Orocos Real-Time Toolkit  2.8.3
GraphCopier.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: Peter Soetens Tue Dec 21 22:43:07 CET 2004 GraphCopier.hpp
3 
4  GraphCopier.hpp - description
5  -------------------
6  begin : Tue December 21 2004
7  copyright : (C) 2004 Peter Soetens
8  email : peter.soetens@mech.kuleuven.ac.be
9 
10  ***************************************************************************
11  * This library is free software; you can redistribute it and/or *
12  * modify it under the terms of the GNU General Public *
13  * License as published by the Free Software Foundation; *
14  * version 2 of the License. *
15  * *
16  * As a special exception, you may use this file as part of a free *
17  * software library without restriction. Specifically, if other files *
18  * instantiate templates or use macros or inline functions from this *
19  * file, or you compile this file and link it with other files to *
20  * produce an executable, this file does not by itself cause the *
21  * resulting executable to be covered by the GNU General Public *
22  * License. This exception does not however invalidate any other *
23  * reasons why the executable file might be covered by the GNU General *
24  * Public License. *
25  * *
26  * This library is distributed in the hope that it will be useful, *
27  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
28  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
29  * Lesser General Public License for more details. *
30  * *
31  * You should have received a copy of the GNU General Public *
32  * License along with this library; if not, write to the Free Software *
33  * Foundation, Inc., 59 Temple Place, *
34  * Suite 330, Boston, MA 02111-1307 USA *
35  * *
36  ***************************************************************************/
37 
38 
39 #include "FunctionGraph.hpp"
40 
41  namespace {
42 
43  using namespace RTT;
44  using namespace RTT::detail;
45  using namespace boost;
46 
47  // these two are used as policy parameters for the
48  // boost::copy_graph function.
49  class GraphVertexCopier {
50  typedef FunctionGraph::Graph Graph;
51  typedef graph_traits<Graph>::vertex_descriptor VertexDesc;
52  std::map<const base::DataSourceBase*, base::DataSourceBase*>& rdss;
53  property_map<Graph, vertex_command_t>::const_type commandmap1;
54  property_map<Graph, vertex_exec_t>::const_type allmap1;
55  property_map<Graph, vertex_command_t>::type commandmap2;
56  property_map<Graph, vertex_exec_t>::type allmap2;
57  public:
58  GraphVertexCopier( const Graph& g1, Graph& g2,
59  std::map<const base::DataSourceBase*, base::DataSourceBase*>& replacementdss )
60  : rdss( replacementdss ),
61  commandmap1( get( vertex_command, g1 ) ), allmap1( get( vertex_exec, g1 ) ),
62  commandmap2( get( vertex_command, g2 ) ), allmap2( get( vertex_exec, g2 ) )
63  {
64  }
65  void operator()( const VertexDesc& a, VertexDesc& b )
66  {
67  // copy exec prop first
68  put( allmap2, b, get( allmap1, a ) );
69  // copy the commands, using the 'copy' semantics of VertexNode.
70  put( commandmap2, b, get( commandmap1, a ).copy( rdss ) );
71  }
72  };
73 
74  class GraphEdgeCopier {
75  typedef FunctionGraph::Graph Graph;
76  typedef graph_traits<Graph>::edge_descriptor EdgeDesc;
77  std::map<const base::DataSourceBase*, base::DataSourceBase*>& rdss;
78  property_map<Graph, edge_condition_t>::const_type conditionmap1;
79  property_map<Graph, edge_condition_t>::type conditionmap2;
80 // property_map<Graph, edge_exec_t>::const_type allmap1;
81 // property_map<Graph, edge_exec_t>::type allmap2;
82  public:
83  GraphEdgeCopier( const Graph& g1, Graph& g2,
84  std::map<const base::DataSourceBase*, base::DataSourceBase*>& replacementdss )
85  : rdss( replacementdss ),
86  conditionmap1( get( edge_condition, g1 ) ), conditionmap2( get( edge_condition, g2 ) )
87 // allmap1( get( edge_all, g1 ) ), allmap2( get( edge_all, g2 ) )
88  {
89  }
90  void operator()( const EdgeDesc& a, const EdgeDesc& b )
91  {
92 // put( allmap2, b, get( allmap1, a ) );
93  put( conditionmap2, b, get( conditionmap1, a ).copy( rdss ) );
94  }
95  };
96  }
97 
boost::adjacency_list< boost::vecS, boost::listS, boost::directedS, VertProperty, EdgeProperty > Graph
Convenient short notation for every sub-namespace of RTT.
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:51