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
26#include <MemoryX/interface/core/EntityBase.h>
27#include <MemoryX/interface/memorytypes/MemoryEntities.h>
28
29namespace memoryx
30{
31
32 class Relation;
34
35 /**
36 * Relation class represents a directed relation between entities.
37 * It allows to specify the uncertainty of this relation as DoB probability.
38 *
39 */
40 class Relation : public memoryx::RelationBase, public memoryx::Entity
41 {
42 public:
43 /**
44 * Constucts a new Relation
45 *
46 * @param name name of the relation (and actually its type, i.e. "isOn")
47 * @param entities the list of entity refs between which this relation holds
48 * @param sign whether the relation is known to be true or false
49 * @param prob existence probability of relation
50 */
51 Relation(const std::string& name = "",
52 const EntityRefList& entities = EntityRefList{},
53 bool sign = true,
54 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,
69 const ::Ice::Current& = Ice::emptyCurrent) override;
70
71 /**
72 * Retrieve whether this relation is true or false
73 *
74 * @return the sign
75 */
76 bool getSign(const ::Ice::Current& = Ice::emptyCurrent) const override;
77
78 /**
79 * Set whether this relation is true or false
80 *
81 * @param sign the sign
82 */
83 void setSign(bool sign, const ::Ice::Current& = Ice::emptyCurrent) override;
84
85 /**
86 * Retrieve probability that this relation actually exists
87 *
88 * @return existence probability
89 */
90 ::Ice::Float getProb(const ::Ice::Current& = Ice::emptyCurrent) const override;
91
92 /**
93 * Set probability that this relation actually exists
94 *
95 * @prob existence probability
96 */
97 void setProb(::Ice::Float prob, const ::Ice::Current& = Ice::emptyCurrent) override;
98
99 std::string getAttributes() const;
100
101 void setAttributes(std::string const& attributes);
102
103 std::string getSourceAttributes() const;
104
105 void setSourceAttributes(std::string const& attributes);
106
107 std::string getTargetAttributes() const;
108
109 void setTargetAttributes(std::string const& attributes);
110
111 // cloning
112 Ice::ObjectPtr ice_clone() const override;
113 RelationPtr clone(const Ice::Current& c = Ice::emptyCurrent) const;
114
115 private:
116 void output(std::ostream& stream) const;
117
118 public: // streaming operator
119 friend std::ostream&
120 operator<<(std::ostream& stream, const Relation& rhs)
121 {
122 rhs.output(stream);
123 return stream;
124 }
125
126 friend std::ostream&
127 operator<<(std::ostream& stream, const RelationPtr& rhs)
128 {
129 rhs->output(stream);
130 return stream;
131 }
132
133 friend std::ostream&
134 operator<<(std::ostream& stream, const RelationBasePtr& rhs)
135 {
136 stream << RelationPtr::dynamicCast(rhs);
137 return stream;
138 }
139 };
140
141} // namespace memoryx
constexpr T c
Entity is the superclass for all MemoryX memory chunks.
Definition Entity.h:246
Relation class represents a directed relation between entities.
Definition Relation.h:41
friend std::ostream & operator<<(std::ostream &stream, const Relation &rhs)
Definition Relation.h:120
::Ice::Float getProb(const ::Ice::Current &=Ice::emptyCurrent) const override
Retrieve probability that this relation actually exists.
Definition Relation.cpp:94
void setSign(bool sign, const ::Ice::Current &=Ice::emptyCurrent) override
Set whether this relation is true or false.
Definition Relation.cpp:88
std::string getAttributes() const
Definition Relation.cpp:106
void setProb(::Ice::Float prob, const ::Ice::Current &=Ice::emptyCurrent) override
Set probability that this relation actually exists.
Definition Relation.cpp:100
std::string getSourceAttributes() const
Definition Relation.cpp:118
void setEntities(const EntityRefList &entities, const ::Ice::Current &=Ice::emptyCurrent) override
set the entities involved in this relation
Definition Relation.cpp:68
EntityRefList getEntities(const ::Ice::Current &=Ice::emptyCurrent) const override
Retrieve the entities involved in this relation.
Definition Relation.cpp:53
void setAttributes(std::string const &attributes)
Definition Relation.cpp:112
RelationPtr clone(const Ice::Current &c=Ice::emptyCurrent) const
Definition Relation.cpp:148
std::string getTargetAttributes() const
Definition Relation.cpp:130
Ice::ObjectPtr ice_clone() const override
Definition Relation.cpp:142
Relation(const std::string &name="", const EntityRefList &entities=EntityRefList{}, bool sign=true, float prob=1.f)
Constucts a new Relation.
Definition Relation.cpp:30
void setTargetAttributes(std::string const &attributes)
Definition Relation.cpp:136
void setSourceAttributes(std::string const &attributes)
Definition Relation.cpp:124
bool getSign(const ::Ice::Current &=Ice::emptyCurrent) const override
Retrieve whether this relation is true or false.
Definition Relation.cpp:82
VirtualRobot headers.
IceInternal::Handle< Relation > RelationPtr
Definition Relation.h:33