Orocos Real-Time Toolkit  2.8.3
VertexNode.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: Peter Soetens Mon May 10 19:10:37 CEST 2004 VertexNode.cxx
3 
4  VertexNode.cxx - description
5  -------------------
6  begin : Mon May 10 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 #include "VertexNode.hpp"
38 #include "CommandNOP.hpp"
39 #include "../base/ActionInterface.hpp"
40 #include "../internal/DataSource.hpp"
41 
42 namespace RTT {
43  using namespace detail;
44 
45 
47  : command( new CommandNOP ),
48  lineNumber( 0 )
49  {
50  }
51 
53  : command( orig.getCommand()->clone() ),
54  lineNumber(orig.getLineNumber())
55  {
56  }
57 
59  : command( cmd ),
60  lineNumber( 0 )
61  {
62  }
63 
65  {
66  delete command;
67  }
68 
69 
71  {
76  return command->execute();
77  }
78 
79  bool VertexNode::isValid() const {
80  return command->valid();
81  }
82 
84  {
85  return command;
86  }
87 
89  {
90  ActionInterface* old = command;
91  command = cmd;
92  return old;
93  }
94 
96  {
97  lineNumber = ln ;
98  }
99 
101  {
102  return lineNumber;
103  }
104 
106  {
107  // reset the command
108  command->reset();
109  command->readArguments();
110  }
111 
112  VertexNode VertexNode::copy( std::map<const DataSourceBase*, DataSourceBase*>& rdss ) const
113  {
114  VertexNode ret( *this );
115  delete ret.setCommand( getCommand()->copy( rdss ) );
116  return ret;
117  }
118 
120  {
121  if ( &orig == this)
122  return *this;
123  delete command;
124  command = orig.getCommand()->clone();
125  lineNumber = orig.getLineNumber();
126  return *this;
127  }
128 }
~VertexNode()
Returns a special program node that contains no clauses and a special stopExecution command...
Definition: VertexNode.cpp:64
base::ActionInterface * getCommand() const
Returns the command currently associated with this node.
Definition: VertexNode.cpp:83
void startExecution()
This means that the execution engine has just started to execute this node, after some other node has...
Definition: VertexNode.cpp:105
virtual void reset()
Reset this action.
This class represents elements in a program tree.
Definition: VertexNode.hpp:76
virtual void readArguments()=0
This is invoked some time before execute() at a time when the action may read its function arguments...
virtual bool valid() const
Inspect if this action was executed and valid.
The empty command.
Definition: CommandNOP.hpp:52
VertexNode()
Construct an empty program node with no command, no conditional branches and line number 0...
Definition: VertexNode.cpp:46
VertexNode copy(std::map< const base::DataSourceBase *, base::DataSourceBase * > &rdss) const
Definition: VertexNode.cpp:112
int getLineNumber() const
Returns the program line number currently associated with this program node (default = zero)...
Definition: VertexNode.cpp:100
virtual ActionInterface * clone() const =0
The Clone Software Pattern.
base::ActionInterface * setCommand(base::ActionInterface *c)
Set the command associated with this program to the given command.
Definition: VertexNode.cpp:88
virtual bool execute()=0
Execute the functionality of this action.
Based on the software pattern &#39;command&#39;, this interface allows execution of action objects...
bool isValid() const
Returns true if the node is in a valid state to be left.
Definition: VertexNode.cpp:79
bool execute()
Executes the command currently associated with this node.
Definition: VertexNode.cpp:70
void setLineNumber(int ln)
Set line number of this program node to given line number.
Definition: VertexNode.cpp:95
VertexNode & operator=(const VertexNode &orig)
Definition: VertexNode.cpp:119
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:51