37 template <
typename GUM_SCALAR >
44 __o3_prm(&o3_prm), __solver(&solver), __errors(&errors) {
48 template <
typename GUM_SCALAR >
56 template <
typename GUM_SCALAR >
65 template <
typename GUM_SCALAR >
70 template <
typename GUM_SCALAR >
74 if (
this == &src) {
return *
this; }
82 template <
typename GUM_SCALAR >
86 if (
this == &src) {
return *
this; }
87 __prm = std::move(src.__prm);
94 template <
typename GUM_SCALAR >
101 if (
__solver->resolveInterface(i->superLabel())) {
103 i->name().label(), i->superLabel().label(),
true);
110 template <
typename GUM_SCALAR >
115 template <
typename GUM_SCALAR >
127 O3PRM_INTERFACE_DUPLICATE(i->name(), *
__errors);
134 template <
typename GUM_SCALAR >
138 if (i->superLabel().label() !=
"") {
139 if (!
__solver->resolveInterface(i->superLabel())) {
return false; }
141 auto head =
__nameMap[i->superLabel().label()];
142 auto tail =
__nameMap[i->name().label()];
149 O3PRM_INTERFACE_CYCLIC_INHERITANCE(
150 i->name(), i->superLabel(), *
__errors);
158 template <
typename GUM_SCALAR >
162 for (
auto id = topo_order.rbegin();
id != topo_order.rend(); --id) {
167 template <
typename GUM_SCALAR >
172 __prm->getInterface(i->name().label()).inheritInterface();
176 for (
auto& elt: i->elements()) {
179 if (
__prm->isType(elt.type().label())) {
180 factory.
addAttribute(elt.type().label(), elt.name().label());
183 elt.type().label(), elt.name().label(), elt.isArray());
188 O3PRM_INTERFACE_DUPLICATE_ELEMENT(elt, *
__errors);
196 template <
typename GUM_SCALAR >
199 if (!
__solver->resolveClassElement(elt.
type())) {
return false; }
217 template <
typename GUM_SCALAR >
221 const auto& real_elt = real_i.get(elt.
name().
label());
234 template <
typename GUM_SCALAR >
239 const auto& real_elt = real_i.get(elt.
name().
label());
242 const auto& super_type = real_elt.type();
244 if (!sub_type.isSubTypeOf(super_type)) {
245 O3PRM_INTERFACE_ILLEGAL_OVERLOAD(elt, *
__errors);
249 if (sub_type.name() == super_type.name()) {
250 O3PRM_INTERFACE_DUPLICATE_ELEMENT(elt, *
__errors);
257 template <
typename GUM_SCALAR >
262 const auto& real_elt =
274 auto super_type = &(real_elt.slotType());
276 if (!sub_type->isSubTypeOf(*super_type)) {
277 O3PRM_INTERFACE_ILLEGAL_OVERLOAD(elt, *
__errors);
281 if (sub_type->name() == super_type->name()) {
282 O3PRM_INTERFACE_DUPLICATE_ELEMENT(elt, *
__errors);
289 template <
typename GUM_SCALAR >
304 if (&real_i == ref_type) {
305 O3PRM_INTERFACE_SELF_REFERENCE(i, elt, *
__errors);
309 if (ref_type->isSubTypeOf(real_i)) {
310 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)
Copyright 2005-2020 Pierre-Henri WUILLEMIN () et Christophe GONZALES () info_at_agrum_dot_org.
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
Copyright 2005-2020 Pierre-Henri WUILLEMIN () et Christophe GONZALES () info_at_agrum_dot_org.
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