![]() |
aGrUM 3.0.0
a C++ library for (probabilistic) graphical models
|
Factory which builds a PRM<GUM_SCALAR>. More...
#include <PRMFactory.h>
Public Member Functions | |
Constructors & destructor | |
| PRMFactory () | |
| Default constructor. | |
| PRMFactory (PRM< GUM_SCALAR > *prm) | |
| This constructor let you set on which PRM instance the factory works. | |
| PRMFactory (const PRMFactory &from)=delete | |
| Copy constructor. Don't use it. | |
| PRMFactory & | operator= (const PRMFactory &from)=delete |
| Copy operator. Don't use it. | |
| ~PRMFactory () override | |
| Destructor. | |
Getters & Setters | |
| PRM< GUM_SCALAR > * | prm () const |
| Returns a pointer on the PRM<GUM_SCALAR> created by this factory. | |
| PRMObject::prm_type | currentType () const override |
| PRMObject * | getCurrent () override |
| const PRMObject * | getCurrent () const override |
| Returns a pointer on the PRM<GUM_SCALAR> created by this factory. | |
| PRMObject * | closeCurrent () override |
| Close current object being built. | |
| std::string | currentPackage () const override |
| PRMClass< GUM_SCALAR > & | retrieveClass (std::string_view name) |
| Returns a reference over a Class<GUM_SCALAR> given its name. | |
| PRMType & | retrieveType (std::string_view name) |
| Returns a reference over a PRMType given its name. | |
| PRMType & | retrieveCommonType (const std::vector< PRMClassElement< GUM_SCALAR > * > &elts) |
| Returns a pointer on the PRM<GUM_SCALAR> created by this factory. | |
Package construction methods. | |
| void | pushPackage (std::string_view name) override |
| Define the current package. | |
| std::string | popPackage () override |
| Pop the current package from the package stack. | |
| void | addImport (std::string_view name) override |
| Add an import for namespace lookup. | |
PRMType construction methods. | |
| void | startDiscreteType (std::string_view name, std::string_view super="") override |
| Start a discrete subtype declaration. | |
| void | addLabel (std::string_view l, std::string_view ext="") override |
| Add a label to the current discrete type. | |
| void | endDiscreteType () override |
| End the current discrete type declaration. | |
| void | startDiscretizedType (std::string_view name) override |
| Start a discretized type declaration. | |
| void | addTick (double tick) override |
| Add a tick to the current discretized type. | |
| void | endDiscretizedType () override |
| End the current discretized type declaration. | |
| void | addRangeType (std::string_view name, long minVal, long maxVal) override |
| Add a range variable type declaration. | |
several checks for parsers | |
| bool | isClassOrInterface (std::string_view type) const override |
| bool | isArrayInCurrentSystem (std::string_view name) const override |
Class<GUM_SCALAR> construction models. | |
| void | startClass (std::string_view c, std::string_view ext="", const Set< std::string > *implements=nullptr, bool delayInheritance=false) override |
| Tells the factory that we start a class declaration. | |
| void | continueClass (std::string_view c) override |
| Continue the declaration of a class. | |
| void | endClass (bool checkImplementations=true) override |
| Tells the factory that we finished a class declaration. | |
PRMInterface<GUM_SCALAR> construction models. | |
| void | startInterface (std::string_view i, std::string_view ext="", bool delayInheritance=false) override |
| Tells the factory that we start an interface declaration. | |
| void | continueInterface (std::string_view name) override |
| Continue the declaration of an interface. | |
| void | addAttribute (std::string_view type, std::string_view name) override |
| Add an attribute to an interface. | |
| void | endInterface () override |
| Tells the factory that we finished an interface declaration. | |
Attributes construction methods. | |
| virtual void | addAttribute (PRMAttribute< GUM_SCALAR > *attr) |
| Add an already created attribute to the current class. | |
| void | startAttribute (std::string_view type, std::string_view name, bool scalar_atttr=false) override |
| Tells the factory that we start an attribute declaration. | |
| void | continueAttribute (std::string_view name) override |
| Continues the declaration of an attribute. | |
| void | addParent (std::string_view name) override |
| Tells the factory that we add a parent to the current declared attribute. | |
| void | setRawCPFByLines (const std::vector< GUM_SCALAR > &array) |
| Gives the factory the CPF in its raw form. | |
| void | setRawCPFByColumns (const std::vector< GUM_SCALAR > &array) |
| Gives the factory the CPF in its raw form. | |
| virtual void | setCPFByRule (const std::vector< std::string > &labels, const std::vector< GUM_SCALAR > &values) |
| Fills the CPF using a rule. | |
| void | setCPFByRule (const std::vector< std::string > &labels, const std::vector< std::string > &values) override |
| Fills the CPF using a rule and gum::Formula. | |
| void | setRawCPFByFloatLines (const std::vector< float > &array) override |
| Gives the factory the CPF in its raw form. | |
| void | setRawCPFByFloatColumns (const std::vector< float > &array) override |
| Gives the factory the CPF in its raw form. | |
| void | setRawCPFByColumns (const std::vector< std::string > &array) override |
| Gives the factory the CPF in its raw form use gum::Formula. | |
| void | setRawCPFByLines (const std::vector< std::string > &array) override |
| Gives the factory the CPF in its raw form using gum::Formula. | |
| void | setCPFByFloatRule (const std::vector< std::string > &labels, const std::vector< float > &values) override |
| Fills the CPF using a rule. | |
| void | endAttribute () override |
| Tells the factory that we finished declaring an attribute. | |
Parameters construction methods. | |
| void | addParameter (std::string_view type, std::string_view name, double value) override |
| Add a parameter to the current class with a default value. | |
Aggregator and function construction methods. | |
| void | addAggregator (std::string_view name, std::string_view agg_type, const std::vector< std::string > &chains, const std::vector< std::string > ¶ms, std::string_view type="") override |
| Add an aggregator in the current declared class. | |
| void | startAggregator (std::string_view name, std::string_view agg_type, std::string_view rv_type, const std::vector< std::string > ¶ms) |
| Start an aggregator declaration. | |
| void | continueAggregator (std::string_view name) |
| Conitnues an aggregator declaration. | |
| void | endAggregator () |
| Finishes an aggregate declaration. | |
| void | addNoisyOrCompound (std::string_view name, const std::vector< std::string > &chains, const std::vector< float > &numbers, float leak, const std::vector< std::string > &label) override |
| Add a compound noisy-or as an PRMAttribute<GUM_SCALAR> to the current Class<GUM_SCALAR>. | |
PRMReferenceSlot<GUM_SCALAR> construction methods. | |
| void | addReferenceSlot (std::string_view type, std::string_view name, bool isArray) override |
| Tells the factory that we started declaring a slot. | |
Systems constructions methods. | |
| void | startSystem (std::string_view name) override |
| Tells the factory that we started declaring a model. | |
| void | endSystem () override |
| Tells the factory that we finished declaring a model. | |
| void | addInstance (std::string_view type, std::string_view name) override |
| Add an instance to the model. | |
| void | addInstance (std::string_view type, std::string_view name, const HashTable< std::string, double > ¶ms) override |
| Add an instance with params as values of type's parameters. | |
| void | addArray (std::string_view type, std::string_view name, Size size) override |
| Creates an array with the given number of instances of the given type. | |
| void | incArray (std::string_view l_i, std::string_view r_i) override |
| Add an instance to an array. | |
| void | setReferenceSlot (std::string_view left_instance, std::string_view left_reference, std::string_view right_instance) override |
| Instantiate a reference in the current model. | |
| void | setReferenceSlot (std::string_view l_i, std::string_view r_i) override |
| Instantiate a reference in the current model. | |
Private Member Functions | |
Private methods for type checking and exception handling. | |
| std::string | _addPrefix_ (std::string_view str) const |
| Adds prefix to str iff prefix != "". | |
| PRMObject * | _checkStack_ (Idx i, PRMObject::prm_type obj_type) |
| Return a pointer on a PRMObject at stack.size() - i position after checking the type of the object given obj_type. | |
| PRMClassElement< GUM_SCALAR > * | _checkStack_ (Idx i, typename PRMClassElement< GUM_SCALAR >::ClassElementType obj_type) |
| Adds prefix to str iff prefix != "". | |
| PRMClassElementContainer< GUM_SCALAR > * | _checkStackContainter_ (Idx i) |
| Adds prefix to str iff prefix != "". | |
Private getters | |
| PRMType * | _retrieveType_ (std::string_view name) const |
| Returns a pointer on a PRMType given it's name. Since the type can be given either with it's local name (without the prefix), full name (with the prefix) or can come from an import unit, or maybe one day with a using declaration we need some processing to find it. | |
| PRMClass< GUM_SCALAR > * | _retrieveClass_ (std::string_view name) const |
| Returns a pointer on a class given it's name. Used when building models, meaning that the class name can either be local (need to add the current prefix) or global (no prefix needed). | |
| PRMInterface< GUM_SCALAR > * | _retrieveInterface_ (std::string_view name) const |
| Returns a pointer on an interface given it's name. Used when building models, meaning that the interface name can either be local (need to add the current prefix) or global (no prefix needed). | |
Private methods handling Class<GUM_SCALAR> and | |
PRMClassElement<GUM_SCALAR> creation. | |
| PRMSlotChain< GUM_SCALAR > * | _buildSlotChain_ (PRMClassElementContainer< GUM_SCALAR > *start, std::string_view name) |
| This methods build a PRMSlotChain<GUM_SCALAR> given a starting element and a string. | |
| bool | _retrieveInputs_ (PRMClass< GUM_SCALAR > *c, const std::vector< std::string > &chains, std::vector< PRMClassElement< GUM_SCALAR > * > &inputs) |
| Retrieve inputs for an PRMAggregate. | |
| PRMType * | _retrieveCommonType_ (const std::vector< PRMClassElement< GUM_SCALAR > * > &elts) |
| Retrieve the common PRMType of a vector of PRMClassElement<GUM_SCALAR>. | |
| int | _typeDepth_ (const PRMType *t) |
| Returns the inheritance depth of a PRMType. | |
| void | _checkInterfaceImplementation_ (PRMClass< GUM_SCALAR > *c) |
| Check if c implements correctly all his interfaces. | |
| void | _addParent_ (PRMClassElementContainer< GUM_SCALAR > *c, PRMAttribute< GUM_SCALAR > *agg, std::string_view name) |
| Add a parent to an attribute. | |
| void | _addParent_ (PRMClass< GUM_SCALAR > *c, PRMAggregate< GUM_SCALAR > *agg, std::string_view name) |
| Add a parent to an aggregate. | |
Private methods handling PRMSystem<GUM_SCALAR> and | |
PRMInstance<GUM_SCALAR> creation. | |
| void | _addInstance_ (PRMClass< GUM_SCALAR > *type, std::string_view name) |
| Adds an instance to the current model. | |
| void | _buildAggregateCPF_ (PRMSystem< GUM_SCALAR > *model) |
| Builds all Aggregates CPF in the given model. This must be called after all the slot chains have been generated. | |
| void | _instantiateSlotChain_ (PRMSystem< GUM_SCALAR > *model, PRMInstance< GUM_SCALAR > *inst, PRMReferenceSlot< GUM_SCALAR > *ref, PRMSlotChain< GUM_SCALAR > *sc) |
| Instantiate a slot chain in the given instance. | |
| std::string | _retrieveInstanceSequence_ (PRMInstance< GUM_SCALAR > *inst, Sequence< PRMInstance< GUM_SCALAR > * > &seq, PRMSlotChain< GUM_SCALAR > *sc) |
| Fill seq with the sequence of instance build using inst as the instantiation of sc-> class and seeking each instantiation of reference in sc. | |
Private Attributes | |
Private members. | |
| std::vector< std::string > | _packages_ |
| The prefix used for classes and types names. It is normally the namespace of the corresponding compilation unit. | |
| std::vector< List< std::string > * > | _namespaces_ |
| Set of all declared namespaces. | |
| PRM< GUM_SCALAR > * | _prm_ |
| The pointer on the PRM<GUM_SCALAR> built by this factory. | |
| std::vector< PRMObject * > | _stack_ |
| A stack used to keep track of created PRMObject. | |
| HashTable< PRMAggregate< GUM_SCALAR > *, std::vector< std::string > > | _agg_params_ |
| A mapping between aggregators and their parameters. | |
Factory which builds a PRM<GUM_SCALAR>.
The Factory always create one PRM<GUM_SCALAR> which is not deleted with the factory, so be very careful to delete the PRM<GUM_SCALAR> built by this factory.
The factory does not allow any sequence of calls, if you call a method when the factory is in an incoherent state it will raise a FactoryInvalidState exception.
Keep in mind that most methods could raise gum::FatalError if something unexpected happens, since the framework is meant to evolve it is possible.
Definition at line 90 of file PRMFactory.h.
| gum::prm::PRMFactory< GUM_SCALAR >::PRMFactory | ( | ) |
Default constructor.
Definition at line 1304 of file PRMFactory_tpl.h.
References PRMFactory(), and _prm_.
Referenced by PRMFactory(), PRMFactory(), PRMFactory(), ~PRMFactory(), and operator=().
| gum::prm::PRMFactory< GUM_SCALAR >::PRMFactory | ( | PRM< GUM_SCALAR > * | prm | ) |
This constructor let you set on which PRM instance the factory works.
Definition at line 1310 of file PRMFactory_tpl.h.
References PRMFactory(), _prm_, and prm().
|
delete |
|
override |
Destructor.
Definition at line 1315 of file PRMFactory_tpl.h.
References PRMFactory(), and _namespaces_.
|
private |
Adds an instance to the current model.
Definition at line 1664 of file PRMFactory_tpl.h.
References _checkStack_(), and gum::prm::PRMObject::SYSTEM.
Referenced by addInstance(), and addInstance().
|
private |
Add a parent to an aggregate.
Definition at line 602 of file PRMFactory_tpl.h.
References _retrieveInputs_(), _retrieveType_(), gum::prm::PRMClass< GUM_SCALAR >::addArc(), gum::prm::PRMAggregate< GUM_SCALAR >::agg_type(), gum::prm::PRMAggregate< GUM_SCALAR >::AMPLITUDE, gum::prm::PRMAggregate< GUM_SCALAR >::AND, gum::prm::PRMAggregate< GUM_SCALAR >::COUNT, gum::prm::PRMAggregate< GUM_SCALAR >::EXISTS, gum::prm::PRMAggregate< GUM_SCALAR >::FORALL, GUM_ERROR, gum::prm::PRMAggregate< GUM_SCALAR >::hasLabel(), gum::prm::PRMAggregate< GUM_SCALAR >::labelValue(), gum::prm::PRMAggregate< GUM_SCALAR >::MAX, gum::prm::PRMAggregate< GUM_SCALAR >::MEDIAN, gum::prm::PRMAggregate< GUM_SCALAR >::MIN, gum::prm::PRMAggregate< GUM_SCALAR >::OR, gum::prm::PRMClassElement< GUM_SCALAR >::safeName(), gum::prm::PRMAggregate< GUM_SCALAR >::setLabel(), and gum::prm::PRMAggregate< GUM_SCALAR >::SUM.
|
private |
Add a parent to an attribute.
Definition at line 252 of file PRMFactory_tpl.h.
References _buildSlotChain_(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::add(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::addArc(), gum::prm::PRMClassElement< GUM_SCALAR >::elt_type(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::exists(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::get(), GUM_ERROR, gum::prm::PRMSlotChain< GUM_SCALAR >::isMultiple(), gum::prm::PRMObject::name(), gum::prm::PRMClassElement< GUM_SCALAR >::prm_aggregate, gum::prm::PRMClassElement< GUM_SCALAR >::prm_attribute, gum::prm::PRMClassElement< GUM_SCALAR >::prm_refslot, and gum::prm::PRMClassElement< GUM_SCALAR >::prm_slotchain.
Referenced by addParent().
|
private |
Adds prefix to str iff prefix != "".
Definition at line 1680 of file PRMFactory_tpl.h.
References _packages_.
Referenced by _retrieveClass_(), _retrieveInterface_(), _retrieveType_(), addRangeType(), continueClass(), continueInterface(), startClass(), startDiscreteType(), startDiscretizedType(), startInterface(), and startSystem().
|
private |
Builds all Aggregates CPF in the given model. This must be called after all the slot chains have been generated.
|
private |
This methods build a PRMSlotChain<GUM_SCALAR> given a starting element and a string.
Definition at line 933 of file PRMFactory_tpl.h.
References gum::SequenceImplementation< Key, Gen >::back(), gum::prm::decomposePath(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::exists(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::get(), gum::SequenceImplementation< Key, Gen >::insert(), gum::prm::PRMClassElement< GUM_SCALAR >::prm_aggregate, gum::prm::PRMClassElement< GUM_SCALAR >::prm_attribute, gum::prm::PRMClassElement< GUM_SCALAR >::prm_refslot, gum::prm::PRMClassElementContainer< GUM_SCALAR >::setOutputNode(), gum::SequenceImplementation< Key, Gen >::size(), and gum::prm::PRMReferenceSlot< GUM_SCALAR >::slotType().
Referenced by _addParent_(), _retrieveInputs_(), and addNoisyOrCompound().
|
private |
Check if c implements correctly all his interfaces.
Definition at line 121 of file PRMFactory_tpl.h.
References gum::prm::PRMClassElementContainer< GUM_SCALAR >::exists(), gum::prm::PRMClass< GUM_SCALAR >::get(), GUM_ERROR, gum::prm::PRMClass< GUM_SCALAR >::implements(), gum::prm::PRMObject::name(), gum::prm::PRMClassElement< GUM_SCALAR >::prm_aggregate, gum::prm::PRMClassElement< GUM_SCALAR >::prm_attribute, gum::prm::PRMClassElement< GUM_SCALAR >::prm_refslot, gum::prm::PRMClassElement< GUM_SCALAR >::prm_slotchain, and gum::prm::PRMReferenceSlot< GUM_SCALAR >::slotType().
Referenced by endClass().
|
private |
Return a pointer on a PRMObject at stack.size() - i position after checking the type of the object given obj_type.
| FactoryInvalidState | Raised if the stack isn't consistent with the |
Definition at line 1692 of file PRMFactory_tpl.h.
References _stack_, GUM_ERROR, and gum::prm::PRMObject::obj_type().
Referenced by _addInstance_(), addAggregator(), addArray(), addAttribute(), addAttribute(), addLabel(), addParameter(), addParent(), addTick(), endAggregator(), endAttribute(), endClass(), endDiscreteType(), endDiscretizedType(), endInterface(), endSystem(), incArray(), setCPFByFloatRule(), setCPFByRule(), setCPFByRule(), setRawCPFByColumns(), setRawCPFByColumns(), setRawCPFByFloatColumns(), setRawCPFByFloatLines(), setRawCPFByLines(), setRawCPFByLines(), setReferenceSlot(), and startAggregator().
|
private |
Adds prefix to str iff prefix != "".
Definition at line 1726 of file PRMFactory_tpl.h.
References _stack_, gum::prm::PRMClassElement< GUM_SCALAR >::elt_type(), and GUM_ERROR.
|
private |
Adds prefix to str iff prefix != "".
Definition at line 1709 of file PRMFactory_tpl.h.
References _stack_, gum::prm::PRMObject::CLASS, GUM_ERROR, gum::prm::PRMObject::obj_type(), and gum::prm::PRMObject::PRM_INTERFACE.
Referenced by addParent(), addReferenceSlot(), continueAggregator(), continueAttribute(), and startAttribute().
|
private |
Instantiate a slot chain in the given instance.
|
private |
Returns a pointer on a class given it's name. Used when building models, meaning that the class name can either be local (need to add the current prefix) or global (no prefix needed).
| NotFound | If no class matching the name is found. |
Definition at line 1207 of file PRMFactory_tpl.h.
References _addPrefix_(), _namespaces_, _prm_, and GUM_ERROR.
Referenced by addArray(), addInstance(), addInstance(), addReferenceSlot(), isClassOrInterface(), retrieveClass(), and startClass().
|
private |
Retrieve the common PRMType of a vector of PRMClassElement<GUM_SCALAR>.
The vector elts must only contains PRMClassElement<GUM_SCALAR> with a PRMType, i.e. PRMAttribute<GUM_SCALAR>, PRMAggregate and PRMSlotChain<GUM_SCALAR>. If not a WrongClassElement is raised.
A common PRMType is PRMType t such as t.isSuperTypeOf(elts[i]) for 0 < i < elts.size(), where elts is a PRMType container.
| elts | A vector of PRMClassElement<GUM_SCALAR>. |
| WrongClassElement | Raised if elts contains a PRMClassElement<GUM_SCALAR> without a PRMType. |
| NotFound | Raised if there exists no common super type of all PRMClassElement<GUM_SCALAR> in elts. |
Definition at line 1029 of file PRMFactory_tpl.h.
References _retrieveType_(), _typeDepth_(), GUM_ERROR, gum::HashTable< Key, Val >::insert(), gum::Variable::name(), and gum::HashTable< Key, Val >::tryGet().
Referenced by _retrieveInputs_(), addNoisyOrCompound(), and retrieveCommonType().
|
private |
Retrieve inputs for an PRMAggregate.
The vector chains contains names of the PRMAggregate inputs. If a name does not match an existing PRMClassElement<GUM_SCALAR> in c, then a call to PRMFactory:: buildSlotChains() is made. Such created PRMSlotChain<GUM_SCALAR> are added to c.
| c | The class in which the PRMAggregate is defined. |
| chains | Vector of the PRMAggregate inputs names. |
| inputs | Vector filled with the PRMClassElement<GUM_SCALAR> matching the names in chains. |
| NotFound | Raised if a name in chains does not match a legal PRMSlotChain<GUM_SCALAR> or an existing PRMClassElement<GUM_SCALAR> in c. |
Definition at line 974 of file PRMFactory_tpl.h.
References _buildSlotChain_(), _retrieveCommonType_(), gum::prm::PRMClass< GUM_SCALAR >::add(), gum::prm::PRMSlotChain< GUM_SCALAR >::chain(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::exists(), gum::prm::PRMClass< GUM_SCALAR >::get(), GUM_ERROR, gum::prm::PRMClassElement< GUM_SCALAR >::isSlotChain(), gum::prm::PRMSlotChain< GUM_SCALAR >::lastElt(), and gum::Variable::name().
Referenced by _addParent_(), and addAggregator().
|
private |
Fill seq with the sequence of instance build using inst as the instantiation of sc-> class and seeking each instantiation of reference in sc.
|
private |
Returns a pointer on an interface given it's name. Used when building models, meaning that the interface name can either be local (need to add the current prefix) or global (no prefix needed).
| NotFound | If no class matching the name is found. |
Definition at line 1254 of file PRMFactory_tpl.h.
References _addPrefix_(), _namespaces_, _prm_, and GUM_ERROR.
Referenced by addReferenceSlot(), continueInterface(), isClassOrInterface(), startClass(), and startInterface().
|
private |
Returns a pointer on a PRMType given it's name. Since the type can be given either with it's local name (without the prefix), full name (with the prefix) or can come from an import unit, or maybe one day with a using declaration we need some processing to find it.
The following precedences on finding the name is used:
| OperationNotAllowed | If the type is undeclared. |
Definition at line 1146 of file PRMFactory_tpl.h.
References _addPrefix_(), _namespaces_, _prm_, currentPackage(), and GUM_ERROR.
Referenced by _addParent_(), _retrieveCommonType_(), addAggregator(), retrieveType(), startAggregator(), startAttribute(), and startDiscreteType().
|
private |
Returns the inheritance depth of a PRMType.
This used by PRMFactory:: retrieveCommonType. This returns 0 if t does not have a super type.
| t | The PRMType for which we compute its depth. |
Definition at line 1747 of file PRMFactory_tpl.h.
Referenced by _retrieveCommonType_().
|
overridevirtual |
Add an aggregator in the current declared class.
If at least one parent of an aggregator is a PRMSlotChain<GUM_SCALAR>, then all of it's parents must be PRMSlotChain<GUM_SCALAR>. When an aggregator parents are only composed of PRMAttribute<GUM_SCALAR> and PRMAggregate, then it is directly added as an PRMAttribute<GUM_SCALAR> to it's Class<GUM_SCALAR>.
| name | The name of this aggregator. |
| agg_type | The name of the aggregator type of this aggregator. |
| chains | The set of chains on which this aggregate applies. |
| params | The list of parameters for this aggregator. |
| type | Some aggregators have a user defined type, use this parameter to define it. |
| OperationNotAllowed | Raised if one or more parameters misses or are not correct. |
| TypeError | Raised if the aggregator's type or one or more of the chains are not of the good type. |
Implements gum::prm::IPRMFactory.
Definition at line 665 of file PRMFactory_tpl.h.
References _checkStack_(), _retrieveInputs_(), _retrieveType_(), gum::prm::PRMClass< GUM_SCALAR >::add(), gum::prm::PRMClass< GUM_SCALAR >::addArc(), gum::prm::PRMAggregate< GUM_SCALAR >::AMPLITUDE, gum::prm::PRMAggregate< GUM_SCALAR >::AND, gum::prm::PRMAggregate< GUM_SCALAR >::buildImpl(), gum::prm::PRMObject::CLASS, gum::prm::PRMAggregate< GUM_SCALAR >::COUNT, gum::prm::PRMAggregate< GUM_SCALAR >::EXISTS, gum::prm::PRMAggregate< GUM_SCALAR >::FORALL, GUM_ERROR, gum::prm::PRMAggregate< GUM_SCALAR >::label(), gum::prm::PRMAggregate< GUM_SCALAR >::MAX, gum::prm::PRMAggregate< GUM_SCALAR >::MEDIAN, gum::prm::PRMAggregate< GUM_SCALAR >::MIN, gum::prm::PRMObject::name(), gum::prm::PRMAggregate< GUM_SCALAR >::OR, gum::prm::PRMClass< GUM_SCALAR >::overload(), gum::prm::PRMClassElement< GUM_SCALAR >::safeName(), gum::prm::PRMAggregate< GUM_SCALAR >::str2enum(), gum::prm::PRMAggregate< GUM_SCALAR >::SUM, and gum::prm::PRMAggregate< GUM_SCALAR >::type().
Referenced by gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateClass_(), gum::prm::LayerGenerator< GUM_SCALAR >::_generateClasses_(), and gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateCluster_().
|
overridevirtual |
Creates an array with the given number of instances of the given type.
PRMInstance<GUM_SCALAR> are name using "name" as prefix and adding the suffix "[i]", with "i" being the position of the instance in the array.
Implements gum::prm::IPRMFactory.
Definition at line 849 of file PRMFactory_tpl.h.
References _checkStack_(), _retrieveClass_(), gum::prm::PRMSystem< GUM_SCALAR >::add(), gum::prm::PRMSystem< GUM_SCALAR >::addArray(), and gum::prm::PRMObject::SYSTEM.
Referenced by gum::prm::o3prm::O3SystemFactory< GUM_SCALAR >::_addInstances_().
|
virtual |
Add an already created attribute to the current class.
Use this method when you must add functions, such as Noisy-Or.
Use this method when you need to add functions, such as Noisy-Or. The attribute CPT is checked for parents and arcs will be added using the DiscreteVariable pointers, thus be careful to use those of the attributes, aggregates and slotchains of the current class. gum::prm::Class<GUM_SCALAR>::insertArc() will be called for each found parent of attr, so you should overload gum::prm::PRMAttribute<GUM_SCALAR>::addParent() to prevent duplication errors. Such class exists: gum::prm::PRMFuncAttribute .
The pointer is given to the class, so do not worry about deleting it.
| attr | The attribute added to the current class. |
| NotFound | Raised if one of the DiscreteVariable in attr CPT does not match any PRMClassElement<GUM_SCALAR> in this. |
Definition at line 227 of file PRMFactory_tpl.h.
References _checkStack_(), gum::prm::PRMClass< GUM_SCALAR >::add(), gum::prm::PRMClass< GUM_SCALAR >::addArc(), gum::prm::PRMObject::CLASS, gum::prm::PRMClassElementContainer< GUM_SCALAR >::containerDag(), gum::prm::PRMAttribute< GUM_SCALAR >::cpf(), gum::SequenceImplementation< Key, Gen >::exists(), gum::prm::PRMClass< GUM_SCALAR >::get(), GUM_ERROR, gum::NodeGraphPart::nodes(), gum::prm::PRMClassElement< GUM_SCALAR >::safeName(), gum::prm::PRMAttribute< GUM_SCALAR >::type(), and gum::prm::PRMType::variable().
|
overridevirtual |
Add an attribute to an interface.
Implements gum::prm::IPRMFactory.
Definition at line 1512 of file PRMFactory_tpl.h.
References _checkStack_(), endAttribute(), gum::prm::PRMObject::PRM_INTERFACE, and startAttribute().
Referenced by gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateInterfaces_(), gum::prm::LayerGenerator< GUM_SCALAR >::_generateInterfaces_(), addNoisyOrCompound(), and gum::prm::o3prm::O3InterfaceFactory< GUM_SCALAR >::buildElements().
|
overridevirtual |
Add an import for namespace lookup.
When loading a module, you should push all import declarations using this method. The order in which you add imports will impact name resolution (first found, first used).
Imports are sync with packages: when you push a new package a new empty list of imports is added. When you pop a package the current list of imports is discarded and the previous one is restored.
| name | The name of the package for all further objects. |
Implements gum::prm::IPRMFactory.
Definition at line 1784 of file PRMFactory_tpl.h.
References _namespaces_, and GUM_ERROR.
|
overridevirtual |
Add an instance to the model.
Implements gum::prm::IPRMFactory.
Definition at line 1589 of file PRMFactory_tpl.h.
References _addInstance_(), _retrieveClass_(), and addInstance().
Referenced by gum::prm::o3prm::O3SystemFactory< GUM_SCALAR >::_addInstances_(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateSystem_(), gum::prm::LayerGenerator< GUM_SCALAR >::_generateSystem_(), and addInstance().
|
overridevirtual |
Add an instance with params as values of type's parameters.
Implements gum::prm::IPRMFactory.
Definition at line 1603 of file PRMFactory_tpl.h.
References _addInstance_(), _packages_, _retrieveClass_(), addParameter(), gum::HashTable< Key, Val >::empty(), endClass(), GUM_ERROR, gum::prm::PRMParameter< GUM_SCALAR >::INT, startClass(), and gum::prm::PRMParameter< GUM_SCALAR >::valueType().
|
overridevirtual |
Add a label to the current discrete type.
| l | The label value. |
| ext | The super type label for which l is an extension. |
| OperationNotAllowed | Raised if the current type does not have a super type, see PRMFactory::addLabel(const std::string&). |
| DuplicateElement | Raised if a label with the same value already exists. |
| NotFound | Raised if ext does not match any label in the current type's super type. |
Implements gum::prm::IPRMFactory.
Definition at line 1385 of file PRMFactory_tpl.h.
References _checkStack_(), gum::LabelizedVariable::addLabel(), gum::DiscreteVariable::domainSize(), GUM_ERROR, gum::DiscreteVariable::label(), and gum::prm::PRMObject::TYPE.
Referenced by gum::prm::o3prm::O3TypeFactory< GUM_SCALAR >::_buildTypes_(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateType_(), and gum::prm::LayerGenerator< GUM_SCALAR >::_generateType_().
|
overridevirtual |
Add a compound noisy-or as an PRMAttribute<GUM_SCALAR> to the current Class<GUM_SCALAR>.
The type of a noisy-or must be a boolean.
| name | the name of the PRMAttribute<GUM_SCALAR> added as a noisy-or. |
| chains | the list of parents of the noisy-or. |
| numbers | the list of weights for each parent. Can consist of only one value which will be applied to all the parents. |
| leak | the leak |
| label | the label on which the noisy-or applies, can be an empty string (the noisy-or will behave as if chains are all booleans). |
| NotFound | Raised if one of the chains or the label is not found. |
| FactoryInvalidState | Raised if a Class<GUM_SCALAR> is not the current declared PRMObject. |
| OperationNotAllowed | Raised if for some reasons the parameters are invalid. |
Implements gum::prm::IPRMFactory.
Definition at line 1083 of file PRMFactory_tpl.h.
References _buildSlotChain_(), _retrieveCommonType_(), gum::prm::PRMClass< GUM_SCALAR >::add(), addAttribute(), gum::prm::PRMClassElement< GUM_SCALAR >::cast(), gum::MultiDimICIModel< GUM_ELEMENT >::causalWeight(), gum::prm::PRMObject::CLASS, currentType(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::exists(), gum::prm::PRMClass< GUM_SCALAR >::get(), getCurrent(), GUM_ERROR, gum::prm::PRMClassElement< GUM_SCALAR >::isSlotChain(), and retrieveType().
|
overridevirtual |
Add a parameter to the current class with a default value.
A parameter with a default value is an PRMAttribute<GUM_SCALAR> (aka mutable PRMAttribute<GUM_SCALAR>) with no parents and with a CPF filled with 1.
| type | The type of this parameter. |
| name | The name of this parameter. |
| value | The label used as default value for this parameter. |
Implements gum::prm::IPRMFactory.
Definition at line 534 of file PRMFactory_tpl.h.
References _checkStack_(), gum::prm::PRMObject::CLASS, gum::prm::PRMParameter< GUM_SCALAR >::INT, and gum::prm::PRMParameter< GUM_SCALAR >::REAL.
Referenced by gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_addParameters_(), and addInstance().
|
overridevirtual |
Tells the factory that we add a parent to the current declared attribute.
The name can refer to an already declared attribute or aggregate of the same class. It can also be a slot chain only if there is no multiple reference in it.
| OperationNotAllowed | Raised if the given operation is illegal. |
Implements gum::prm::IPRMFactory.
Definition at line 304 of file PRMFactory_tpl.h.
References _addParent_(), _checkStack_(), _checkStackContainter_(), gum::prm::PRMClassElement< GUM_SCALAR >::prm_aggregate, and gum::prm::PRMClassElement< GUM_SCALAR >::prm_attribute.
Referenced by gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_completeAggregates_(), gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_completeAttribute_(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateClass_(), gum::prm::LayerGenerator< GUM_SCALAR >::_generateClasses_(), and gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateCluster_().
|
overridevirtual |
Add a range variable type declaration.
| name | The variable's name |
| minVal | The variable's lower bound. |
| maxVal | The variable's upper bound. |
| DuplicateElement | Raised if an object with the same name already exists. |
| OperationNotAllowed | Raised if the range variable is not a valid discrete type. |
Implements gum::prm::IPRMFactory.
Definition at line 1488 of file PRMFactory_tpl.h.
References _addPrefix_(), _prm_, and GUM_ERROR.
Referenced by gum::prm::o3prm::O3TypeFactory< GUM_SCALAR >::_buildIntTypes_().
|
overridevirtual |
Tells the factory that we started declaring a slot.
| OperationNotAllowed | Raised if the given operation is illegal. |
Implements gum::prm::IPRMFactory.
Definition at line 824 of file PRMFactory_tpl.h.
References _checkStackContainter_(), _retrieveClass_(), _retrieveInterface_(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::add(), GUM_ERROR, and gum::prm::PRMClassElementContainer< GUM_SCALAR >::overload().
Referenced by gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_addReferenceSlots_(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateClass_(), gum::prm::LayerGenerator< GUM_SCALAR >::_generateClasses_(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateCluster_(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateInterfaces_(), gum::prm::LayerGenerator< GUM_SCALAR >::_generateInterfaces_(), and gum::prm::o3prm::O3InterfaceFactory< GUM_SCALAR >::buildElements().
|
overridevirtual |
Add a tick to the current discretized type.
| tick | The tick value. |
Implements gum::prm::IPRMFactory.
Definition at line 1460 of file PRMFactory_tpl.h.
References _checkStack_(), gum::DiscretizedVariable< T_TICKS >::addTick(), GUM_ERROR, and gum::prm::PRMObject::TYPE.
Referenced by gum::prm::o3prm::O3TypeFactory< GUM_SCALAR >::_buildRealTypes_().
|
overridevirtual |
Close current object being built.
Nothing is done in particular except removing the current object from the factory's stack. If the object was not added to a container it will not be deleted properly, so you might want to delete it yourself (at your own risks!).
Implements gum::prm::IPRMFactory.
Definition at line 1351 of file PRMFactory_tpl.h.
References _stack_.
| void gum::prm::PRMFactory< GUM_SCALAR >::continueAggregator | ( | std::string_view | name | ) |
Conitnues an aggregator declaration.
Definition at line 589 of file PRMFactory_tpl.h.
References _checkStackContainter_(), _stack_, gum::prm::PRMClassElementContainer< GUM_SCALAR >::exists(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::get(), GUM_ERROR, and gum::prm::PRMClassElement< GUM_SCALAR >::isAggregate().
Referenced by gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_completeAggregates_().
|
overridevirtual |
Continues the declaration of an attribute.
Implements gum::prm::IPRMFactory.
Definition at line 1548 of file PRMFactory_tpl.h.
References _checkStackContainter_(), _stack_, gum::prm::PRMClassElementContainer< GUM_SCALAR >::exists(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::get(), GUM_ERROR, and gum::prm::PRMClassElement< GUM_SCALAR >::isAttribute().
Referenced by gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_completeAttribute_().
|
overridevirtual |
Continue the declaration of a class.
Implements gum::prm::IPRMFactory.
Definition at line 102 of file PRMFactory_tpl.h.
References _addPrefix_(), _prm_, _stack_, and GUM_ERROR.
Referenced by gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_addReferenceSlots_(), gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_declareAggregates_(), gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_declareAttribute_(), gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::buildParameters(), gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::completeAggregates(), and gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::completeAttributes().
|
overridevirtual |
Continue the declaration of an interface.
Implements gum::prm::IPRMFactory.
Definition at line 216 of file PRMFactory_tpl.h.
References _addPrefix_(), _prm_, _retrieveInterface_(), _stack_, and GUM_ERROR.
Referenced by gum::prm::o3prm::O3InterfaceFactory< GUM_SCALAR >::buildElements().
|
overridevirtual |
Implements gum::prm::IPRMFactory.
Definition at line 1362 of file PRMFactory_tpl.h.
References _packages_.
Referenced by _retrieveType_(), and popPackage().
|
overridevirtual |
| NotFound | if no type is being built. |
Implements gum::prm::IPRMFactory.
Definition at line 1330 of file PRMFactory_tpl.h.
References _stack_, and GUM_ERROR.
Referenced by addNoisyOrCompound().
| void gum::prm::PRMFactory< GUM_SCALAR >::endAggregator | ( | ) |
Finishes an aggregate declaration.
Definition at line 659 of file PRMFactory_tpl.h.
References _checkStack_(), _stack_, and gum::prm::PRMClassElement< GUM_SCALAR >::prm_aggregate.
Referenced by gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_completeAggregates_(), and gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_declareAggregates_().
|
overridevirtual |
Tells the factory that we finished declaring an attribute.
| OperationNotAllowed | Raised if the given operation is illegal. |
Implements gum::prm::IPRMFactory.
Definition at line 1562 of file PRMFactory_tpl.h.
References _checkStack_(), _stack_, and gum::prm::PRMClassElement< GUM_SCALAR >::prm_attribute.
Referenced by gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_completeAttribute_(), gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_declareAttribute_(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateClass_(), gum::prm::LayerGenerator< GUM_SCALAR >::_generateClasses_(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateCluster_(), and addAttribute().
|
overridevirtual |
Tells the factory that we finished a class declaration.
| PRMTypeError | Raised if the current Class<GUM_SCALAR> does not respect one of it's PRMInterface<GUM_SCALAR>. |
Implements gum::prm::IPRMFactory.
Definition at line 111 of file PRMFactory_tpl.h.
References _checkInterfaceImplementation_(), _checkStack_(), _stack_, and gum::prm::PRMObject::CLASS.
Referenced by gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_addReferenceSlots_(), gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_declareAggregates_(), gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_declareAttribute_(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateClass_(), gum::prm::LayerGenerator< GUM_SCALAR >::_generateClasses_(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateCluster_(), addInstance(), gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::buildClasses(), gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::buildParameters(), gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::completeAggregates(), and gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::completeAttributes().
|
overridevirtual |
End the current discrete type declaration.
| OperationNotAllowed | Raised if the current type is not a valid discrete type. |
Implements gum::prm::IPRMFactory.
Definition at line 1433 of file PRMFactory_tpl.h.
References _checkStack_(), _prm_, _stack_, gum::DiscreteVariable::domainSize(), GUM_ERROR, gum::Variable::name(), and gum::prm::PRMObject::TYPE.
Referenced by gum::prm::o3prm::O3TypeFactory< GUM_SCALAR >::_buildTypes_(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateType_(), and gum::prm::LayerGenerator< GUM_SCALAR >::_generateType_().
|
overridevirtual |
End the current discretized type declaration.
| OperationNotAllowed | Raised if the current type is not a valid discrete type. |
Implements gum::prm::IPRMFactory.
Definition at line 1474 of file PRMFactory_tpl.h.
References _checkStack_(), _prm_, _stack_, gum::DiscreteVariable::domainSize(), GUM_ERROR, gum::Variable::name(), and gum::prm::PRMObject::TYPE.
Referenced by gum::prm::o3prm::O3TypeFactory< GUM_SCALAR >::_buildRealTypes_().
|
overridevirtual |
Tells the factory that we finished an interface declaration.
Implements gum::prm::IPRMFactory.
Definition at line 1506 of file PRMFactory_tpl.h.
References _checkStack_(), _stack_, and gum::prm::PRMObject::PRM_INTERFACE.
Referenced by gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateInterfaces_(), gum::prm::LayerGenerator< GUM_SCALAR >::_generateInterfaces_(), gum::prm::o3prm::O3InterfaceFactory< GUM_SCALAR >::buildElements(), and gum::prm::o3prm::O3InterfaceFactory< GUM_SCALAR >::buildInterfaces().
|
overridevirtual |
Tells the factory that we finished declaring a model.
| OperationNotAllowed | Raised if the given operation is illegal. |
Implements gum::prm::IPRMFactory.
Definition at line 1579 of file PRMFactory_tpl.h.
References _checkStack_(), _stack_, GUM_ERROR, gum::prm::PRMSystem< GUM_SCALAR >::instantiate(), and gum::prm::PRMObject::SYSTEM.
Referenced by gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateSystem_(), gum::prm::LayerGenerator< GUM_SCALAR >::_generateSystem_(), and gum::prm::o3prm::O3SystemFactory< GUM_SCALAR >::build().
|
overridevirtual |
Returns a pointer on the PRM<GUM_SCALAR> created by this factory.
This pointer will not be deleted when the factory is destroyed.
Implements gum::prm::IPRMFactory.
Definition at line 1344 of file PRMFactory_tpl.h.
|
overridevirtual |
| NotFound | if nothing is being built. |
Implements gum::prm::IPRMFactory.
Definition at line 1337 of file PRMFactory_tpl.h.
References _stack_, and GUM_ERROR.
Referenced by addNoisyOrCompound(), and isArrayInCurrentSystem().
|
overridevirtual |
Add an instance to an array.
Implements gum::prm::IPRMFactory.
Definition at line 876 of file PRMFactory_tpl.h.
References _checkStack_(), gum::prm::PRMSystem< GUM_SCALAR >::add(), gum::prm::PRMSystem< GUM_SCALAR >::get(), GUM_ERROR, gum::prm::PRMSystem< GUM_SCALAR >::isArray(), gum::prm::PRMSystem< GUM_SCALAR >::isInstance(), and gum::prm::PRMObject::SYSTEM.
|
overridevirtual |
Implements gum::prm::IPRMFactory.
Definition at line 1836 of file PRMFactory_tpl.h.
References getCurrent(), and gum::prm::PRMSystem< GUM_SCALAR >::isArray().
|
overridevirtual |
Implements gum::prm::IPRMFactory.
Definition at line 1817 of file PRMFactory_tpl.h.
References _retrieveClass_(), and _retrieveInterface_().
|
delete |
|
overridevirtual |
Pop the current package from the package stack.
Implements gum::prm::IPRMFactory.
Definition at line 1766 of file PRMFactory_tpl.h.
References _namespaces_, _packages_, and currentPackage().
| PRM< GUM_SCALAR > * gum::prm::PRMFactory< GUM_SCALAR >::prm | ( | ) | const |
Returns a pointer on the PRM<GUM_SCALAR> created by this factory.
This pointer will not be deleted when the factory is destroyed.
Definition at line 1325 of file PRMFactory_tpl.h.
References _prm_.
Referenced by PRMFactory(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::generate(), and gum::prm::LayerGenerator< GUM_SCALAR >::generate().
|
overridevirtual |
Define the current package.
A stack is used to keep track of packages given the different imports.
| name | The name of the package for all further objects. |
Implements gum::prm::IPRMFactory.
Definition at line 1760 of file PRMFactory_tpl.h.
References _namespaces_, and _packages_.
| PRMClass< GUM_SCALAR > & gum::prm::PRMFactory< GUM_SCALAR >::retrieveClass | ( | std::string_view | name | ) |
Returns a reference over a Class<GUM_SCALAR> given its name.
This methods adds if necessary the current package as a prefix to name.
| name | The name of the Class<GUM_SCALAR>. |
| NotFound | if no Class<GUM_SCALAR> matches the given name. |
Definition at line 1801 of file PRMFactory_tpl.h.
References _retrieveClass_().
Referenced by gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateClass_(), gum::prm::LayerGenerator< GUM_SCALAR >::_generateClasses_(), and gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateCluster_().
| PRMType & gum::prm::PRMFactory< GUM_SCALAR >::retrieveCommonType | ( | const std::vector< PRMClassElement< GUM_SCALAR > * > & | elts | ) |
Returns a pointer on the PRM<GUM_SCALAR> created by this factory.
This pointer will not be deleted when the factory is destroyed.
Definition at line 1811 of file PRMFactory_tpl.h.
References _retrieveCommonType_().
| PRMType & gum::prm::PRMFactory< GUM_SCALAR >::retrieveType | ( | std::string_view | name | ) |
Returns a reference over a PRMType given its name.
This methods adds if necessary the current package as a prefix to name.
| name | The name of the PRMType. |
Definition at line 1806 of file PRMFactory_tpl.h.
References _retrieveType_().
Referenced by addNoisyOrCompound().
|
overridevirtual |
Fills the CPF using a rule.
The labels vector is filled with one of each parent's labels or with a wildcard ("*"). If a wildcard is used then all values of the corresponding parents are used. The sequence of parents must be the declaration order used when adding the current attribute's parents.
| labels | The value of each parents. |
| values | The probability values of the current attribute given the values in parenst. |
Implements gum::prm::IPRMFactory.
Definition at line 388 of file PRMFactory_tpl.h.
References _checkStack_(), GUM_ERROR, gum::prm::PRMClassElement< GUM_SCALAR >::prm_attribute, and setCPFByRule().
|
virtual |
Fills the CPF using a rule.
The labels vector is filled with one of each parent's labels or with a wildcard ("*"). If a wildcard is used then all values of the corresponding parents are used. The sequence of parents must be the declaration order used when adding the current attribute's parents.
| labels | The value of each parents. |
| values | The probability values of the current attribute given the values in parents. |
Definition at line 406 of file PRMFactory_tpl.h.
References _checkStack_(), gum::Instantiation::chgVal(), gum::DiscreteVariable::domainSize(), gum::Instantiation::end(), GUM_ERROR, gum::Instantiation::incIn(), gum::DiscreteVariable::label(), gum::prm::PRMClassElement< GUM_SCALAR >::prm_attribute, gum::Instantiation::setFirstIn(), and gum::Instantiation::setVals().
Referenced by gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_completeAttribute_(), and setCPFByFloatRule().
|
overridevirtual |
Fills the CPF using a rule and gum::Formula.
The labels vector is filled with one of each parent's labels or with a wildcard ("*"). If a wildcard is used then all values of the corresponding parents are used. The sequence of parents must be the declaration order used when adding the current attribute's parents.
| labels | The value of each parents. |
| values | The probability values of the current attribute given the values in parents. |
Implements gum::prm::IPRMFactory.
Definition at line 470 of file PRMFactory_tpl.h.
References _checkStack_(), gum::Instantiation::chgVal(), gum::DiscreteVariable::domainSize(), gum::Instantiation::end(), GUM_ERROR, gum::Instantiation::incIn(), gum::DiscreteVariable::label(), gum::prm::PRMClassElement< GUM_SCALAR >::prm_attribute, gum::Instantiation::setFirstIn(), and gum::Instantiation::setVals().
| void gum::prm::PRMFactory< GUM_SCALAR >::setRawCPFByColumns | ( | const std::vector< GUM_SCALAR > & | array | ) |
Gives the factory the CPF in its raw form.
The creation of the CPF is left to the factory because we do not know what level of complexity for CPF implementation can be handled by the PRM<GUM_SCALAR> implementation.
How to fill a CPT? If you want to fill the CPT of P(A|B,C) with A, B and C boolean variables ( {f, t}, the order is important), then the following array is valid:
See PRMFactory::setRawCPFByLines() for more details.
| OperationNotAllowed | Raised if the given operation is illegal. |
Definition at line 357 of file PRMFactory_tpl.h.
References _checkStack_(), gum::Instantiation::add(), gum::prm::PRMAttribute< GUM_SCALAR >::cpf(), gum::Instantiation::end(), GUM_ERROR, gum::Instantiation::inc(), gum::prm::PRMClassElement< GUM_SCALAR >::prm_attribute, gum::Instantiation::setFirst(), setRawCPFByLines(), gum::Instantiation::setVals(), and gum::Instantiation::variablesSequence().
Referenced by gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_completeAttribute_(), and setRawCPFByFloatColumns().
|
overridevirtual |
Gives the factory the CPF in its raw form use gum::Formula.
The creation of the CPF is left to the factory because we do not know what level of complexity for CPF implementation can be handled by the PRM<GUM_SCALAR> implementation.
How to fill a CPT? If you want to fill the CPT of P(A|B,C) with A, B and C boolean variables ( {f, t}, the order is important), then the following array is valid:
See PRMFactory::setRawCPFByLines() for more details.
| OperationNotAllowed | Raised if the given operation is illegal. |
Implements gum::prm::IPRMFactory.
Definition at line 1843 of file PRMFactory_tpl.h.
References _checkStack_(), gum::Instantiation::add(), gum::prm::PRMObject::CLASS, gum::Instantiation::end(), GUM_ERROR, gum::Instantiation::inc(), gum::prm::PRMClassElement< GUM_SCALAR >::prm_attribute, gum::Instantiation::setFirst(), setRawCPFByLines(), gum::Instantiation::setVals(), and gum::Instantiation::variablesSequence().
|
overridevirtual |
Gives the factory the CPF in its raw form.
The creation of the CPF is left to the factory because we do not know what level of complexity for CPF implementation can be handled by the PRM<GUM_SCALAR> implementation.
How to fill a CPT? If you want to fill the CPT of P(A|B,C) with A, B and C boolean variables ( {f, t}, the order is important), then the following array is valid:
See PRMFactory::setRawCPFByLines() for more details.
| OperationNotAllowed | Raised if the given operation is illegal. |
Implements gum::prm::IPRMFactory.
Definition at line 344 of file PRMFactory_tpl.h.
References _checkStack_(), gum::prm::PRMAttribute< GUM_SCALAR >::cpf(), GUM_ERROR, gum::prm::PRMClassElement< GUM_SCALAR >::prm_attribute, and setRawCPFByColumns().
|
overridevirtual |
Gives the factory the CPF in its raw form.
The creation of the CPF is left to the factory because we do not know what level of complexity for CPF implementation can be handled by the PRM<GUM_SCALAR> implementation.
How to fill a CPT? If you want to fill the CPT of P(A|B,C) with A, B and C boolean variables ( {f, t}, the order is important), then the following array is valid:
| OperationNotAllowed | Raised if the given operation is illegal. |
Implements gum::prm::IPRMFactory.
Definition at line 319 of file PRMFactory_tpl.h.
References _checkStack_(), gum::prm::PRMObject::CLASS, gum::prm::PRMAttribute< GUM_SCALAR >::cpf(), GUM_ERROR, and gum::prm::PRMClassElement< GUM_SCALAR >::prm_attribute.
| void gum::prm::PRMFactory< GUM_SCALAR >::setRawCPFByLines | ( | const std::vector< GUM_SCALAR > & | array | ) |
Gives the factory the CPF in its raw form.
The creation of the CPF is left to the factory because we do not know what level of complexity for CPF implementation can be handled by the PRM<GUM_SCALAR> implementation.
How to fill a CPT? If you want to fill the CPT of P(A|B,C) with A, B and C boolean variables ( {f, t}, the order is important), then the following array is valid:
| OperationNotAllowed | Raised if the given operation is illegal. |
Definition at line 331 of file PRMFactory_tpl.h.
References _checkStack_(), gum::prm::PRMObject::CLASS, GUM_ERROR, and gum::prm::PRMClassElement< GUM_SCALAR >::prm_attribute.
Referenced by gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateClass_(), gum::prm::LayerGenerator< GUM_SCALAR >::_generateClasses_(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateCluster_(), setRawCPFByColumns(), and setRawCPFByColumns().
|
overridevirtual |
Gives the factory the CPF in its raw form using gum::Formula.
The creation of the CPF is left to the factory because we do not know what level of complexity for CPF implementation can be handled by the PRM<GUM_SCALAR> implementation.
How to fill a CPT? If you want to fill the CPT of P(A|B,C) with A, B and C boolean variables ( {f, t}, the order is important), then the following array is valid:
| OperationNotAllowed | Raised if the given operation is illegal. |
Implements gum::prm::IPRMFactory.
Definition at line 1879 of file PRMFactory_tpl.h.
References _checkStack_(), gum::prm::PRMObject::CLASS, gum::prm::PRMFormAttribute< GUM_SCALAR >::formulas(), GUM_ERROR, gum::MultiDimContainer< GUM_ELEMENT >::populate(), and gum::prm::PRMClassElement< GUM_SCALAR >::prm_attribute.
|
overridevirtual |
Instantiate a reference in the current model.
This is equivalent to the following SKOOL instruction: left_instance.left_reference = right_instance;
right_instance's type must be compatible with the slot type of left_reference.
| l_i | A slot chain starting from an instance and ending over a reference slot. |
| r_i | The name of an instance or an array of instances in the model. |
Implements gum::prm::IPRMFactory.
Definition at line 1791 of file PRMFactory_tpl.h.
References GUM_ERROR, and setReferenceSlot().
|
overridevirtual |
Instantiate a reference in the current model.
This is equivalent to the following SKOOL instruction: left_instance.left_reference = right_instance;
right_instance's type must be compatible with the slot type of left_reference.
| left_instance | The name of an instance in the model. |
| left_reference | The name of a reference of left_instance. |
| right_instance | The name of an instance or an array of instances in the model. |
Implements gum::prm::IPRMFactory.
Definition at line 892 of file PRMFactory_tpl.h.
References _checkStack_(), GUM_ERROR, gum::prm::PRMClassElement< GUM_SCALAR >::isReferenceSlot(), and gum::prm::PRMObject::SYSTEM.
Referenced by gum::prm::o3prm::O3SystemFactory< GUM_SCALAR >::_addAssignments_(), gum::prm::o3prm::O3SystemFactory< GUM_SCALAR >::_addIncrements_(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateSystem_(), gum::prm::LayerGenerator< GUM_SCALAR >::_generateSystem_(), and setReferenceSlot().
| void gum::prm::PRMFactory< GUM_SCALAR >::startAggregator | ( | std::string_view | name, |
| std::string_view | agg_type, | ||
| std::string_view | rv_type, | ||
| const std::vector< std::string > & | params ) |
Start an aggregator declaration.
| name | The aggregator's name. |
| agg_type | The aggregtor's type ( |
| rv_type | The aggregator's random variable type ( |
| params | The aggregator's parameters. |
Definition at line 556 of file PRMFactory_tpl.h.
References _checkStack_(), _retrieveType_(), _stack_, gum::prm::PRMClass< GUM_SCALAR >::add(), gum::prm::PRMObject::CLASS, gum::prm::PRMAggregate< GUM_SCALAR >::COUNT, gum::prm::PRMAggregate< GUM_SCALAR >::EXISTS, gum::prm::PRMAggregate< GUM_SCALAR >::FORALL, GUM_ERROR, gum::prm::PRMClass< GUM_SCALAR >::overload(), and gum::prm::PRMAggregate< GUM_SCALAR >::str2enum().
Referenced by gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_declareAggregates_().
|
overridevirtual |
Tells the factory that we start an attribute declaration.
| FatalError | Raised if the given operation is illegal. |
Implements gum::prm::IPRMFactory.
Definition at line 1519 of file PRMFactory_tpl.h.
References _checkStackContainter_(), _retrieveType_(), _stack_, gum::prm::PRMClassElementContainer< GUM_SCALAR >::add(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::exists(), gum::prm::PRMClassElement< GUM_SCALAR >::id(), gum::prm::PRMObject::isClass(), and gum::prm::PRMClassElementContainer< GUM_SCALAR >::overload().
Referenced by gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_declareAttribute_(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateClass_(), gum::prm::LayerGenerator< GUM_SCALAR >::_generateClasses_(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateCluster_(), and addAttribute().
|
overridevirtual |
Tells the factory that we start a class declaration.
Use the default values if you do not want c to be a subclass or to implement interfaces.
| c | The class name. |
| ext | The name of the super class of c. |
| implements | The list of interface implemented by c. |
| delayInheritance | If true, the created gum::prm::Class inheritance will be delayed. |
| OperationNotAllowed | Raised if the given operation is illegal. |
Implements gum::prm::IPRMFactory.
Definition at line 66 of file PRMFactory_tpl.h.
References _addPrefix_(), _prm_, _retrieveClass_(), _retrieveInterface_(), _stack_, gum::Set< Key >::empty(), GUM_ERROR, gum::Set< Key >::insert(), and gum::prm::PRMObject::name().
Referenced by gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateClass_(), gum::prm::LayerGenerator< GUM_SCALAR >::_generateClasses_(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateCluster_(), addInstance(), and gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::buildClasses().
|
overridevirtual |
Start a discrete subtype declaration.
| name | The discrete type's name. |
| super | The super type of the declared discrete type. |
| DuplicateElement | Raised if an object with the same name already exists. |
Implements gum::prm::IPRMFactory.
Definition at line 1367 of file PRMFactory_tpl.h.
References _addPrefix_(), _prm_, _retrieveType_(), _stack_, and GUM_ERROR.
Referenced by gum::prm::o3prm::O3TypeFactory< GUM_SCALAR >::_buildTypes_(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateType_(), and gum::prm::LayerGenerator< GUM_SCALAR >::_generateType_().
|
overridevirtual |
Start a discretized type declaration.
| name | The discretized type's name. |
| DuplicateElement | Raised if an object with the same name already exists. |
Implements gum::prm::IPRMFactory.
Definition at line 1449 of file PRMFactory_tpl.h.
References _addPrefix_(), _prm_, _stack_, and GUM_ERROR.
Referenced by gum::prm::o3prm::O3TypeFactory< GUM_SCALAR >::_buildRealTypes_().
|
overridevirtual |
Tells the factory that we start an interface declaration.
Use the default values if you do not want c to be a subclass or to implement interfaces.
| i | The interface name. |
| ext | The name of the super interface of i. |
| delayInheritance | If true, the created gum::prm::PRMInterface inheritance will be delayed. |
| NotFound | Raised if ext does not match any declared PRMInterface<GUM_SCALAR>. |
Implements gum::prm::IPRMFactory.
Definition at line 192 of file PRMFactory_tpl.h.
References _addPrefix_(), _prm_, _retrieveInterface_(), _stack_, GUM_ERROR, and gum::prm::PRMObject::name().
Referenced by gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateInterfaces_(), gum::prm::LayerGenerator< GUM_SCALAR >::_generateInterfaces_(), and gum::prm::o3prm::O3InterfaceFactory< GUM_SCALAR >::buildInterfaces().
|
overridevirtual |
Tells the factory that we started declaring a model.
| OperationNotAllowed | Raised if the given operation is illegal. |
Implements gum::prm::IPRMFactory.
Definition at line 1568 of file PRMFactory_tpl.h.
References _addPrefix_(), _prm_, _stack_, GUM_ERROR, and gum::prm::PRMObject::name().
Referenced by gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateSystem_(), gum::prm::LayerGenerator< GUM_SCALAR >::_generateSystem_(), and gum::prm::o3prm::O3SystemFactory< GUM_SCALAR >::build().
|
private |
A mapping between aggregators and their parameters.
Definition at line 1047 of file PRMFactory.h.
|
private |
Set of all declared namespaces.
Definition at line 1038 of file PRMFactory.h.
Referenced by ~PRMFactory(), _retrieveClass_(), _retrieveInterface_(), _retrieveType_(), addImport(), popPackage(), and pushPackage().
|
private |
The prefix used for classes and types names. It is normally the namespace of the corresponding compilation unit.
Definition at line 1035 of file PRMFactory.h.
Referenced by _addPrefix_(), addInstance(), currentPackage(), popPackage(), and pushPackage().
|
private |
The pointer on the PRM<GUM_SCALAR> built by this factory.
Definition at line 1041 of file PRMFactory.h.
Referenced by PRMFactory(), PRMFactory(), _retrieveClass_(), _retrieveInterface_(), _retrieveType_(), addRangeType(), continueClass(), continueInterface(), endDiscreteType(), endDiscretizedType(), prm(), startClass(), startDiscreteType(), startDiscretizedType(), startInterface(), and startSystem().
|
private |
A stack used to keep track of created PRMObject.
Definition at line 1044 of file PRMFactory.h.
Referenced by _checkStack_(), _checkStack_(), _checkStackContainter_(), closeCurrent(), continueAggregator(), continueAttribute(), continueClass(), continueInterface(), currentType(), endAggregator(), endAttribute(), endClass(), endDiscreteType(), endDiscretizedType(), endInterface(), endSystem(), getCurrent(), getCurrent(), startAggregator(), startAttribute(), startClass(), startDiscreteType(), startDiscretizedType(), startInterface(), and startSystem().