View on GitHub

Vistle

Distributed Data-parallel Scientific Visualization in VR

port.h
Go to the documentation of this file.
1#ifndef PORT_H
2#define PORT_H
3
4#include <string>
5#include <vector>
6#include <set>
7#include <deque>
8#include <ostream>
9#include <memory>
10
11#include <vistle/util/enum.h>
12#include "export.h"
13
14namespace vistle {
15
16class Object;
17typedef std::shared_ptr<const Object> obj_const_ptr;
18typedef std::deque<obj_const_ptr> ObjectList;
19
20namespace detail {
21
22template<class T>
24 bool operator()(const T *x, const T *y) const { return *x < *y; }
25};
26
27} // namespace detail
28
30 friend class PortTracker;
31
32public:
33 DEFINE_ENUM_WITH_STRING_CONVERSIONS(Type, (ANY)(INPUT)(OUTPUT)(PARAMETER))
35 Flags,
36 (NONE)(NOCOMPUTE) //< compute won't be called for objects received via this port
37 (COMBINE_BIT) //< several connections to a single port are allowed and should be processed together - only together with NOCOMPUTE
38 (COMBINE) //< several connections to a single port are allowed and should be processed together
39 (MULTI) //< additional ports are created for each connected port
40 )
41
42 Port(int moduleID, const std::string &name, Port::Type type, int flags = 0);
43 void setDescription(const std::string &desc);
44 int getModuleID() const;
45 const std::string &getName() const;
46 const std::string &getDescription() const;
47 Type getType() const;
48 int flags() const;
49
50 ObjectList &objects();
51 const ObjectList &objects() const;
52
53 typedef std::set<Port *, detail::deref_compare<Port>> PortSet;
54 typedef std::set<const Port *, detail::deref_compare<Port>> ConstPortSet;
55 const ConstPortSet &connections() const;
56 void setConnections(const ConstPortSet &conn);
57 bool addConnection(Port *other);
58 const Port *removeConnection(const Port &other);
59 bool isConnected() const;
60
61 const PortSet &linkedPorts() const;
62
63 bool operator<(const Port &other) const
64 {
65 if (getModuleID() == other.getModuleID()) {
66 return getName() < other.getName();
67 }
68 return getModuleID() < other.getModuleID();
69 }
70 bool operator==(const Port &other) const
71 {
72 return getModuleID() == other.getModuleID() && getName() == other.getName();
73 }
74
76 Port *child(size_t idx, bool link = false);
78 bool link(Port *linked);
79
80private:
81 int moduleID;
82 std::string name;
83 std::string description;
84 Type type;
85 int m_flags;
86 ObjectList m_objects;
87 ConstPortSet m_connections;
88 Port *m_parent;
89 std::vector<Port *> m_children;
90 PortSet m_linkedPorts;
91};
92
93V_COREEXPORT std::ostream &operator<<(std::ostream &s, const Port &port);
94
95V_ENUM_OUTPUT_OP(Type, Port)
96V_ENUM_OUTPUT_OP(Flags, Port)
97
98} // namespace vistle
99#endif
Definition: porttracker.h:18
Definition: port.h:29
bool operator==(const Port &other) const
Definition: port.h:70
std::set< Port *, detail::deref_compare< Port > > PortSet
Definition: port.h:53
int getModuleID() const
Definition: port.cpp:20
std::set< const Port *, detail::deref_compare< Port > > ConstPortSet
Definition: port.h:54
DEFINE_ENUM_WITH_STRING_CONVERSIONS(Type,(ANY)(INPUT)(OUTPUT)(PARAMETER)) DEFINE_ENUM_WITH_STRING_CONVERSIONS(Flags
const std::string & getName() const
Definition: port.cpp:25
#define V_COREEXPORT
Definition: export.h:9
#define V_ENUM_OUTPUT_OP(name, scope)
Definition: enum.h:72
@ NONE
Definition: celltypes.h:19
Definition: allobjects.cpp:30
std::deque< obj_const_ptr > ObjectList
Definition: port.h:18
std::shared_ptr< const Object > obj_const_ptr
Definition: archives.h:86
std::ostream & operator<<(std::ostream &out, const Meta &meta)
Definition: objectmeta.cpp:45
DEFINE_ENUM_WITH_STRING_CONVERSIONS(FieldCompressionMode,(Uncompressed)(ZfpFixedRate)(ZfpAccuracy)(ZfpPrecision)) namespace detail
Definition: archives_config.h:38
Definition: port.h:23
bool operator()(const T *x, const T *y) const
Definition: port.h:24