aGrUM  0.16.0
PRMObject.h
Go to the documentation of this file.
1 
30 #ifndef GUM_PRM_OBJECT_H
31 #define GUM_PRM_OBJECT_H
32 
33 #include <string>
34 
35 #include <agrum/agrum.h>
36 
37 namespace gum {
38 
39  namespace prm {
56  class PRMObject {
57  public:
58  // ==========================================================================
60  // ==========================================================================
62 
69  enum class prm_type : char {
70  ALL,
71  CLASS,
73  CLASS_ELT,
74  TYPE,
75  SYSTEM,
76  INSTANCE
77  };
78 
79  static std::string LEFT_CAST() { return "("; }
80  static std::string RIGHT_CAST() { return ")"; }
81 
83  static std::string enum2str(prm_type type) {
84  switch (type) {
85  case prm_type::CLASS: return "PRMType::CLASS";
86 
87  case prm_type::CLASS_ELT: return "PRMType::CLASS_ELT";
88 
89  case prm_type::TYPE: return "PRMType::TYPE";
90 
91  case prm_type::SYSTEM: return "PRMType::SYSTEM";
92 
93  case prm_type::INSTANCE: return "PRMType::INSTANCE";
94 
95  case prm_type::PRM_INTERFACE: return "PRMType::PRM_INTERFACE";
96 
97  default: return "unknown";
98  }
99  }
100 
102  static INLINE bool isClass(const PRMObject& obj) {
103  return obj.obj_type() == prm_type::CLASS;
104  }
105 
107  static INLINE bool isInterface(const PRMObject& obj) {
108  return obj.obj_type() == prm_type::PRM_INTERFACE;
109  }
110 
112  static INLINE bool isInstance(const PRMObject& obj) {
113  return obj.obj_type() == prm_type::INSTANCE;
114  }
115 
117  // ==========================================================================
119  // ==========================================================================
121 
126  explicit PRMObject(const std::string& name);
127 
131  PRMObject(const PRMObject& source);
132 
136  PRMObject(PRMObject&& source);
137 
141  virtual ~PRMObject();
142 
144  // ==========================================================================
146  // ==========================================================================
148 
152  const std::string& name() const;
153 
158  void name(const std::string& name);
159 
163  virtual prm_type obj_type() const = 0;
164 
166  // ==========================================================================
168  // ==========================================================================
170 
174  bool operator==(const PRMObject& obj) const;
175 
179  bool operator!=(const PRMObject& obj) const;
180 
184  PRMObject& operator=(const PRMObject& source);
185 
189  PRMObject& operator=(PRMObject&& source);
190 
192  private:
193  // ==========================================================================
195  // ==========================================================================
197 
198  // The name of this object
199  // ======================================================================
200  std::string __name;
201 
203  };
204 
206  std::ostream& operator<<(std::ostream& out, PRMObject::prm_type obj_type);
207 
208  // list of declarations of PRMObjects
209  class PRMType;
210  template < typename GUM_SCALAR >
211  class PRMClassElement;
212  template < typename GUM_SCALAR >
214  template < typename GUM_SCALAR >
215  class PRMAggregate;
216  template < typename GUM_SCALAR >
217  class PRMInterface;
218  template < typename GUM_SCALAR >
219  class PRMAttribute;
220  template < typename GUM_SCALAR >
222  template < typename GUM_SCALAR >
224  template < typename GUM_SCALAR >
225  class PRMClass;
226  template < typename GUM_SCALAR >
227  class PRMInstance;
228  template < typename GUM_SCALAR >
229  class PRMSystem;
230 
231  } /* namespace prm */
232 } /* namespace gum */
233 
234 #ifndef GUM_NO_INLINE
236 #endif // GUM_NO_INLINE
237 
238 #endif /* GUM_PRM_OBJECT_H */
PRMObject & operator=(const PRMObject &source)
Copy operator.
Definition: PRMObject.cpp:64
std::ostream & operator<<(std::ostream &out, PRMObject::prm_type obj_type)
For printing PRMType easily.
Definition: PRMObject.cpp:78
static INLINE bool isInterface(const PRMObject &obj)
Returns true if obj_ptr is of type PRMInterface.
Definition: PRMObject.h:107
bool operator!=(const PRMObject &obj) const
To PRMObject are equal if they have the same name (which is unique).
Definition: PRMObject_inl.h:49
static INLINE bool isClass(const PRMObject &obj)
Returns true if obj_ptr is of type Class.
Definition: PRMObject.h:102
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
An PRMInstance is a Bayesian Network fragment defined by a Class and used in a PRMSystem.
Definition: PRMInstance.h:63
static std::string enum2str(prm_type type)
Returns the string representation of a PRMObject.
Definition: PRMObject.h:83
virtual prm_type obj_type() const =0
Returns the type of this object.
virtual ~PRMObject()
Destructor.
Definition: PRMObject.cpp:61
Abstract class representing an element of PRM class.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
bool operator==(const PRMObject &obj) const
To PRMObject are equal if they have the same name (which is unique).
Definition: PRMObject_inl.h:43
A PRMReferenceSlot represent a relation between two PRMClassElementContainer.
Definition: PRMObject.h:223
prm_type
Enumeration of the different types of objects handled by a PRM.
Definition: PRMObject.h:69
A PRMSystem is a container of PRMInstance and describe a relational skeleton.
Definition: PRMObject.h:229
This is a decoration of the DiscreteVariable class.
Definition: PRMType.h:63
An PRMInterface is implemented by a Class<GUM_SCALAR> and defines a set of PRMReferenceSlot<GUM_SCALA...
Definition: PRMClass.h:54
A PRMSlotChain represents a sequence of gum::prm::PRMClassElement<GUM_SCALAR> where the n-1 first gum...
Definition: PRMObject.h:221
Abstract base class for any element defined in a PRM.
Definition: PRMObject.h:56
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
static std::string LEFT_CAST()
Enumeration of the different types of objects handled by a PRM.
Definition: PRMObject.h:79
std::string __name
Definition: PRMObject.h:200
<agrum/PRM/classElementContainer.h>
A PRMClass is an object of a PRM representing a fragment of a Bayesian Network which can be instantia...
Definition: PRMClass.h:66
PRMAttribute is a member of a Class in a PRM.
Definition: PRMAttribute.h:61
PRMObject(const std::string &name)
Constructor.
Definition: PRMObject.cpp:43
static std::string RIGHT_CAST()
Enumeration of the different types of objects handled by a PRM.
Definition: PRMObject.h:80
static INLINE bool isInstance(const PRMObject &obj)
Returns true if obj_ptr is of type PRMInstance.
Definition: PRMObject.h:112