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;
346 bool discover(boost::function<
void()> changeCb = boost::function<
void()>())
349 bool graphHasChanged =
false;
352 foreach(
const std::string&
id,
MIRA_FW.getChannelManager().getChannels())
364 auto authorities =
MIRA_FW.getAuthorityManager().getAuthorities();
365 foreach(
auto id, authorities)
373 boost::mutex::scoped_lock lock(
mMutex);
379 node->mNamespace = ns;
380 ns->nodes.insert(node);
383 std::string fwid =
"local";
384 foreach(
const auto& connection, *(
MIRA_FW.getRemoteModule()->getConnections()))
386 if (connection.second->hasAuthority(
id)) {
387 fwid = connection.second->getAddress().address;
392 node->mFramework = fw;
393 fw->nodes.insert(node);
399 auto publishedChannels =
MIRA_FW.getAuthorityManager().getPublishedChannels(
id);
400 foreach(
const std::string& channel, publishedChannels)
402 boost::mutex::scoped_lock lock(
mMutex);
405 mGraphHasChanged |= channelNode->mPublishingAuthorities.insert(node).second;
408 auto subscribedChannels =
MIRA_FW.getAuthorityManager().getSubscribedChannels(
id);
409 foreach(
const std::string& channel, subscribedChannels)
411 boost::mutex::scoped_lock lock(
mMutex);
414 mGraphHasChanged |= channelNode->mSubscribedAuthorities.insert(node).second;
421 return graphHasChanged;
430 node.reset(
new ChannelNode(
id));
433 node->mNamespace = ns;
434 ns->nodes.insert(node);
444 node.reset(
new NamespaceNode(ns));
446 if(!node->ns.isRoot())
457 node.reset(
new FrameworkNode(name));
468 std::list<NodePtr> nodes;
479 template <
typename Visitor>
481 boost::mutex::scoped_lock lock(
mMutex);
516 if(child->ns.isAncestorOf(node->ns)) {
527 auto childrenSet = ancestor->children;
530 if(child->ns.isChildOf(node->ns)) {
531 node->children.insert(child);
532 ancestor->children.erase(child);
533 child->parent = node;
538 ancestor->children.insert(node);
540 node->parent = ancestor;
545 auto parent_ns = node->ns.parent();
546 if (parent_ns != ancestor->ns)
579 template <
typename Container,
typename Key>
580 typename Container::value_type
findPtr(Container& c,
const Key& key)
582 foreach(
typename Container::value_type ptr, c)
585 return typename Container::value_type();
bool operator==(const std::string &iName)
Definition: FrameworkGraph.h:309
NamespaceNodePtr mRootNamespace
Definition: FrameworkGraph.h:573
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:571
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:580
std::set< NodePtr > nodes
channel and authority nodes within this framework
Definition: FrameworkGraph.h:327
std::list< ChannelNodePtr > mChannels
Definition: FrameworkGraph.h:570
NamespaceNodePtr getRootNamespace()
Returns the root namespace node.
Definition: FrameworkGraph.h:501
std::list< FrameworkNodePtr > & getFrameworks()
Returns all framework nodes.
Definition: FrameworkGraph.h:497
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:572
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
std::set< AuthorityNodePtr > mSubscribedAuthorities
Definition: FrameworkGraph.h:175
boost::mutex mMutex
Definition: FrameworkGraph.h:568
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
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:575
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
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:475
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:346
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:489
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:493
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:505
std::list< AuthorityNodePtr > mAuthorities
Definition: FrameworkGraph.h:569
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
void visitAuthorities(Visitor &&visit)
visit all authories
Definition: FrameworkGraph.h:480
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:467