View on GitHub

Vistle

Distributed Data-parallel Scientific Visualization in VR

availablemodule.h
Go to the documentation of this file.
1#ifndef VISTLE_AVAILABLEMODULE_H
2#define VISTLE_AVAILABLEMODULE_H
3
4#include <map>
5#include <set>
6#include <string>
7#include <vector>
8#include "export.h"
9#include "message.h"
10#include "messages.h"
11#include "messagepayload.h"
12#include "object.h"
13namespace vistle {
14
15const int ModuleNameLength = 50;
16typedef std::function<bool(const message::Message &msg, const buffer *payload)> sendMessageFunction;
17typedef std::function<bool(const message::Message &msg, const MessagePayload &payload)> sendShmMessageFunction;
18
20public:
21 friend class ModuleBaseMessage;
22 struct Key {
23 int hub;
24 std::string name;
25 Key(int hub, const std::string &name);
26 bool operator<(const Key &rhs) const;
27 };
29 AvailableModuleBase(int hub, const std::string &name, const std::string &path, const std::string &description);
30 AvailableModuleBase(const message::Message &msg, const buffer &payload);
35 virtual ~AvailableModuleBase() = default;
36 int hub() const;
37 const std::string &name() const;
38 const std::string &path() const;
39 const std::string &description() const;
40 void setHub(int hubId);
41 std::string print() const;
42 bool isCompound() const;
43 struct SubModule {
44 std::string name;
45 float x, y; //offset in mapeditor if split
47 template<class Archive>
48 void serialize(Archive &ar)
49 {
50 ar &name;
51 ar &x;
52 ar &y;
53 }
54 };
55 struct Connection {
56 int fromId, toId; //relative to first submodule
57 std::string fromPort, toPort;
58 bool operator<(const Connection &other) const
59 {
60 bool retval = other.fromId < fromId;
61 if (other.fromId == fromId)
62 retval = other.toId < toId;
63 else
64 return retval;
65 if (other.toId == toId)
66 retval = other.fromPort < fromPort;
67 else
68 return retval;
69 if (other.fromPort == fromPort)
70 retval = other.toPort < toPort;
71 return retval;
72 }
74 template<class Archive>
75 void serialize(Archive &ar)
76 {
77 ar &fromId;
78 ar &toId;
79 ar &fromPort;
80 ar &toPort;
81 }
82 };
83
84 size_t addSubmodule(const SubModule &sub);
85 void addConnection(const Connection &conn);
86 const std::vector<SubModule> submodules() const;
87 const std::set<Connection> connections() const;
88
89protected:
90 bool send(message::Type type, const sendMessageFunction &func) const;
91 bool send(message::Type type, const sendShmMessageFunction &func) const;
92
93private:
94 int m_hub;
95 std::string m_name;
96 std::string m_path;
97 std::string m_description;
98
99
100 //for module compounds
101 std::set<Connection> m_connections; //maps input-, outputports and params to parent ones
102 std::vector<SubModule> m_submodules;
103
104 mutable vistle::buffer m_cacheBuffer;
105 mutable vistle::MessagePayload m_cacheMessagePayload;
106 mutable bool m_changed = true;
107 std::unique_ptr<message::Message> cacheMsg(message::Type type) const;
108
110 template<class Archive>
111 void serialize(Archive &ar)
112 {
113 ar &m_description;
114 ar &m_connections;
115 ar &m_submodules;
116 }
117};
118const std::string moduleCompoundSuffix = ".vsl";
119class ModuleCompound;
121public:
122 friend class ModuleCompound;
124 bool send(const sendMessageFunction &func) const;
125 bool send(const sendShmMessageFunction &func) const;
126
127private:
129};
130
132public:
134 bool send(const sendMessageFunction &func) const;
135 bool send(const sendShmMessageFunction &func) const;
136 AvailableModule transform(); //this invalidates this object;
137};
138typedef std::map<AvailableModule::Key, AvailableModule> AvailableMap;
139
140
141} // namespace vistle
142#endif
#define ARCHIVE_ACCESS
Definition: archives_config.h:465
Definition: availablemodule.h:19
virtual ~AvailableModuleBase()=default
AvailableModuleBase(const AvailableModuleBase &)=delete
AvailableModuleBase & operator=(AvailableModuleBase &&)=default
AvailableModuleBase(AvailableModuleBase &&)=default
AvailableModuleBase & operator=(const AvailableModuleBase &)=delete
Definition: availablemodule.h:120
Definition: availablemodule.h:131
Definition: message.h:157
Definition: shm_reference.h:15
#define V_COREEXPORT
Definition: export.h:9
void serialize(Archive &ar, vistle::Vector1 &v, const unsigned int version)
Definition: vector.h:105
bool send(socket_t &sock, const message::Message &msg, error_code &ec, const char *payload, size_t size)
Definition: tcpmessage.cpp:447
Definition: allobjects.cpp:30
std::function< bool(const message::Message &msg, const MessagePayload &payload)> sendShmMessageFunction
Definition: availablemodule.h:17
std::vector< char, allocator< char > > buffer
Definition: buffer.h:9
std::map< AvailableModule::Key, AvailableModule > AvailableMap
Definition: availablemodule.h:138
std::function< bool(const message::Message &msg, const buffer *payload)> sendMessageFunction
Definition: availablemodule.h:16
bool operator<(const ParameterVector< S > &v1, const ParameterVector< S > &v2)
Definition: paramvector_impl.h:243
const int ModuleNameLength
Definition: availablemodule.h:15
const std::string moduleCompoundSuffix
Definition: availablemodule.h:118
Definition: availablemodule.h:55
std::string fromPort
Definition: availablemodule.h:57
ARCHIVE_ACCESS void serialize(Archive &ar)
Definition: availablemodule.h:75
bool operator<(const Connection &other) const
Definition: availablemodule.h:58
std::string toPort
Definition: availablemodule.h:57
int toId
Definition: availablemodule.h:56
int fromId
Definition: availablemodule.h:56
Definition: availablemodule.h:22
std::string name
Definition: availablemodule.h:24
int hub
Definition: availablemodule.h:23
Definition: availablemodule.h:43
float x
Definition: availablemodule.h:45
ARCHIVE_ACCESS void serialize(Archive &ar)
Definition: availablemodule.h:48
std::string name
Definition: availablemodule.h:44