55 template <
typename GUM_SCALAR >
61 template <
typename GUM_SCALAR >
64 bool delayInheritance) :
70 template <
typename GUM_SCALAR >
78 template <
typename GUM_SCALAR >
87 template <
typename GUM_SCALAR >
92 template <
typename GUM_SCALAR >
97 attr->setId(i_attr->id());
105 _nameMap_.insert(attr->safeName(), attr);
106 _dag_.addNodeWithId(attr->id());
116 ref->setId(i_ref->id());
122 _nameMap_.insert(ref->safeName(), ref);
127 template <
typename GUM_SCALAR >
131 "name '" << elt->
name() <<
"' is already used by another ClassElement");
140 _dag_.addNodeWithId(attr->
id());
153 _dag_.addNodeWithId(elt->
id());
154 _nodeIdMap_.insert(elt->
id(), elt);
156 _nameMap_.insert(elt->
name(), elt);
157 _nameMap_.insert(elt->
safeName(), elt);
159 GUM_ERROR(WrongClassElement,
"illegal ClassElement<GUM_SCALAR> for an Interface")
165 template <
typename GUM_SCALAR >
175 PRMClassElement< GUM_SCALAR >* overloaded = _nameMap_[overloader->name()];
176 if (overloaded == overloader)
179 if (!_checkOverloadLegality_(overloaded, overloader))
182 switch (overloader->elt_type()) {
184 auto attr_overloader =
static_cast< PRMAttribute< GUM_SCALAR >*
>(overloader);
185 auto attr_overloaded =
static_cast< PRMAttribute< GUM_SCALAR >*
>(overloaded);
186 _overloadAttribute_(attr_overloader, attr_overloaded);
191 auto ref_overloader =
static_cast< PRMReferenceSlot< GUM_SCALAR >*
>(overloader);
192 auto ref_overloaded =
static_cast< PRMReferenceSlot< GUM_SCALAR >*
>(overloaded);
193 _overloadReferenceSlot_(ref_overloader, ref_overloaded);
200 "Element " << overloader->name() <<
" can not be overloaded")
205 return overloader->
id();
208 template < typename GUM_SCALAR >
211 if (overloader->type() != overloaded->type()) {
212 overloader->setId(nextNodeId());
213 _dag_.addNodeWithId(overloader->id());
214 _nodeIdMap_.insert(overloader->id(), overloader);
215 _nameMap_[overloader->name()] = overloader;
216 _nameMap_.insert(overloader->safeName(), overloader);
217 _attributes_.insert(overloader);
218 _addCastDescendants_(overloader, overloaded);
220 overloader->setId(overloaded->id());
221 _nodeIdMap_[overloader->id()] = overloader;
222 _nameMap_[overloader->name()] = overloader;
223 _nameMap_[overloader->safeName()] = overloader;
224 _attributes_.erase(overloaded);
225 _attributes_.insert(overloader);
229 overloader->overload(overloaded);
234 template <
typename GUM_SCALAR >
239 overloader->
setId(overloaded->
id());
250 template <
typename GUM_SCALAR >
259 _dag_.addNodeWithId(child->
id());
272 template <
typename GUM_SCALAR >
283 if (!ref_overloader->slotType().isSubTypeOf(ref_overloaded->
slotType())) {
return false; }
290 template <
typename GUM_SCALAR >
301 while (current != 0) {
302 if (current == &(cec))
return true;
316 template <
typename GUM_SCALAR >
330 template <
typename GUM_SCALAR >
336 template <
typename GUM_SCALAR >
342 template <
typename GUM_SCALAR >
348 template <
typename GUM_SCALAR >
354 template <
typename GUM_SCALAR >
356 const std::string& head) {
360 template <
typename GUM_SCALAR >
366 template <
typename GUM_SCALAR >
372 template <
typename GUM_SCALAR >
377 template <
typename GUM_SCALAR >
382 template <
typename GUM_SCALAR >
387 template <
typename GUM_SCALAR >
393 template <
typename GUM_SCALAR >
399 template <
typename GUM_SCALAR >
405 template <
typename GUM_SCALAR >
410 template <
typename GUM_SCALAR >
415 template <
typename GUM_SCALAR >
420 template <
typename GUM_SCALAR >
429 template <
typename GUM_SCALAR >
438 template <
typename GUM_SCALAR >
447 template <
typename GUM_SCALAR >
457 template <
typename GUM_SCALAR >
463 template <
typename GUM_SCALAR >
469 template <
typename GUM_SCALAR >
474 template <
typename GUM_SCALAR >
480 template <
typename GUM_SCALAR >
485 impl->findAllSubtypes_(set);
490 ext->findAllSubtypes_(set);
494 template <
typename GUM_SCALAR >
Headers of gum::prm::Class<GUM_SCALAR>.
Headers of gum::prm::PRMInterface.
Exception : a similar element already exists.
Exception : fatal (unknown ?) error.
Exception : the element we looked for cannot be found.
Exception : operation not allowed.
PRMAttribute is a member of a Class in a PRM.
virtual void setAsCastDescendant(PRMAttribute< GUM_SCALAR > *attr)=0
Define attr as a cast descendant of this PRMAttribute.
virtual PRMAttribute< GUM_SCALAR > * getCastDescendant() const =0
Returns a proper cast descendant of this PRMAttribute.
virtual PRMType & type()=0
See gum::PRMClassElement::type().
virtual std::pair< bool, bool > & getIOFlag_(const PRMClassElement< GUM_SCALAR > &elt)
Returns the IO flags of a PRMClassElement<GUM_SCALAR>.
PRMClassElementContainer(const std::string &name)
Default constructor.
virtual bool exists(const std::string &name) const
Returns true if a member with the given name exists in this PRMClassElementContainer or in the PRMCla...
Abstract class representing an element of PRM class.
virtual void setId(NodeId id)
Used to assign the id of this element.
NodeId id() const
Returns the NodeId of this element in it's class DAG.
virtual ClassElementType elt_type() const =0
Return the type of class element this object is.
static INLINE bool isReferenceSlot(const PRMClassElement< GUM_SCALAR > &elt)
Returns true if obj_ptr is of type PRMReferenceSlot.
virtual PRMType & type()=0
Return a reference over the gum::PRMType of this class element.
const std::string & safeName() const
Returns the safe name of this PRMClassElement, if any.
static INLINE bool isAttribute(const PRMClassElement< GUM_SCALAR > &elt)
Returns true if obj_ptr is of type PRMAttribute.
void findAllSubtypes_(Set< PRMClassElementContainer< GUM_SCALAR > * > &set)
Fills set with all the subtypes of this PRMInterface, this includes extensions and implementations.
typename NodeProperty< PRMClassElement< GUM_SCALAR > * >::const_iterator const_ClassEltIterator
PRMInterface(const std::string &name)
Default constructor.
Set< PRMAttribute< GUM_SCALAR > * > _attributes_
The sequence of PRMAttribute<GUM_SCALAR>s.
HashTable< std::string, PRMClassElement< GUM_SCALAR > * > _nameMap_
Mapping between a member's name and itself. Used for fast access to a member given it's name.
void _inheritInterface_(const PRMInterface< GUM_SCALAR > &i)
Proceed with the copy of i in this.
PRMInterface< GUM_SCALAR > * _superInterface_
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this....
void _overloadReferenceSlot_(PRMReferenceSlot< GUM_SCALAR > *overloader, PRMReferenceSlot< GUM_SCALAR > *overloaded)
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this....
virtual bool isSubTypeOf(const PRMClassElementContainer< GUM_SCALAR > &cec) const
Test if this PRMInterface is a sub PRMInterface of cec.
virtual PRMClassElement< double > & get(NodeId id)
void _addImplementation_(PRMClass< GUM_SCALAR > *c)
Add an Class<GUM_SCALAR> to the set of Class<GUM_SCALAR> which implements this PRMInterface.
void _addExtension_(PRMInterface< GUM_SCALAR > *c)
Add an Class<GUM_SCALAR> to the set of Class<GUM_SCALAR> which implements this PRMInterface.
virtual ~PRMInterface()
Destructor.
Set< PRMReferenceSlot< GUM_SCALAR > * > _referenceSlots_
The sequence of PRMReferenceSlot<GUM_SCALAR>.
virtual PRMObject::prm_type obj_type() const
Implementation of pure virtual method of PRMObject.
void inheritInterface()
Inherits from this interface super interface, this should only be done when this inteface inheritance...
NodeProperty< PRMClassElement< GUM_SCALAR > * > _nodeIdMap_
Mapping between node's id and their name (being an attribute or a slot). Used for fast access to a me...
typename NodeProperty< PRMClassElement< GUM_SCALAR > * >::iterator ClassEltIterator
void _overloadAttribute_(PRMAttribute< GUM_SCALAR > *overloader, PRMAttribute< GUM_SCALAR > *overloaded)
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this....
bool _checkOverloadLegality_(const PRMClassElement< GUM_SCALAR > *overloaded, const PRMClassElement< GUM_SCALAR > *overloader)
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this....
PRMClassElement< GUM_SCALAR > & operator[](NodeId id)
See gum::prm::PRMClassElementContainer<GUM_SCALAR>::operator[](NodeId).
const Set< PRMAttribute< GUM_SCALAR > * > & attributes() const
Returns the set of PRMAttribute<GUM_SCALAR> of this Class<GUM_SCALAR>.
void _addCastDescendants_(PRMAttribute< GUM_SCALAR > *start, PRMAttribute< GUM_SCALAR > *end)
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this....
void updateDescendants_(const PRMClassElement< GUM_SCALAR > &elt)
See gum::prm::PRMClassElementContainer<GUM_SCALAR>(constPRMClassElement<GUM_SCALAR>&).
const DAG & dag_() const
Returns a constant reference over this PRMInterface's DAG.
const ClassEltIterator & end()
virtual bool isOutputNode(const PRMClassElement< GUM_SCALAR > &elt) const
See gum::prm::PRMClassElementContainer<GUM_SCALAR>::get(conststd::string&).
friend class PRMClass< GUM_SCALAR >
void addArc(const std::string &tail, const std::string &head)
An Interfance doesn't have any arc, this will raise an OperationNotAllowed exception.
Set< PRMClass< GUM_SCALAR > * > _implementations_
The set of Class<GUM_SCALAR> which implements this PRMInterface.
const Set< PRMReferenceSlot< GUM_SCALAR > * > & referenceSlots() const
Returns the set of PRMAggregate of this Class<GUM_SCALAR>.
DAG _dag_
The dag representing dependencies between formal attributes and slots.
PRMInterface< GUM_SCALAR > & super()
Returns the superInterface of this PRMInterface.
NodeId add(PRMClassElement< GUM_SCALAR > *elt)
See gum::prm::PRMClassElementContainer<GUM_SCALAR>::add(PRMClassElement<GUM_SCALAR>*).
Set< PRMInterface< GUM_SCALAR > * > _extensions_
The set of Class<GUM_SCALAR> which implements this PRMInterface.
NodeId overload(PRMClassElement< GUM_SCALAR > *elt)
Add a new PRMClassElement<GUM_SCALAR> which overload an inherited PRMClassElement<GUM_SCALAR>.
Set< PRMClass< GUM_SCALAR > * > & implementations()
Returns the set of Class<GUM_SCALAR> implementing this PRMInterface.
const std::string & name() const
Returns the name of this object.
prm_type
Enumeration of the different types of objects handled by a PRM.
virtual prm_type obj_type() const =0
Returns the type of this object.
A PRMReferenceSlot represent a relation between two PRMClassElementContainer.
PRMClassElementContainer< GUM_SCALAR > & slotType()
Returns the type of this slot, which is a PRMClassElementContainer (it is not the type of PRMObject).
<agrum/PRM/elements/scalarAttribute.h>
PRMType & superType()
Returns the super type of this type.
bool isSubTypeOf(const PRMType &super) const
Returns true if this is a subtype of super.
bool isSubType() const
Returns true if this type is a sub-type.
#define GUM_ERROR(type, msg)
Size NodeId
Type for node ids.
namespace for all probabilistic relational models entities
NodeId nextNodeId()
Returns the next value of an unique counter for PRM's node id.
gum is the global namespace for all aGrUM entities