icub-client
action.h
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2014 WYSIWYD Consortium, European Commission FP7 Project ICT-612139
3 * Authors: Gori Ilaria and Petit Maxime
4 * email: ilaria.gori@iit.it, maxime.petit@inserm.fr
5 * website: https://github.com/robotology/icub-client/
6 * Permission is granted to copy, distribute, and/or modify this program
7 * under the terms of the GNU General Public License, version 2 or any
8 * later version published by the Free Software Foundation.
9 *
10 * A copy of the license can be found at
11 * icub-client/license/gpl.txt
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
16 * Public License for more details
17 */
18 
19 #ifndef __ICUBCLIENT_ACTION_H__
20 #define __ICUBCLIENT_ACTION_H__
21 
22 #include "entity.h"
23 #include "relation.h"
24 #include "icubclient/tags.h"
25 
26 namespace icubclient{
27 
33  class Action:public Entity
34  {
35  friend class OPCClient;
36 
37  Relation initialDescription;
38  std::list<Action> subActions;
40  public:
44  std::map<std::string, double> estimatedDriveEffects;
45 
46  Action();
47  Action(const Action &b);
48 
49  virtual bool isType(std::string _entityType) const
50  {
51  if (_entityType == ICUBCLIENT_OPC_ENTITY_ACTION)
52  return true;
53  else
54  return this->Entity::isType(_entityType);
55  }
56 
57  void setInitialDescription(const Relation &r);
58  Relation description() const;
59  Action express(const Relation &r) const;
60 
65  void append(Action &a);
66 
70  virtual std::list<Action> asPlan() const;
71 
76  virtual std::list<Action> asPlan(const Relation& newDescription) const;
77 
81  virtual bool isComposite(){ return subActions.size(); }
82 
86  int size(){ return subActions.size(); }
87 
91  virtual yarp::os::Bottle asBottle() const;
92  virtual bool fromBottle(const yarp::os::Bottle &b);
93  virtual std::string toString() const;
94 
99  virtual void getPlanDrivesEffect(std::map<std::string,double> &driveEffects);
100 
105  virtual std::string toString(const Relation &newRelation) const;
106  };
107 
108 }//Namespace
109 
110 #endif
111 
virtual yarp::os::Bottle asBottle() const
Number of subactions composing this one.
Definition: action.cpp:39
virtual void getPlanDrivesEffect(std::map< std::string, double > &driveEffects)
Estimate the effect of this plan on a specific drive, by summing all the effects of subplans to this ...
Definition: action.cpp:158
Represent any entity that can be stored within the OPC.
Definition: entity.h:40
void append(Action &a)
Append a subaction to create a composite one.
Definition: action.cpp:131
int size()
Number of subactions composing this one.
Definition: action.h:86
virtual bool isType(std::string _entityType) const
Test if an entity is inheriting a given type.
Definition: entity.h:67
virtual std::list< Action > asPlan() const
Get an unrolled plan description.
Definition: action.cpp:136
Represents an action, whether composite or not.
Definition: action.h:33
Relation description() const
Return initialDescription as Relation.
Definition: action.cpp:124
An OPC client using the datastructures defined within the icub-client library.
Definition: opcClient.h:35
virtual bool fromBottle(const yarp::os::Bottle &b)
Fill entity fields from a bottle representation.
Definition: action.cpp:68
virtual bool isComposite()
Is an action composite or not?
Definition: action.h:81
void setInitialDescription(const Relation &r)
Definition: action.cpp:99
Represent a relation between two entities.
Definition: relation.h:31
#define ICUBCLIENT_OPC_ENTITY_ACTION
Definition: tags.h:41
std::map< std::string, double > estimatedDriveEffects
Estimated effects on the drive.
Definition: action.h:44
virtual bool isType(std::string _entityType) const
Test if an entity is inheriting a given type.
Definition: action.h:49
virtual std::string toString() const
Return a human readable description of the entity.
Definition: action.cpp:172
Action express(const Relation &r) const
Definition: action.cpp:104