35 template <
typename GUM_SCALAR >
42 __o3_prm(&o3_prm), __solver(&solver), __errors(&errors) {
46 template <
typename GUM_SCALAR >
54 template <
typename GUM_SCALAR >
63 template <
typename GUM_SCALAR >
68 template <
typename GUM_SCALAR >
71 if (
this == &src) {
return *
this; }
79 template <
typename GUM_SCALAR >
82 if (
this == &src) {
return *
this; }
83 __prm = std::move(src.__prm);
90 template <
typename GUM_SCALAR >
97 if (
__solver->resolveInterface(i->superLabel())) {
99 i->name().label(), i->superLabel().label(),
true);
106 template <
typename GUM_SCALAR >
111 template <
typename GUM_SCALAR >
123 O3PRM_INTERFACE_DUPLICATE(i->name(), *
__errors);
130 template <
typename GUM_SCALAR >
134 if (i->superLabel().label() !=
"") {
135 if (!
__solver->resolveInterface(i->superLabel())) {
return false; }
137 auto head =
__nameMap[i->superLabel().label()];
138 auto tail =
__nameMap[i->name().label()];
145 O3PRM_INTERFACE_CYCLIC_INHERITANCE(
146 i->name(), i->superLabel(), *
__errors);
154 template <
typename GUM_SCALAR >
158 for (
auto id = topo_order.rbegin();
id != topo_order.rend(); --id) {
163 template <
typename GUM_SCALAR >
168 __prm->getInterface(i->name().label()).inheritInterface();
172 for (
auto& elt : i->elements()) {
175 if (
__prm->isType(elt.type().label())) {
176 factory.
addAttribute(elt.type().label(), elt.name().label());
179 elt.type().label(), elt.name().label(), elt.isArray());
184 O3PRM_INTERFACE_DUPLICATE_ELEMENT(elt, *
__errors);
192 template <
typename GUM_SCALAR >
195 if (!
__solver->resolveClassElement(elt.
type())) {
return false; }
213 template <
typename GUM_SCALAR >
217 const auto& real_elt = real_i.get(elt.
name().
label());
230 template <
typename GUM_SCALAR >
235 const auto& real_elt = real_i.get(elt.
name().
label());
238 const auto& super_type = real_elt.type();
240 if (!sub_type.isSubTypeOf(super_type)) {
241 O3PRM_INTERFACE_ILLEGAL_OVERLOAD(elt, *
__errors);
245 if (sub_type.name() == super_type.name()) {
246 O3PRM_INTERFACE_DUPLICATE_ELEMENT(elt, *
__errors);
253 template <
typename GUM_SCALAR >
258 const auto& real_elt =
270 auto super_type = &(real_elt.slotType());
272 if (!sub_type->isSubTypeOf(*super_type)) {
273 O3PRM_INTERFACE_ILLEGAL_OVERLOAD(elt, *
__errors);
277 if (sub_type->name() == super_type->name()) {
278 O3PRM_INTERFACE_DUPLICATE_ELEMENT(elt, *
__errors);
285 template <
typename GUM_SCALAR >
300 if (&real_i == ref_type) {
301 O3PRM_INTERFACE_SELF_REFERENCE(i, elt, *
__errors);
305 if (ref_type->isSubTypeOf(real_i)) {
306 O3PRM_INTERFACE_ILLEGAL_SUB_REFERENCE(i, elt, *
__errors);
void __setO3InterfaceCreationOrder()
virtual void endInterface() override
Tells the factory that we finished an interface declaration.
bool __checkReferenceOverloadLegality(O3Interface &i, O3InterfaceElement &elt)
bool __checkAttributeOverloadLegality(O3Interface &i, O3InterfaceElement &elt)
O3InterfaceFactory(PRM< GUM_SCALAR > &prm, O3PRM &o3_prm, O3NameSolver< GUM_SCALAR > &solver, ErrorsContainer &errors)
virtual void continueInterface(const std::string &name) override
Continue the declaration of an interface.
Abstract class representing an element of PRM class.
virtual void startInterface(const std::string &i, const std::string &ext="", bool delayInheritance=false) override
Tells the factory that we start an interface declaration.
virtual void addReferenceSlot(const std::string &type, const std::string &name, bool isArray) override
Tells the factory that we started declaring a slot.
This class is used contain and manipulate gum::ParseError.
bool __checkOverloadLegality(O3Interface &i, O3InterfaceElement &elt)
gum is the global namespace for all aGrUM entities
O3InterfaceFactory< GUM_SCALAR > & operator=(const O3InterfaceFactory< GUM_SCALAR > &src)
HashTable< NodeId, O3Interface *> __nodeMap
virtual void addAttribute(const std::string &type, const std::string &name) override
Add an attribute to an interface.
virtual NodeId addNode()
insert a new node and return its id
A PRMReferenceSlot represent a relation between two PRMClassElementContainer.
O3NameSolver< GUM_SCALAR > * __solver
PRM< GUM_SCALAR > * __prm
Bulds gum::prm:PRMInterface from gum::prm::o3prm::O3Interface.
Resolves names for the different O3PRM factories.
bool __checkO3Interfaces()
bool __addInterface2Dag()
Factory which builds a PRM<GUM_SCALAR>.
ErrorsContainer * __errors
virtual void addArc(const NodeId tail, const NodeId head)
insert a new arc into the directed graph
Headers for the O3InterfaceFactory class.
const Sequence< NodeId > & topologicalOrder(bool clear=true) const
The topological order stays the same as long as no variable or arcs are added or erased src the topol...
O3InterfaceList & interfaces()
This class represents a Probabilistic Relational PRMSystem<GUM_SCALAR>.
<agrum/PRM/classElementContainer.h>
HashTable< std::string, gum::NodeId > __nameMap
bool __checkCyclicReference(O3Interface &i, O3InterfaceElement &elt)
HashTable< std::string, O3Interface *> __interfaceMap
The O3InterfaceElement is part of the AST of the O3PRM language.
The O3PRM is part of the AST of the O3PRM language.
bool __checkInterfaceElement(O3Interface &i, O3InterfaceElement &elt)
value_type & insert(const Key &key, const Val &val)
Adds a new element (actually a copy of this element) into the hash table.
The O3Interface is part of the AST of the O3PRM language.
std::vector< O3Interface *> __o3Interface