57 template <
typename GUM_SCALAR >
67 template <
typename GUM_SCALAR >
74 template <
typename GUM_SCALAR >
82 template <
typename GUM_SCALAR >
87 template <
typename GUM_SCALAR >
90 if (
this == &src) {
return *
this; }
98 template <
typename GUM_SCALAR >
101 if (
this == &src) {
return *
this; }
102 _prm_ = std::move(src._prm_);
109 template <
typename GUM_SCALAR >
116 if (
_solver_->resolveInterface(i->superLabel())) {
117 factory.
startInterface(i->name().label(), i->superLabel().label(),
true);
124 template <
typename GUM_SCALAR >
129 template <
typename GUM_SCALAR >
132 for (
auto& i:
_o3_prm_->interfaces()) {
133 auto id =
_dag_.addNode();
141 O3PRM_INTERFACE_DUPLICATE(i->name(), *
_errors_);
148 template <
typename GUM_SCALAR >
151 for (
auto& i:
_o3_prm_->interfaces()) {
152 if (i->superLabel().label() !=
"") {
153 if (!
_solver_->resolveInterface(i->superLabel())) {
return false; }
155 auto head =
_nameMap_[i->superLabel().label()];
156 auto tail =
_nameMap_[i->name().label()];
159 _dag_.addArc(tail, head);
163 O3PRM_INTERFACE_CYCLIC_INHERITANCE(i->name(), i->superLabel(), *
_errors_);
171 template <
typename GUM_SCALAR >
173 auto topo_order =
_dag_.topologicalOrder();
174 for (
auto id = topo_order.rbegin();
id != topo_order.rend(); --
id) {
179 template <
typename GUM_SCALAR >
184 _prm_->getInterface(i->name().label()).inheritInterface();
188 for (
auto& elt: i->elements()) {
191 if (
_prm_->isType(elt.type().label())) {
192 factory.
addAttribute(elt.type().label(), elt.name().label());
194 factory.
addReferenceSlot(elt.type().label(), elt.name().label(), elt.isArray());
199 O3PRM_INTERFACE_DUPLICATE_ELEMENT(elt, *
_errors_);
207 template <
typename GUM_SCALAR >
211 if (!
_solver_->resolveClassElement(elt.
type())) {
return false; }
229 template <
typename GUM_SCALAR >
234 const auto& real_elt = real_i.get(elt.
name().
label());
247 template <
typename GUM_SCALAR >
252 const auto& real_elt = real_i.get(elt.
name().
label());
255 const auto& super_type = real_elt.type();
257 if (!sub_type.isSubTypeOf(super_type)) {
258 O3PRM_INTERFACE_ILLEGAL_OVERLOAD(elt, *
_errors_);
262 if (sub_type.name() == super_type.name()) {
263 O3PRM_INTERFACE_DUPLICATE_ELEMENT(elt, *
_errors_);
270 template <
typename GUM_SCALAR >
286 auto super_type = &(real_elt.slotType());
288 if (!sub_type->isSubTypeOf(*super_type)) {
289 O3PRM_INTERFACE_ILLEGAL_OVERLOAD(elt, *
_errors_);
293 if (sub_type->name() == super_type->name()) {
294 O3PRM_INTERFACE_DUPLICATE_ELEMENT(elt, *
_errors_);
301 template <
typename GUM_SCALAR >
316 if (&real_i == ref_type) {
317 O3PRM_INTERFACE_SELF_REFERENCE(i, elt, *
_errors_);
321 if (ref_type->isSubTypeOf(real_i)) {
322 O3PRM_INTERFACE_ILLEGAL_SUB_REFERENCE(i, elt, *
_errors_);
Headers for the O3InterfaceFactory class.
Exception : a similar element already exists.
This class is used contain and manipulate gum::ParseError.
Exception : existence of a directed cycle in a graph.
Exception : operation not allowed.
<agrum/PRM/classElementContainer.h>
static INLINE bool isReferenceSlot(const PRMClassElement< GUM_SCALAR > &elt)
Returns true if obj_ptr is of type PRMReferenceSlot.
static INLINE bool isAttribute(const PRMClassElement< GUM_SCALAR > &elt)
Returns true if obj_ptr is of type PRMAttribute.
Factory which builds a PRM<GUM_SCALAR>.
virtual void addReferenceSlot(const std::string &type, const std::string &name, bool isArray) override
Tells the factory that we started declaring a slot.
virtual void addAttribute(const std::string &type, const std::string &name) override
Add an attribute to an interface.
virtual void endInterface() override
Tells the factory that we finished an interface declaration.
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 continueInterface(const std::string &name) override
Continue the declaration of an interface.
A PRMReferenceSlot represent a relation between two PRMClassElementContainer.
This class represents a Probabilistic Relational PRMSystem<GUM_SCALAR>.
The O3InterfaceElement is part of the AST of the O3PRM language.
Bulds gum::prm:PRMInterface from gum::prm::o3prm::O3Interface.
HashTable< std::string, O3Interface * > _interfaceMap_
void _setO3InterfaceCreationOrder_()
HashTable< std::string, gum::NodeId > _nameMap_
bool _checkAttributeOverloadLegality_(O3Interface &i, O3InterfaceElement &elt)
O3InterfaceFactory(PRM< GUM_SCALAR > &prm, O3PRM &o3_prm, O3NameSolver< GUM_SCALAR > &solver, ErrorsContainer &errors)
PRM< GUM_SCALAR > * _prm_
O3InterfaceFactory< GUM_SCALAR > & operator=(const O3InterfaceFactory< GUM_SCALAR > &src)
bool _checkOverloadLegality_(O3Interface &i, O3InterfaceElement &elt)
bool _checkInterfaceElement_(O3Interface &i, O3InterfaceElement &elt)
std::vector< O3Interface * > _o3Interface_
bool _checkCyclicReference_(O3Interface &i, O3InterfaceElement &elt)
bool _checkReferenceOverloadLegality_(O3Interface &i, O3InterfaceElement &elt)
O3NameSolver< GUM_SCALAR > * _solver_
ErrorsContainer * _errors_
bool _addInterface2Dag_()
HashTable< NodeId, O3Interface * > _nodeMap_
bool _checkO3Interfaces_()
The O3Interface is part of the AST of the O3PRM language.
Resolves names for the different O3PRM factories.
The O3PRM is part of the AST of the O3PRM language.
namespace for all probabilistic relational models entities
gum is the global namespace for all aGrUM entities