56 template < GUM_Numeric GUM_SCALAR >
62 template < GUM_Numeric GUM_SCALAR >
65 bool delayInheritance) :
71 template < GUM_Numeric GUM_SCALAR >
79 template < GUM_Numeric GUM_SCALAR >
88 template < GUM_Numeric GUM_SCALAR >
93 template < GUM_Numeric GUM_SCALAR >
98 attr->setId(i_attr->id());
106 _nameMap_.insert(attr->safeName(), attr);
107 _dag_.addNodeWithId(attr->id());
117 ref->setId(i_ref->id());
124 _dag_.addNodeWithId(ref->id());
128 template < GUM_Numeric GUM_SCALAR >
132 "name '" << elt->
name() <<
"' is already used by another ClassElement");
141 _dag_.addNodeWithId(attr->
id());
154 _dag_.addNodeWithId(elt->
id());
166 template < GUM_Numeric GUM_SCALAR >
175 if (overloaded == overloader)
199 "Element " << overloader->
name() <<
" can not be overloaded")
204 return overloader->
id();
207 template < GUM_Numeric GUM_SCALAR >
210 if (overloader->
type() != overloaded->
type()) {
212 _dag_.addNodeWithId(overloader->
id());
219 overloader->
setId(overloaded->
id());
233 template < GUM_Numeric GUM_SCALAR >
238 overloader->
setId(overloaded->
id());
249 template < GUM_Numeric GUM_SCALAR >
258 _dag_.addNodeWithId(child->
id());
271 template < GUM_Numeric GUM_SCALAR >
282 if (!ref_overloader->slotType().isSubTypeOf(ref_overloaded->
slotType())) {
return false; }
289 template < GUM_Numeric GUM_SCALAR >
300 while (current != 0) {
301 if (current == &(cec))
return true;
315 template < GUM_Numeric GUM_SCALAR >
329 template < GUM_Numeric GUM_SCALAR >
334 template < GUM_Numeric GUM_SCALAR >
339 template < GUM_Numeric GUM_SCALAR >
345 template < GUM_Numeric GUM_SCALAR >
351 template < GUM_Numeric GUM_SCALAR >
356 template < GUM_Numeric GUM_SCALAR >
362 template < GUM_Numeric GUM_SCALAR >
368 template < GUM_Numeric GUM_SCALAR >
373 template < GUM_Numeric GUM_SCALAR >
378 template < GUM_Numeric GUM_SCALAR >
383 template < GUM_Numeric GUM_SCALAR >
388 template < GUM_Numeric GUM_SCALAR >
393 template < GUM_Numeric GUM_SCALAR >
399 template < GUM_Numeric GUM_SCALAR >
404 template < GUM_Numeric GUM_SCALAR >
409 template < GUM_Numeric GUM_SCALAR >
414 template < GUM_Numeric GUM_SCALAR >
417 if (!p) {
GUM_ERROR(
NotFound,
"no ClassElement<GUM_SCALAR> with the given NodeId") }
421 template < GUM_Numeric GUM_SCALAR >
424 if (!p) {
GUM_ERROR(
NotFound,
"no ClassElement<GUM_SCALAR> with the given NodeId") }
428 template < GUM_Numeric GUM_SCALAR >
431 if (!p) {
GUM_ERROR(
NotFound,
"no ClassElement<GUM_SCALAR> with the given name") }
435 template < GUM_Numeric GUM_SCALAR >
439 if (!p) {
GUM_ERROR(
NotFound,
"no ClassElement<GUM_SCALAR> with the given name") }
443 template < GUM_Numeric GUM_SCALAR >
448 template < GUM_Numeric GUM_SCALAR >
454 template < GUM_Numeric GUM_SCALAR >
459 template < GUM_Numeric GUM_SCALAR >
464 template < GUM_Numeric GUM_SCALAR >
469 impl->findAllSubtypes_(set);
474 ext->findAllSubtypes_(set);
478 template < GUM_Numeric GUM_SCALAR >
483 if (i->isOutputNode(elt)) {
return true; }
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.
Exception: wrong PRMClassElement for this operation.
PRMAttribute is a member of a Class in a PRM.
virtual void overload(PRMAttribute< GUM_SCALAR > *source)
Set this as overload of source (necessayr to preserver internal pointers for MultiDims).
virtual void setAsCastDescendant(PRMAttribute< GUM_SCALAR > *attr)=0
Define attr as a cast descendant of this PRMAttribute.
PRMType & type() override=0
See gum::PRMClassElement::type().
PRMAttribute< GUM_SCALAR > * getCastDescendant() const override=0
Returns a proper cast descendant of this PRMAttribute.
PRMClassElementContainer(std::string_view name)
Default constructor.
virtual std::pair< bool, bool > & getIOFlag_(const PRMClassElement< GUM_SCALAR > &elt)
Returns the IO flags of a PRMClassElement<GUM_SCALAR>.
virtual bool exists(std::string_view 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.
static INLINE bool isReferenceSlot(const PRMClassElement< GUM_SCALAR > &elt)
Returns true if obj_ptr is of type PRMReferenceSlot.
virtual ClassElementType elt_type() const =0
Return the type of class element this object is.
virtual PRMType & type()=0
Return a reference over the gum::PRMType of this class element.
static INLINE bool isAttribute(const PRMClassElement< GUM_SCALAR > &elt)
Returns true if obj_ptr is of type PRMAttribute.
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.
const std::string & safeName() const
Returns the safe name of this PRMClassElement, if any.
typename NodeProperty< PRMClassElement< GUM_SCALAR > * >::const_iterator const_ClassEltIterator
void _addImplementation_(PRMClass< GUM_SCALAR > *c)
Add an Class<GUM_SCALAR> to the set of Class<GUM_SCALAR> which implements this PRMInterface.
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....
const Set< PRMAttribute< GUM_SCALAR > * > & attributes() const
Returns the set of PRMAttribute<GUM_SCALAR> of this Class<GUM_SCALAR>.
bool isOutputNode(const PRMClassElement< GUM_SCALAR > &elt) const override
See gum::prm::PRMClassElementContainer<GUM_SCALAR>::get(conststd::string&).
void _overloadReferenceSlot_(PRMReferenceSlot< GUM_SCALAR > *overloader, PRMReferenceSlot< GUM_SCALAR > *overloaded)
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this....
NodeId add(PRMClassElement< GUM_SCALAR > *elt) override
See gum::prm::PRMClassElementContainer<GUM_SCALAR>::add(PRMClassElement<GUM_SCALAR>*).
Set< PRMClass< GUM_SCALAR > * > & implementations()
Returns the set of Class<GUM_SCALAR> implementing this PRMInterface.
void addArc(std::string_view tail, std::string_view head) override
An Interfance doesn't have any arc, this will raise an OperationNotAllowed exception.
Set< PRMReferenceSlot< GUM_SCALAR > * > _referenceSlots_
The sequence of PRMReferenceSlot<GUM_SCALAR>.
PRMInterface< GUM_SCALAR > & super()
Returns the superInterface of this PRMInterface.
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...
const ClassEltIterator & end()
PRMClassElement< GUM_SCALAR > & operator[](NodeId id) override
See gum::prm::PRMClassElementContainer<GUM_SCALAR>::operator[](NodeId).
typename NodeProperty< PRMClassElement< GUM_SCALAR > * >::iterator ClassEltIterator
PRMClassElement< GUM_SCALAR > & get(NodeId id) override
See gum::prm::PRMClassElementContainer<GUM_SCALAR>::get(NodeId).
void _overloadAttribute_(PRMAttribute< GUM_SCALAR > *overloader, PRMAttribute< GUM_SCALAR > *overloaded)
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this....
NodeId overload(PRMClassElement< GUM_SCALAR > *elt) override
Add a new PRMClassElement<GUM_SCALAR> which overload an inherited PRMClassElement<GUM_SCALAR>.
PRMObject::prm_type obj_type() const override
Implementation of pure virtual method of PRMObject.
bool _checkOverloadLegality_(const PRMClassElement< GUM_SCALAR > *overloaded, const PRMClassElement< GUM_SCALAR > *overloader)
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this....
const DAG & dag_() const override
Returns a constant reference over this PRMInterface's DAG.
~PRMInterface() override
Destructor.
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) override
See gum::prm::PRMClassElementContainer<GUM_SCALAR>(constPRMClassElement<GUM_SCALAR>&).
PRMInterface(std::string_view name)
Default constructor.
void _addExtension_(PRMInterface< GUM_SCALAR > *c)
Add an Class<GUM_SCALAR> to 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>.
friend class PRMClass< GUM_SCALAR >
Set< PRMClass< GUM_SCALAR > * > _implementations_
The set of Class<GUM_SCALAR> which implements this PRMInterface.
DAG _dag_
The dag representing dependencies between formal attributes and slots.
bool isSubTypeOf(const PRMClassElementContainer< GUM_SCALAR > &cec) const override
Test if this PRMInterface is a sub PRMInterface of cec.
Set< PRMInterface< GUM_SCALAR > * > _extensions_
The set of Class<GUM_SCALAR> which implements this PRMInterface.
void findAllSubtypes_(Set< PRMClassElementContainer< GUM_SCALAR > * > &set) override
Fills set with all the subtypes of this PRMInterface, this includes extensions and implementations.
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