58 template < GUM_Numeric GUM_SCALAR >
67 template < GUM_Numeric GUM_SCALAR >
74 template < GUM_Numeric GUM_SCALAR >
81 template < GUM_Numeric GUM_SCALAR >
86 template < GUM_Numeric GUM_SCALAR >
89 if (
this == &src) {
return *
this; }
97 template < GUM_Numeric GUM_SCALAR >
100 if (
this == &src) {
return *
this; }
101 _prm_ = std::move(src._prm_);
108 template < GUM_Numeric GUM_SCALAR >
115 if (
_solver_->resolveInterface(i->superLabel())) {
116 factory.
startInterface(i->name().label(), i->superLabel().label(),
true);
123 template < GUM_Numeric GUM_SCALAR >
128 template < GUM_Numeric GUM_SCALAR >
131 for (
auto& i:
_o3_prm_->interfaces()) {
132 auto id =
_dag_.addNode();
140 O3PRM_INTERFACE_DUPLICATE(i->name(), *
_errors_);
147 template < GUM_Numeric GUM_SCALAR >
150 for (
auto& i:
_o3_prm_->interfaces()) {
151 if (i->superLabel().label() !=
"") {
152 if (!
_solver_->resolveInterface(i->superLabel())) {
return false; }
154 auto head =
_nameMap_[i->superLabel().label()];
155 auto tail =
_nameMap_[i->name().label()];
158 _dag_.addArc(tail, head);
162 O3PRM_INTERFACE_CYCLIC_INHERITANCE(i->name(), i->superLabel(), *
_errors_);
170 template < GUM_Numeric GUM_SCALAR >
172 auto topo_order =
_dag_.topologicalOrder();
173 for (
auto id = topo_order.rbegin();
id != topo_order.rend(); --
id) {
178 template < GUM_Numeric GUM_SCALAR >
183 _prm_->getInterface(i->name().label()).inheritInterface();
187 for (
auto& elt: i->elements()) {
190 if (
_prm_->isType(elt.type().label())) {
191 factory.
addAttribute(elt.type().label(), elt.name().label());
193 factory.
addReferenceSlot(elt.type().label(), elt.name().label(), elt.isArray());
198 O3PRM_INTERFACE_DUPLICATE_ELEMENT(elt, *
_errors_);
206 template < GUM_Numeric GUM_SCALAR >
209 if (!
_solver_->resolveClassElement(elt.
type())) {
return false; }
227 template < GUM_Numeric GUM_SCALAR >
231 const auto& real_elt = real_i.get(elt.
name().
label());
244 template < GUM_Numeric GUM_SCALAR >
249 const auto& real_elt = real_i.get(elt.
name().
label());
252 const auto& super_type = real_elt.type();
254 if (!sub_type.isSubTypeOf(super_type)) {
255 O3PRM_INTERFACE_ILLEGAL_OVERLOAD(elt, *
_errors_);
259 if (sub_type.name() == super_type.name()) {
260 O3PRM_INTERFACE_DUPLICATE_ELEMENT(elt, *
_errors_);
267 template < GUM_Numeric GUM_SCALAR >
283 auto super_type = &(real_elt.slotType());
285 if (!sub_type->isSubTypeOf(*super_type)) {
286 O3PRM_INTERFACE_ILLEGAL_OVERLOAD(elt, *
_errors_);
290 if (sub_type->name() == super_type->name()) {
291 O3PRM_INTERFACE_DUPLICATE_ELEMENT(elt, *
_errors_);
298 template < GUM_Numeric GUM_SCALAR >
312 if (&real_i == ref_type) {
313 O3PRM_INTERFACE_SELF_REFERENCE(i, elt, *
_errors_);
317 if (ref_type->isSubTypeOf(real_i)) {
318 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>.
void addReferenceSlot(std::string_view type, std::string_view name, bool isArray) override
Tells the factory that we started declaring a slot.
void endInterface() override
Tells the factory that we finished an interface declaration.
void startInterface(std::string_view i, std::string_view ext="", bool delayInheritance=false) override
Tells the factory that we start an interface declaration.
void addAttribute(std::string_view type, std::string_view name) override
Add an attribute to an interface.
void continueInterface(std::string_view 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.
O3InterfaceFactory< GUM_SCALAR > & operator=(const O3InterfaceFactory< GUM_SCALAR > &src)
HashTable< std::string, O3Interface * > _interfaceMap_
bool _checkOverloadLegality_(O3Interface &i, O3InterfaceElement &elt)
bool _checkInterfaceElement_(O3Interface &i, O3InterfaceElement &elt)
HashTable< std::string, gum::NodeId > _nameMap_
bool _checkAttributeOverloadLegality_(O3Interface &i, O3InterfaceElement &elt)
PRM< GUM_SCALAR > * _prm_
bool _checkO3Interfaces_()
bool _checkCyclicReference_(O3Interface &i, O3InterfaceElement &elt)
std::vector< O3Interface * > _o3Interface_
O3InterfaceFactory(PRM< GUM_SCALAR > &prm, O3PRM &o3_prm, O3NameSolver< GUM_SCALAR > &solver, ErrorsContainer &errors)
bool _addInterface2Dag_()
O3NameSolver< GUM_SCALAR > * _solver_
ErrorsContainer * _errors_
bool _checkReferenceOverloadLegality_(O3Interface &i, O3InterfaceElement &elt)
void _setO3InterfaceCreationOrder_()
HashTable< NodeId, O3Interface * > _nodeMap_
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