icub-client
relation.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 WYSIWYD Consortium, European Commission FP7 Project ICT-612139
3  * Authors: Stéphane Lallée
4  * email: stephane.lallee@gmail.com
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_RELATION_H__
20 #define __ICUBCLIENT_RELATION_H__
21 
22 #include "entity.h"
23 
24 namespace icubclient{
25 
31  class Relation
32  {
33  friend class OPCClient;
34 
35  private:
36  int m_opcId;
37 
38  public:
39  std::string m_verb;
40  std::string m_subject;
41  std::string m_object;
42  std::string m_complement_place;
43  std::string m_complement_time;
44  std::string m_complement_manner;
45 
47  m_opcId = -1;
48  }
49  Relation(yarp::os::Bottle &b);
50  Relation(
51  std::string subject,
52  std::string verb,
53  std::string object = "none",
54  std::string complement_place = "none",
55  std::string complement_time = "none",
56  std::string complement_manner = "none");
57 
58  Relation(
59  Entity* subject,
60  Entity* verb,
61  Entity* object = nullptr,
62  Entity* complement_place = nullptr,
63  Entity* complement_time = nullptr,
64  Entity* complement_manner = nullptr
65  );
66 
67  virtual ~Relation() {}
68 
69  yarp::os::Bottle asBottle(bool ignoreID = false) const;
70 
74  yarp::os::Bottle asLightBottle() const;
75 
80  void fromBottle(const yarp::os::Bottle &b);
81 
85  virtual std::string toString() const;
86 
90  int ID() const;
91 
95  std::string subject() const;
96 
100  std::string object() const;
101 
105  std::string verb() const;
106 
110  std::string complement_place() const;
111 
115  std::string complement_time() const;
116 
120  std::string complement_manner() const;
121 
122  bool operator==(const Relation &b) const;
123  bool operator<(const Relation &b) const;
124  bool operator>(const Relation &b) const;
125  };
126 
127 } //namespace
128 
129 #endif
130 
void fromBottle(const yarp::os::Bottle &b)
Create a Relation from a Bottle.
Definition: relation.cpp:179
std::string complement_manner() const
Get the complement of manner of the relation.
Definition: relation.cpp:236
yarp::os::Bottle asBottle(bool ignoreID=false) const
Definition: relation.cpp:90
virtual ~Relation()
Definition: relation.h:67
Represent any entity that can be stored within the OPC.
Definition: entity.h:40
int ID() const
Get the opc ID of the relation.
Definition: relation.cpp:206
bool operator>(const Relation &b) const
Definition: relation.cpp:241
virtual std::string toString() const
Return string representation of this Relation.
Definition: relation.cpp:190
std::string m_object
Definition: relation.h:41
std::string subject() const
Get the name of the relation&#39;s subject.
Definition: relation.cpp:211
std::string complement_time() const
Get the complement of time of the relation.
Definition: relation.cpp:231
std::string m_complement_place
Definition: relation.h:42
std::string complement_place() const
Get the complement of place of the relation.
Definition: relation.cpp:226
An OPC client using the datastructures defined within the icub-client library.
Definition: opcClient.h:35
std::string object() const
Get the name of the relation&#39;s object.
Definition: relation.cpp:216
std::string m_complement_manner
Definition: relation.h:44
bool operator==(const Relation &b) const
Definition: relation.cpp:280
std::string verb() const
Get the type of the relation.
Definition: relation.cpp:221
std::string m_subject
Definition: relation.h:40
bool operator<(const Relation &b) const
Definition: relation.cpp:275
Represent a relation between two entities.
Definition: relation.h:31
yarp::os::Bottle asLightBottle() const
Return the relation as a bottle without the argument to "none".
Definition: relation.cpp:132
std::string m_complement_time
Definition: relation.h:43
std::string m_verb
Definition: relation.h:39