Orocos Real-Time Toolkit  2.9.0
CommandDataSource.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: Peter Soetens Wed Jan 18 14:11:38 CET 2006 CommandDataSource.hpp
3 
4  CommandDataSource.hpp - description
5  -------------------
6  begin : Wed January 18 2006
7  copyright : (C) 2006 Peter Soetens
8  email : peter.soetens@mech.kuleuven.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 #ifndef ORO_COMMAND_DATASOURCE_HPP
40 #define ORO_COMMAND_DATASOURCE_HPP
41 
42 #include "../internal/DataSource.hpp"
43 #include "../base/ActionInterface.hpp"
44 
45 namespace RTT
46 { namespace scripting {
47 
53  {
56  : _dsb(dsb) {}
57 
59  {
60  }
61 
62  bool execute() {
63  _dsb->evaluate();
64  return true;
65  }
66 
67  void reset() {
68  _dsb->reset();
69  }
70 
72  return new CommandDataSource( _dsb );
73  }
74 
75  base::ActionInterface* copy( std::map<const base::DataSourceBase*, base::DataSourceBase*>& alreadyCloned ) const {
76  return new CommandDataSource( _dsb->copy( alreadyCloned ) );
77  }
78 
79  };
80 
86  {
89  : _dsb(dsb) {}
90 
92  {
93  }
94 
95  bool execute() {
96  _dsb->evaluate();
97  return _dsb->value();
98  }
99  void reset() {
100  _dsb->reset();
101  }
103  return new CommandDataSourceBool( _dsb );
104  }
105 
106  base::ActionInterface* copy( std::map<const base::DataSourceBase*, base::DataSourceBase*>& alreadyCloned ) const {
107  return new CommandDataSourceBool( _dsb->copy( alreadyCloned ) );
108  }
109 
110  };
111 
112 }}
113 
114 #endif
A Command which evaluates a internal::DataSource<bool> and returns the result of get().
base::ActionInterface * clone() const
The Clone Software Pattern.
base::DataSourceBase::shared_ptr _dsb
base::ActionInterface * clone() const
The Clone Software Pattern.
virtual void reset()
Reset the data to initial values.
Definition: DataSource.cpp:87
CommandDataSourceBool(internal::DataSource< bool >::shared_ptr dsb)
virtual DataSource< T > * copy(std::map< const base::DataSourceBase *, base::DataSourceBase * > &alreadyCloned) const =0
Create a deep copy of this internal::DataSource, unless it is already cloned.
void readArguments()
This is invoked some time before execute() at a time when the action may read its function arguments...
base::ActionInterface * copy(std::map< const base::DataSourceBase *, base::DataSourceBase * > &alreadyCloned) const
When copying an Orocos program, we want identical internal::DataSource&#39;s to be mapped to identical Da...
bool execute()
Execute the functionality of this action.
internal::DataSource< bool >::shared_ptr _dsb
Based on the software pattern &#39;command&#39;, this interface allows execution of action objects...
void reset()
Reset this action.
A Command which evaluates a base::DataSourceBase and always returns true.
boost::intrusive_ptr< DataSource< T > > shared_ptr
Definition: DataSource.hpp:115
bool execute()
Execute the functionality of this action.
void readArguments()
This is invoked some time before execute() at a time when the action may read its function arguments...
virtual result_t value() const =0
Return the result of the last evaluate() function.
boost::intrusive_ptr< DataSourceBase > shared_ptr
Use this type to store a pointer to a DataSourceBase.
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:52
virtual bool evaluate() const
Force an evaluation of the DataSourceBase.
Definition: DataSource.inl:52
base::ActionInterface * copy(std::map< const base::DataSourceBase *, base::DataSourceBase * > &alreadyCloned) const
When copying an Orocos program, we want identical internal::DataSource&#39;s to be mapped to identical Da...
CommandDataSource(base::DataSourceBase::shared_ptr dsb)