Relation.h
Go to the documentation of this file.
1 /*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package MemoryX::Core
17 * @author Alexey Kozlov ( kozlov at kit dot edu)
18 * @date 2012
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22 
23 #pragma once
24 
25 #include <MemoryX/interface/core/EntityBase.h>
26 #include <MemoryX/interface/memorytypes/MemoryEntities.h>
27 
29 
30 
31 namespace memoryx
32 {
33 
34  class Relation;
36 
37  /**
38  * Relation class represents a directed relation between entities.
39  * It allows to specify the uncertainty of this relation as DoB probability.
40  *
41  */
42  class Relation: public memoryx::RelationBase,
43  public memoryx::Entity
44  {
45  public:
46  /**
47  * Constucts a new Relation
48  *
49  * @param name name of the relation (and actually its type, i.e. "isOn")
50  * @param entities the list of entity refs between which this relation holds
51  * @param sign whether the relation is known to be true or false
52  * @param prob existence probability of relation
53  */
54  Relation(const std::string& name = "", const EntityRefList& entities = EntityRefList {}, bool sign = true, float prob = 1.f);
55 
56  /**
57  * Retrieve the entities involved in this relation
58  *
59  * @return list of entity refs
60  */
61  EntityRefList getEntities(const ::Ice::Current& = Ice::emptyCurrent) const override;
62 
63  /**
64  * set the entities involved in this relation
65  *
66  * @param entities list of entity refs
67  */
68  void setEntities(const EntityRefList& entities, const ::Ice::Current& = Ice::emptyCurrent) override;
69 
70  /**
71  * Retrieve whether this relation is true or false
72  *
73  * @return the sign
74  */
75  bool getSign(const ::Ice::Current& = Ice::emptyCurrent) const override;
76 
77  /**
78  * Set whether this relation is true or false
79  *
80  * @param sign the sign
81  */
82  void setSign(bool sign, const ::Ice::Current& = Ice::emptyCurrent) override;
83 
84  /**
85  * Retrieve probability that this relation actually exists
86  *
87  * @return existence probability
88  */
89  ::Ice::Float getProb(const ::Ice::Current& = Ice::emptyCurrent) const override;
90 
91  /**
92  * Set probability that this relation actually exists
93  *
94  * @prob existence probability
95  */
96  void setProb(::Ice::Float prob, const ::Ice::Current& = Ice::emptyCurrent) override;
97 
98  std::string getAttributes() const;
99 
100  void setAttributes(std::string const& attributes);
101 
102  std::string getSourceAttributes() const;
103 
104  void setSourceAttributes(std::string const& attributes);
105 
106  std::string getTargetAttributes() const;
107 
108  void setTargetAttributes(std::string const& attributes);
109 
110  // cloning
111  Ice::ObjectPtr ice_clone() const override;
112  RelationPtr clone(const Ice::Current& c = Ice::emptyCurrent) const;
113 
114  private:
115  void output(std::ostream& stream) const;
116 
117  public: // streaming operator
118  friend std::ostream& operator<<(std::ostream& stream, const Relation& rhs)
119  {
120  rhs.output(stream);
121  return stream;
122  }
123 
124  friend std::ostream& operator<<(std::ostream& stream, const RelationPtr& rhs)
125  {
126  rhs->output(stream);
127  return stream;
128  }
129 
130  friend std::ostream& operator<<(std::ostream& stream, const RelationBasePtr& rhs)
131  {
132  stream << RelationPtr::dynamicCast(rhs);
133  return stream;
134  }
135  };
136 
137 }
138 
armarx::VariantType::Float
const VariantTypeId Float
Definition: Variant.h:918
memoryx::Relation::getSourceAttributes
std::string getSourceAttributes() const
Definition: Relation.cpp:104
memoryx::Relation::clone
RelationPtr clone(const Ice::Current &c=Ice::emptyCurrent) const
Definition: Relation.cpp:130
memoryx::Relation::setAttributes
void setAttributes(std::string const &attributes)
Definition: Relation.cpp:99
memoryx::Relation::getProb
::Ice::Float getProb(const ::Ice::Current &=Ice::emptyCurrent) const override
Retrieve probability that this relation actually exists.
Definition: Relation.cpp:84
armarx::sign
T sign(T t)
Definition: algorithm.h:194
memoryx::Relation
Relation class represents a directed relation between entities.
Definition: Relation.h:42
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
memoryx::Relation::getAttributes
std::string getAttributes() const
Definition: Relation.cpp:94
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
memoryx::Relation::setSourceAttributes
void setSourceAttributes(std::string const &attributes)
Definition: Relation.cpp:109
memoryx::Relation::operator<<
friend std::ostream & operator<<(std::ostream &stream, const Relation &rhs)
Definition: Relation.h:118
IceInternal::Handle
Definition: forward_declarations.h:8
memoryx::Relation::Relation
Relation(const std::string &name="", const EntityRefList &entities=EntityRefList {}, bool sign=true, float prob=1.f)
Constucts a new Relation.
Definition: Relation.cpp:30
memoryx::Relation::setEntities
void setEntities(const EntityRefList &entities, const ::Ice::Current &=Ice::emptyCurrent) override
set the entities involved in this relation
Definition: Relation.cpp:61
memoryx::Relation::getTargetAttributes
std::string getTargetAttributes() const
Definition: Relation.cpp:114
memoryx::Relation::operator<<
friend std::ostream & operator<<(std::ostream &stream, const RelationBasePtr &rhs)
Definition: Relation.h:130
memoryx::Relation::ice_clone
Ice::ObjectPtr ice_clone() const override
Definition: Relation.cpp:125
memoryx::Relation::operator<<
friend std::ostream & operator<<(std::ostream &stream, const RelationPtr &rhs)
Definition: Relation.h:124
Entity.h
memoryx::Relation::setSign
void setSign(bool sign, const ::Ice::Current &=Ice::emptyCurrent) override
Set whether this relation is true or false.
Definition: Relation.cpp:79
memoryx::Relation::getSign
bool getSign(const ::Ice::Current &=Ice::emptyCurrent) const override
Retrieve whether this relation is true or false.
Definition: Relation.cpp:74
armarx::aron::type::ObjectPtr
std::shared_ptr< Object > ObjectPtr
Definition: Object.h:36
memoryx::Relation::getEntities
EntityRefList getEntities(const ::Ice::Current &=Ice::emptyCurrent) const override
Retrieve the entities involved in this relation.
Definition: Relation.cpp:48
memoryx::Entity
Definition: Entity.h:246
memoryx::Relation::setTargetAttributes
void setTargetAttributes(std::string const &attributes)
Definition: Relation.cpp:119
memoryx::Relation::setProb
void setProb(::Ice::Float prob, const ::Ice::Current &=Ice::emptyCurrent) override
Set probability that this relation actually exists.
Definition: Relation.cpp:89