47 #ifndef _MIRA_FRAMEWORKGRAPH_H_ 48 #define _MIRA_FRAMEWORKGRAPH_H_ 52 #include <serialization/adapters/std/list> 53 #include <serialization/adapters/boost/shared_ptr.hpp> 65 template <
int C,
typename T>
96 template <
typename NodeMixin = void,
97 typename AuthorityNodeMixin=void,
98 typename ChannelNodeMixin=void,
99 typename NamespaceNodeMixin=void,
100 typename FrameworkNodeMixin=
void>
108 typedef boost::shared_ptr<Node>
NodePtr;
147 std::set<NodePtr> nodes;
194 std::set<NodePtr> nodes;
228 std::map<AuthorityNodePtr, std::set<ChannelNodePtr>> nodes;
230 foreach(
auto a, c->getPublishingAuthorities())
241 std::map<AuthorityNodePtr, std::set<ChannelNodePtr>> nodes;
243 foreach(
auto a, c->getSubscribedAuthorities())
276 parent->children.insert(child);
284 static std::set<NodePtr> empty;
317 static std::set<NodePtr> empty;
369 bool discover(boost::function<
void()> changeCb = boost::function<
void()>())
372 bool graphHasChanged =
false;
375 foreach(
const std::string&
id,
MIRA_FW.getChannelManager().getChannels())
387 auto authorities =
MIRA_FW.getAuthorityManager().getAuthorities();
388 foreach(
auto id, authorities)
396 boost::mutex::scoped_lock lock(
mutex());
402 node->mNamespace = ns;
403 ns->nodes.insert(node);
406 std::string fwid =
"local";
407 foreach(
const auto& connection, *(
MIRA_FW.getRemoteModule()->getConnections()))
409 if (connection.second->hasAuthority(
id)) {
410 fwid = connection.second->getAddress().address;
415 node->mFramework = fw;
416 fw->nodes.insert(node);
422 auto publishedChannels =
MIRA_FW.getAuthorityManager().getPublishedChannels(
id);
423 foreach(
const std::string& channel, publishedChannels)
425 boost::mutex::scoped_lock lock(
mutex());
428 mGraphHasChanged |= channelNode->mPublishingAuthorities.insert(node).second;
431 auto subscribedChannels =
MIRA_FW.getAuthorityManager().getSubscribedChannels(
id);
432 foreach(
const std::string& channel, subscribedChannels)
434 boost::mutex::scoped_lock lock(
mutex());
437 mGraphHasChanged |= channelNode->mSubscribedAuthorities.insert(node).second;
444 return graphHasChanged;
453 node.reset(
new ChannelNode(
id));
456 node->mNamespace = ns;
457 ns->nodes.insert(node);
467 node.reset(
new NamespaceNode(ns));
469 if(!node->ns.isRoot())
480 node.reset(
new FrameworkNode(name));
491 std::list<NodePtr> nodes;
529 if(child->ns.isAncestorOf(node->ns)) {
540 auto childrenSet = ancestor->children;
543 if(child->ns.isChildOf(node->ns)) {
544 node->children.insert(child);
545 ancestor->children.erase(child);
546 child->parent = node;
551 ancestor->children.insert(node);
553 node->parent = ancestor;
558 auto parent_ns = node->ns.parent();
559 if (parent_ns != ancestor->ns)
592 template <
typename Container,
typename Key>
593 typename Container::value_type
findPtr(Container& c,
const Key& key)
595 foreach(
typename Container::value_type ptr, c)
598 return typename Container::value_type();
bool operator==(const std::string &iName)
Definition: FrameworkGraph.h:309
NamespaceNodePtr mRootNamespace
Definition: FrameworkGraph.h:586
std::set< AuthorityNodePtr > getSubscribedAuthorities()
Definition: FrameworkGraph.h:155
std::set< NamespaceNodePtr > children
sub-namespaces that live in this namespace
Definition: FrameworkGraph.h:297
FrameworkNode(const std::string &iName)
Definition: FrameworkGraph.h:308
Base class for all nodes in the framework computation graph.
Definition: FrameworkGraph.h:125
std::string id
the authority id. will be generated for anonymous authorities
Definition: AuthorityDescription.h:96
ResourceName ns
the name of the namespace
Definition: FrameworkGraph.h:291
std::set< ChannelNodePtr > mPublishedChannels
Definition: FrameworkGraph.h:257
std::list< NamespaceNodePtr > mNamespaces
Definition: FrameworkGraph.h:584
boost::shared_ptr< Node > NodePtr
Definition: FrameworkGraph.h:107
std::set< ChannelNodePtr > mSubscribedChannels
Definition: FrameworkGraph.h:256
Container::value_type findPtr(Container &c, const Key &key)
Definition: FrameworkGraph.h:593
std::set< NodePtr > nodes
channel and authority nodes within this framework
Definition: FrameworkGraph.h:327
std::list< ChannelNodePtr > mChannels
Definition: FrameworkGraph.h:583
NamespaceNodePtr getRootNamespace()
Returns the root namespace node.
Definition: FrameworkGraph.h:514
std::list< FrameworkNodePtr > & getFrameworks()
Returns all framework nodes.
Definition: FrameworkGraph.h:510
bool operator==(const std::string &id)
Definition: FrameworkGraph.h:186
NamespaceNodePtr getNamespace()
Returns the namespace node where this channel lives in.
Definition: FrameworkGraph.h:164
boost::shared_ptr< ChannelNode > ChannelNodePtr
Definition: FrameworkGraph.h:110
Descriptive informations about an authority.
Definition: FrameworkGraph.h:66
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
ChannelNode(const std::string &iID)
Definition: FrameworkGraph.h:140
The framework module responsible for connections to remote frameworks.
Represents a single authority in the framwork computation graph.
Definition: FrameworkGraph.h:183
Class for 2D, 3D and N-dimensional points.
FrameworkNodePtr getFramework()
Returns the framework where this authority lives in.
Definition: FrameworkGraph.h:218
std::list< FrameworkNodePtr > mFrameworks
Definition: FrameworkGraph.h:585
virtual std::set< NodePtr > getAdjacentNodes()
Returns the adjacent (incoming and outgoing nodes)
Definition: FrameworkGraph.h:315
std::set< ChannelNodePtr > getPublishedChannels()
Returns all channel nodes with channels that are published by the authority.
Definition: FrameworkGraph.h:203
FrameworkGraph & operator=(FrameworkGraph &&other) noexcept
Definition: FrameworkGraph.h:343
std::set< AuthorityNodePtr > mSubscribedAuthorities
Definition: FrameworkGraph.h:175
boost::mutex mMutex
Definition: FrameworkGraph.h:581
NamespaceNodePtr mNamespace
Definition: FrameworkGraph.h:177
boost::shared_ptr< NamespaceNode > NamespaceNodePtr
Definition: FrameworkGraph.h:116
AuthorityNode(const AuthorityDescription &iDesc)
Definition: FrameworkGraph.h:185
FrameworkNodePtr mFramework
Definition: FrameworkGraph.h:259
#define MIRA_FW
Macro for accessing the framework instance.
Definition: Framework.h:73
void swap(FrameworkGraph &other)
Definition: FrameworkGraph.h:348
virtual std::set< NodePtr > getAdjacentNodes()
Returns the adjacent (incoming and outgoing nodes)
Definition: FrameworkGraph.h:145
std::set< NodePtr > nodes
channel and authority nodes within this namespace
Definition: FrameworkGraph.h:300
This is the descriptive part of an authority.
Definition: AuthorityDescription.h:61
std::set< ChannelNodePtr > getSubscribedChannels()
Returns all channel nodes with channels the authority is subscribed on.
Definition: FrameworkGraph.h:208
std::map< AuthorityNodePtr, std::set< ChannelNodePtr > > getDependers()
Returns all authority nodes that DEPEND on this authority.
Definition: FrameworkGraph.h:240
NamespaceNodePtr getNamespace()
Returns the namespace node where this authority lives in.
Definition: FrameworkGraph.h:213
virtual ~Node()
Definition: FrameworkGraph.h:128
Represents a namespace in the framework computation graph within the overall namespace hierarchy...
Definition: FrameworkGraph.h:266
Class for storing/combining/managing resource names consisting of namespaces and names separated by '...
Definition: ResourceName.h:68
bool mGraphHasChanged
Definition: FrameworkGraph.h:588
std::string name
the name
Definition: FrameworkGraph.h:324
std::map< AuthorityNodePtr, std::set< ChannelNodePtr > > getDependees()
Returns all authority nodes that THIS authority depends on.
Definition: FrameworkGraph.h:227
boost::shared_ptr< AuthorityNode > AuthorityNodePtr
Definition: FrameworkGraph.h:113
bool operator==(const std::string &id)
Definition: FrameworkGraph.h:141
NamespaceNodePtr parent
the namespace parent node (if we are not the root node)
Definition: FrameworkGraph.h:294
Represents a framework in the framework computation graph.
Definition: FrameworkGraph.h:306
boost::mutex & mutex()
Definition: FrameworkGraph.h:359
std::string id
the fully qualified name of the node (the id)
Definition: FrameworkGraph.h:171
std::list< ChannelNodePtr > & getChannels()
Returns all channel nodes.
Definition: FrameworkGraph.h:498
bool discover(boost::function< void()> changeCb=boost::function< void()>())
Discovers the whole structure of all connected frameworks with its authorities, channels, services, etc.
Definition: FrameworkGraph.h:369
virtual std::set< NodePtr > getAdjacentNodes()
Returns the adjacent (incoming and outgoing nodes)
Definition: FrameworkGraph.h:192
static void setParent(NamespaceNodePtr child, NamespaceNodePtr parent)
workaround to avoid shared_from_this
Definition: FrameworkGraph.h:274
std::list< AuthorityNodePtr > & getAuthorities()
Returns all authority nodes.
Definition: FrameworkGraph.h:502
ResourceName ns
the full namespace (starting from root) of this authority
Definition: AuthorityDescription.h:95
std::list< NamespaceNodePtr > & getNamespaces()
Returns all namespace nodes.
Definition: FrameworkGraph.h:506
std::set< AuthorityNodePtr > getPublishingAuthorities()
Definition: FrameworkGraph.h:159
Represents the whole computation graph with all known units/authorities and channels within their nam...
Definition: FrameworkGraph.h:101
NamespaceNode(const ResourceName &iNs)
Definition: FrameworkGraph.h:268
virtual std::set< NodePtr > getAdjacentNodes()=0
Returns the adjacent (incoming and outgoing nodes)
void integrateNamespaceNode(NamespaceNodePtr node)
inserts a new namespace node and reparents the existing namespace nodes, if necessary.
Definition: FrameworkGraph.h:518
std::list< AuthorityNodePtr > mAuthorities
Definition: FrameworkGraph.h:582
AuthorityDescription desc
full information on the authority
Definition: FrameworkGraph.h:252
FrameworkGraph()
Creates an emtpy framework graph object.
Definition: FrameworkGraph.h:333
std::set< AuthorityNodePtr > mPublishingAuthorities
Definition: FrameworkGraph.h:176
FrameworkGraph(FrameworkGraph &&other) noexcept
Definition: FrameworkGraph.h:339
boost::shared_ptr< FrameworkNode > FrameworkNodePtr
Definition: FrameworkGraph.h:119
bool operator==(const ResourceName &iNs)
Definition: FrameworkGraph.h:269
The framework that holds all manager classes and provides startup and shutdown of all framework relat...
NamespaceNodePtr mNamespace
Definition: FrameworkGraph.h:258
Represents a single channel in the framwork computation graph.
Definition: FrameworkGraph.h:137
virtual std::set< NodePtr > getAdjacentNodes()
Returns the adjacent (incoming and outgoing nodes)
Definition: FrameworkGraph.h:282
std::list< NodePtr > getNodes()
Returns all channel and authority nodes.
Definition: FrameworkGraph.h:490