29 #ifndef GUM_INSTANCE_H 30 #define GUM_INSTANCE_H 35 #include <agrum/tools/core/bijection.h> 37 #include <agrum/PRM/elements/PRMClass.h> 38 #include <agrum/PRM/elements/PRMClassElementContainer.h> 61 template <
typename GUM_SCALAR >
82 PRMInstance< GUM_SCALAR >(
const std::string& name, PRMClass< GUM_SCALAR >& type);
85 virtual ~PRMInstance< GUM_SCALAR >();
112 bool exists(NodeId id)
const;
118 bool exists(
const std::string& name)
const;
341 explicit RefIterator(Set< PRMInstance< GUM_SCALAR >* >& set);
528 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 536 #include <agrum/PRM/elements/PRMInstance_tpl.h> const PRMInstance< GUM_SCALAR > & operator*() const
RefConstIterator begin(NodeId id) const
Returns an iterator at the beginning of the set of PRMInstance<GUM_SCALAR> associated to a given gum:...
const PRMInstance< GUM_SCALAR > & getInstance(NodeId id) const
Fast access to the first instance in a PRMReferenceSlot or PRMSlotChain<GUM_SCALAR>.
RefConstIterator(const Set< PRMInstance< GUM_SCALAR > * > &set)
const InvRefConstIterator & endInvRef() const
Alias to iterate over the gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.
void add(NodeId id, PRMInstance< GUM_SCALAR > &instance)
Add an PRMInstance<GUM_SCALAR> to a given PRMReferenceSlot, PRMSlotChain<GUM_SCALAR> or output node...
PRMAttribute< GUM_SCALAR > & get(NodeId id)
Getter on an PRMAttribute<GUM_SCALAR> of this PRMInstance<GUM_SCALAR>.
void _doInstantiate_()
Starts this instance instantiations.
const_iterator begin() const
Returns an iterator at the beginning of the list of gum::prm::PRMAttribute<GUM_SCALAR> in this PRMIns...
INLINE void emplace(Args &&... args)
void instantiate()
Instantiate all nodes which requires it.
bool operator==(const RefIterator &from) const
const PRMClass< GUM_SCALAR > & type() const
Returns the type of this instance.
PRMClass< GUM_SCALAR > & type()
Returns the type of this instance.
std::pair< PRMInstance< GUM_SCALAR > *, std::string > pair
Code alias.
PRMInstance< GUM_SCALAR > * operator->() const
PRMClass< GUM_SCALAR > * _type_
The type of this PRMInstance<GUM_SCALAR>.
bool exists(NodeId id) const
Returns true if id matches an PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.
const const_iterator & end() const
Returns a reference over the iterator at the end of the list of gum::prm::PRMAttribute<GUM_SCALAR> in...
bool _instantiated_
True if this instance has been instantiated.
RefIterator & operator++()
void _copyAttributeCPF_(PRMAttribute< GUM_SCALAR > *attr)
Copy the content of an PRMAttribute<GUM_SCALAR> from its Class<GUM_SCALAR> counterpart.
void _instantiateSlotChain_(PRMSlotChain< GUM_SCALAR > *sc)
Retrieve all instances referred by sc.
PRMInstance(const PRMInstance< GUM_SCALAR > &source)
Copy constructor.
const PRMAttribute< GUM_SCALAR > & get(NodeId id) const
Getter on an PRMAttribute<GUM_SCALAR> of this PRMInstance<GUM_SCALAR>.
Size size() const
Returns the number of attributes in this PRMInstance<GUM_SCALAR>.
RefIterator(Set< PRMInstance< GUM_SCALAR > * > &set)
InvRefIterator beginInvRef()
Alias to iterate over the gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.
std::vector< std::pair< PRMInstance< GUM_SCALAR > *, std::string > > & getRefAttr(NodeId id)
Returns a vector of pairs of refering attributes of id.
PRMInstance< GUM_SCALAR > & operator*() const
RefConstIterator & operator++()
RefConstIterator(const RefConstIterator &from)
bool operator==(const RefConstIterator &from) const
bool exists(const std::string &name) const
Returns true if name matches an PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.
const Bijection< const DiscreteVariable *, const DiscreteVariable *> & bijection() const
Returns a mapping between DiscreteVariable used in this and the ones used in this PRMInstance<GUM_SCA...
PRMInstance< GUM_SCALAR > & operator=(const PRMClass< GUM_SCALAR > &from)
Copy operator. Don't use it.
InvRefConstIterator beginInvRef() const
Alias to iterate over the gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.
ParamScopeData(const std::string &s, const PRMReferenceSlot< GUM_SCALAR > &ref, Idx d)
const std::vector< std::pair< PRMInstance< GUM_SCALAR > *, std::string > > & getRefAttr(NodeId id) const
Returns a vector of pairs of refering attributes of id.
virtual prm_type obj_type() const
Returns the PRM type of this object.
RefIterator(const RefIterator &from)
Set< PRMInstance< GUM_SCALAR > *>::const_iterator _iter_
bool operator!=(const RefConstIterator &from) const
RefIterator begin(NodeId id)
Returns an iterator at the beginning of the set of PRMInstance<GUM_SCALAR> associated to a given gum:...
const PRMAttribute< GUM_SCALAR > & get(const std::string &name) const
Given a name returns the related PRMClassElement.
Bijection< const DiscreteVariable *, const DiscreteVariable *> _bijection_
A bijection used for MultiDim handling.
const iterator & end()
Returns a reference over the iterator at the end of the list of gum::prm::PRMAttribute<GUM_SCALAR> in...
void _copyAttribute_(PRMAttribute< GUM_SCALAR > *source)
Used at construction to instantiate attributes.
bool hasRefAttr(NodeId id) const
Returns true if id has at least one referring PRMAttribute<GUM_SCALAR>.
NodeProperty< std::vector< pair > *> _referingAttr_
The set of pair (instance, attribute) referring an attribute of this instance.
void _addReferingInstance_(PRMSlotChain< GUM_SCALAR > *sc, PRMInstance< GUM_SCALAR > *i)
Add this as a referring instance over the attribute pointed by sc in i.
const PRMInstance< GUM_SCALAR > * operator->() const
Set< PRMInstance< GUM_SCALAR > *> & _set_
RefConstIterator & operator=(const RefConstIterator &from)
RefIterator & operator=(const RefIterator &from)
iterator begin()
Returns an iterator at the begining of the list of gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInst...
const InvRefIterator & endInvRef()
Alias to iterate over the gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.
PRMAttribute< GUM_SCALAR > & get(const std::string &name)
Given a name returns the related PRMAttribute<GUM_SCALAR>.
const Set< PRMInstance< GUM_SCALAR > *> & _set_
bool operator!=(const RefIterator &from) const
void _copyAggregates_(PRMAggregate< GUM_SCALAR > *source)
Used at construction to instantiate aggregates.
const Set< PRMInstance< GUM_SCALAR > *> & getInstances(NodeId id) const
Returns the Set of PRMInstance<GUM_SCALAR> referenced by id.
Set< PRMInstance< GUM_SCALAR > *>::iterator _iter_