41 #include "../base/AttributeBase.hpp"    44 #include "../Service.hpp"    49 #include <boost/graph/copy.hpp>    53     using namespace detail;
    54     using namespace boost;
    60         : myName(_name), retn(0), pausing(false), mstep(false), munload_on_stop(unload_on_stop)
    73         graph_traits<Graph>::vertex_iterator v1,v2, it;
    75         for ( it=v1; it != v2; ++it)
    79         for ( it=v1; it != v2; ++it)
    85         std::vector<AttributeBase*> argsvect = orig.
getArguments();
    86         std::vector<AttributeBase*>::iterator ita = argsvect.begin();
    87         for ( ; ita != argsvect.end(); ++ita)
    88             this->
args.push_back( (*ita)->clone() );
   102         property_map<Graph, vertex_index_t>::type
   103             index = 
get(vertex_index, 
program);
   107         graph_traits<Graph>::vertex_iterator vi, vend;
   108         graph_traits<Graph>::vertices_size_type cnt = 0;
   109         for(tie(vi,vend) = vertices(
program); vi != vend; ++vi)
   110             put(index, *vi, cnt++);
   120         std::vector<AttributeBase*>::iterator it = 
args.begin();
   121         for ( ; it != 
args.end(); ++it)
   196         return mstep == 
false;
   230         graph_traits<Graph>::out_edge_iterator ei, ei_end;
   232         boost::property_map<Graph, vertex_command_t>::type
   234         boost::property_map<Graph, edge_condition_t>::type
   242             if ( previous != current )
   244                     for ( tie(ei, ei_end) = boost::out_edges( current, 
program ); ei != ei_end; ++ei)
   247                         cmap[current].startExecution();
   258                 cmap[current].execute();
   265             if ( cmap[current].isValid() ) {
   266                 for ( tie(ei, ei_end) = boost::out_edges( current, 
program ); ei != ei_end; ++ei) {
   268                         if ( emap[*ei].evaluate() ) {
   269                             current = boost::target(*ei, 
program);
   283         if (current == 
exitv) {
   292         graph_traits<Graph>::out_edge_iterator ei, ei_end;
   294         boost::property_map<Graph, vertex_command_t>::type
   296         boost::property_map<Graph, edge_condition_t>::type
   300         if ( previous != current )
   302             for ( tie(ei, ei_end) = boost::out_edges( current, 
program ); ei != ei_end; ++ei)
   305                 cmap[current].startExecution();
   315             cmap[current].execute();
   322         if ( cmap[current].isValid() ) {
   323             for ( tie(ei, ei_end) = boost::out_edges( current, 
program ); ei != ei_end; ++ei) {
   325                     if ( emap[*ei].evaluate() ) {
   326                         current = boost::target(*ei, 
program);
   327                         if (current == 
exitv)
   340         if (current == 
exitv)
   385         typedef boost::property_map<Graph, vertex_index_t>::const_type indexmap_t;
   386         typedef boost::graph_traits<Graph>::vertex_descriptor vd_t;
   387         typedef std::vector<vd_t> o2cvect_t;
   388         typedef boost::iterator_property_map<o2cvect_t::iterator, indexmap_t, vd_t, vd_t&> o2cmap_t;
   395         indexmap_t indexmap = 
get( vertex_index, 
program );
   397         o2cvect_t o2cvect( num_vertices( 
program ) );
   398         o2cmap_t o2cmap( o2cvect.begin(), indexmap );
   408         for (
unsigned int i=0; i < 
args.size(); ++i)
   414                            boost::vertex_copy( GraphVertexCopier( 
program, ret->
program, replacementdss ) ).
   415                            edge_copy( GraphEdgeCopier( 
program, ret->
program, replacementdss ) ).
   416                            orig_to_copy( o2cmap ) );
   420         ret->current = o2cmap[current];
   421         ret->previous = o2cmap[previous];
   439         graph_traits<Graph>::vertex_iterator v,vend;
   440         tie(v,vend) = vertices(
program);
   441         boost::property_map<Graph, vertex_command_t>::const_type
   443         boost::property_map<Graph, vertex_index_t>::const_type
   444             imap = 
get(vertex_index, 
program);
   446         std::cerr << 
" number of vertices: " << boost::num_vertices(
program) << 
std::endl;
   447         for ( ; v != vend; ++v )
   449             int index = 
get( imap, *v );
   452                 std::cerr << 
" " << index << 
" " << 
typeid( *cmd ).name() << 
std::endl;
   454                 std::cerr << 
" " << index << 
" (null)" << 
std::endl;
   460         for (std::vector<AttributeBase*>::iterator it = 
args.begin(); it != 
args.end(); ++it)
 virtual bool stepDone() const 
const Graph & getGraph() const 
void debugPrintout() const 
void setUnloadOnStop(bool unload_on_stop)
Sets the unloading policy on stop or error. 
virtual AttributeBase * copy(std::map< const DataSourceBase *, DataSourceBase * > &replacements, bool instantiate)=0
Returns a copy of this AttributeBase. 
Graph program
The graph containing this function. 
virtual bool removeFunction(base::ExecutableInterface *f)
Remove a running function added with runFunction. 
virtual AttributeBase * clone() const =0
Returns a clone of this AttributeBase. 
std::vector< base::AttributeBase * > args
Ordered arguments (are also in the repository). 
bool isLoaded()
Returns true if this object is loaded in an ExecutionEngine. 
virtual FunctionGraph * clone() const 
virtual bool stop()
Stop the execution of this program. 
void setResult(base::AttributeBase *r)
Will store the result in this attribute. 
virtual const std::string & getName() const 
Programs can be refered to by name. 
base::AttributeBase * retn
virtual void loading()
Informs this object that it got loaded in an ExecutionEngine. 
virtual void reset()
Identical to stop();. 
void clearArguments()
Clear the arguments vector and release all base::AttributeBase resources. 
virtual bool start()
Start the execution of this program. 
basic_ostreams & endl(basic_ostreams &s)
Flush and newline. 
std::string _text
Program text. 
boost::shared_ptr< Service > shared_ptr
std::string getText() const 
Return the program text to which getLineNumber() refers. 
std::string myName
The (unique) name of this program. 
virtual int getLineNumber() const 
Return the current 'line number' of the program. 
The program was running but is now paused. 
Based on the software pattern 'command', this interface allows execution of action objects...
Status::ProgramStatus pStatus
std::vector< base::AttributeBase * > getArguments() const 
Return an ordered list of this funcion's arguments. 
void setProgramService(ServicePtr myservice)
Set a service that manages this script. 
virtual bool pause()
Pause or start-and-pause the execution of this program. 
void finish()
To be called after a function is constructed. 
ExecutionEngine * getEngine()
Returns the ExecutionEngine this object is loaded into or null otherwise. 
void setName(const std::string &_name)
Set the name of this program. 
virtual FunctionGraph * copy(std::map< const base::DataSourceBase *, base::DataSourceBase * > &replacementdss) const 
Clone this Program. 
virtual bool execute()
Execute as much actions until the program needs to wait on a condition to become true. 
This program is currently not loaded in an ExecutionEngine. 
FunctionGraph(const std::string &name, bool unload_on_stop)
Create a FunctionGraph with a given name. 
void addArgument(base::AttributeBase *a)
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute. 
virtual void unloading()
Informs this object that it got unloaded from an ExecutionEngine. 
This class represents a function. 
The program is not running. 
virtual bool step()
Execute a single action when paused. 
void setText(const std::string &t)
Set the program text.