31 string complement_place,
32 string complement_time,
33 string complement_manner)
39 m_complement_place = complement_place;
40 m_complement_time = complement_time;
41 m_complement_manner = complement_manner;
55 m_subject = subject->
name();
60 m_verb = verb->
name();
65 m_object =
object->name();
70 m_complement_place = complement_place->
name();
72 m_complement_place =
"none";
75 m_complement_time = complement_time->
name();
77 m_complement_time =
"none";
79 if (complement_manner)
80 m_complement_manner = complement_manner->
name();
82 m_complement_manner =
"none";
85 Relation::Relation(yarp::os::Bottle &b)
90 Bottle Relation::asBottle(
bool ignoreID)
const 94 bSub.addString(
"entity");
101 bSub.addString(
"id");
102 bSub.addInt(m_opcId);
106 bSub.addString(
"rSubject");
107 bSub.addString(m_subject.c_str());
110 bSub.addString(
"rVerb");
111 bSub.addString(m_verb.c_str());
114 bSub.addString(
"rObject");
115 bSub.addString(m_object.c_str());
118 bSub.addString(
"rCompPlace");
119 bSub.addString(m_complement_place.c_str());
122 bSub.addString(
"rCompTime");
123 bSub.addString(m_complement_time.c_str());
126 bSub.addString(
"rCompManner");
127 bSub.addString(m_complement_manner.c_str());
132 Bottle Relation::asLightBottle()
const 136 bSub.addString(
"entity");
141 bSub.addString(
"rSubject");
142 bSub.addString(m_subject.c_str());
145 bSub.addString(
"rVerb");
146 bSub.addString(m_verb.c_str());
149 bSub.addString(
"rObject");
150 bSub.addString(m_object.c_str());
152 if (m_complement_place !=
"none")
155 bSub.addString(
"rCompPlace");
156 bSub.addString(m_complement_place.c_str());
159 if (m_complement_time !=
"none")
162 bSub.addString(
"rCompTime");
163 bSub.addString(m_complement_time.c_str());
166 if (m_complement_manner !=
"none")
169 bSub.addString(
"rCompManner");
170 bSub.addString(m_complement_manner.c_str());
179 void Relation::fromBottle(
const Bottle &b)
181 m_opcId = b.find(
"id").asInt();
182 m_subject = b.find(
"rSubject").toString().c_str();
183 m_verb = b.find(
"rVerb").asString().c_str();
184 m_object = b.find(
"rObject").asString().c_str();
185 m_complement_place = b.find(
"rCompPlace").asString().c_str();
186 m_complement_time = b.find(
"rCompTime").asString().c_str();
187 m_complement_manner = b.find(
"rCompManner").asString().c_str();
190 string Relation::toString()
const 192 std::ostringstream oss;
193 oss<< subject() <<
" " <<verb()<<
" ";
194 if (
object() !=
"none")
196 if (complement_place() !=
"none")
197 oss<<complement_place()<<
" ";
198 if (complement_time() !=
"none")
199 oss<<complement_time()<<
" ";
200 if (complement_manner() !=
"none")
201 oss<<complement_manner()<<
" ";
206 int Relation::ID()
const 211 string Relation::subject()
const 216 string Relation::object()
const 221 string Relation::verb()
const 226 string Relation::complement_place()
const 228 return m_complement_place;
231 string Relation::complement_time()
const 233 return m_complement_time;
236 string Relation::complement_manner()
const 238 return m_complement_manner;
247 else if (this->m_opcId != b.m_opcId)
249 return (this->m_opcId > b.m_opcId);
251 else if (this->m_verb != b.
m_verb)
253 return (this->m_verb > b.
m_verb);
255 else if (this->m_object != b.
m_object)
257 return (this->m_object > b.
m_object);
277 return (!(this->
operator>(b))&&!(this->
operator==(b)));
283 this->m_opcId == b.m_opcId &&
285 this->m_verb == b.
m_verb &&
Represent any entity that can be stored within the OPC.
std::string m_complement_place
std::string m_complement_manner
std::string name() const
Return the name of an entity (which has to be unique within the OPC)
Represent a relation between two entities.
std::string m_complement_time