aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
IPRMFactory.h
Go to the documentation of this file.
1/****************************************************************************
2 * This file is part of the aGrUM/pyAgrum library. *
3 * *
4 * Copyright (c) 2005-2025 by *
5 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
6 * - Christophe GONZALES(_at_AMU) *
7 * *
8 * The aGrUM/pyAgrum library is free software; you can redistribute it *
9 * and/or modify it under the terms of either : *
10 * *
11 * - the GNU Lesser General Public License as published by *
12 * the Free Software Foundation, either version 3 of the License, *
13 * or (at your option) any later version, *
14 * - the MIT license (MIT), *
15 * - or both in dual license, as here. *
16 * *
17 * (see https://agrum.gitlab.io/articles/dual-licenses-lgplv3mit.html) *
18 * *
19 * This aGrUM/pyAgrum library is distributed in the hope that it will be *
20 * useful, but WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
21 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES MERCHANTABILITY or FITNESS *
22 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
25 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
26 * OTHER DEALINGS IN THE SOFTWARE. *
27 * *
28 * See LICENCES for more details. *
29 * *
30 * SPDX-FileCopyrightText: Copyright 2005-2025 *
31 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
32 * - Christophe GONZALES(_at_AMU) *
33 * SPDX-License-Identifier: LGPL-3.0-or-later OR MIT *
34 * *
35 * Contact : info_at_agrum_dot_org *
36 * homepage : http://agrum.gitlab.io *
37 * gitlab : https://gitlab.com/agrumery/agrum *
38 * *
39 ****************************************************************************/
40
41
48
49#ifndef GUM_IPRM_FACTORY_H
50#define GUM_IPRM_FACTORY_H
51
52#include <iostream>
53#include <limits>
54#include <sstream>
55#include <string>
56#include <vector>
57
58#include <agrum/agrum.h>
59
60#include <agrum/PRM/PRM.h>
61
62namespace gum {
63
64 namespace prm {
71 struct IPRMFactory {
72 virtual ~IPRMFactory() {};
73
74 // virtual PRM<GUM_SCALAR>* prm() const=0;
75 virtual PRMObject::prm_type currentType() const = 0;
76 virtual PRMObject* getCurrent() = 0;
77 virtual const PRMObject* getCurrent() const = 0;
78 virtual PRMObject* closeCurrent() = 0;
79 virtual std::string currentPackage() const = 0;
80 // Class<GUM_SCALAR>& retrieveClass ( const std::string& name )=0;
81 // PRMType& retrieveType ( const std::string& name )=0;
82 // PRMType& retrieveCommonType ( const
83 // std::vector<PRMClassElement<GUM_SCALAR>*>& elts )=0;
84 virtual void pushPackage(const std::string& name) = 0;
85 virtual std::string popPackage() = 0;
86 virtual void addImport(const std::string& name) = 0;
87 virtual void startDiscreteType(const std::string& name, std::string super = "") = 0;
88 virtual void addLabel(const std::string& l, std::string extends = "") = 0;
89 virtual void endDiscreteType() = 0;
90 virtual void startDiscretizedType(const std::string& name) = 0;
91 virtual void addTick(double tick) = 0;
92 virtual void endDiscretizedType() = 0;
93 virtual void addRangeType(const std::string& name, long minVal, long maxVal) = 0;
94 virtual void startClass(const std::string& c,
95 const std::string& extends = "",
96 const Set< std::string >* implements = nullptr,
97 bool delayInheritance = false)
98 = 0;
99 virtual void continueClass(const std::string& c) = 0;
100 virtual void endClass(bool checkImplementations = true) = 0;
101 virtual void startInterface(const std::string& i,
102 const std::string& extends = "",
103 bool delayInheritance = false)
104 = 0;
105 virtual void continueInterface(const std::string& name) = 0;
106 virtual void addAttribute(const std::string& type, const std::string& name) = 0;
107 virtual void endInterface() = 0;
108 // virtual void addAttribute ( PRMAttribute<GUM_SCALAR>* attr ) =0;
109 virtual void
110 startAttribute(const std::string& type, const std::string& name, bool scalar_attr = false)
111 = 0;
112 virtual void continueAttribute(const std::string& name) = 0;
113 virtual void addParent(const std::string& name) = 0;
114 virtual void setRawCPFByFloatLines(const std::vector< float >& array) = 0;
115 virtual void setRawCPFByFloatColumns(const std::vector< float >& array) = 0;
116 virtual void setCPFByFloatRule(const std::vector< std::string >& labels,
117 const std::vector< float >& values)
118 = 0;
119 virtual void setCPFByRule(const std::vector< std::string >& labels,
120 const std::vector< std::string >& values)
121 = 0;
122 virtual void setRawCPFByColumns(const std::vector< std::string >& array) = 0;
123 virtual void setRawCPFByLines(const std::vector< std::string >& array) = 0;
124 virtual void endAttribute() = 0;
125 virtual void addParameter(const std::string& type, const std::string& name, double value) = 0;
126 virtual void addAggregator(const std::string& name,
127 const std::string& agg_type,
128 const std::vector< std::string >& chains,
129 const std::vector< std::string >& params,
130 std::string type = "")
131 = 0;
132 virtual void addNoisyOrCompound(const std::string& name,
133 const std::vector< std::string >& chains,
134 const std::vector< float >& numbers,
135 float leak,
136 const std::vector< std::string >& label)
137 = 0;
138 virtual void addReferenceSlot(const std::string& type, const std::string& name, bool isArray)
139 = 0;
140 virtual void startSystem(const std::string& name) = 0;
141 virtual void endSystem() = 0;
142 virtual void addInstance(const std::string& type, const std::string& name) = 0;
143 virtual void addInstance(const std::string& type,
144 const std::string& name,
146 = 0;
147 virtual void addArray(const std::string& type, const std::string& name, Size size) = 0;
148 virtual void incArray(const std::string& l_i, const std::string& r_i) = 0;
149 virtual void setReferenceSlot(const std::string& left_instance,
150 const std::string& left_reference,
151 const std::string& right_instance)
152 = 0;
153 virtual void setReferenceSlot(const std::string& l_i, const std::string& r_i) = 0;
154
155 virtual bool isClassOrInterface(const std::string& type) const = 0;
156 virtual bool isArrayInCurrentSystem(const std::string& name) const = 0;
157 };
158 } /* namespace prm */
159} /* namespace gum */
160
161#endif /* GUM_IPRM_FACTORY_H */
Headers of PRM.
Abstract base class for any element defined in a PRM.
Definition PRMObject.h:75
prm_type
Enumeration of the different types of objects handled by a PRM.
Definition PRMObject.h:88
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition types.h:74
namespace for all probabilistic relational models entities
Definition agrum.h:68
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
non-template interface-like parent for every PRM Factory
Definition IPRMFactory.h:71
virtual void addImport(const std::string &name)=0
virtual void continueAttribute(const std::string &name)=0
virtual void continueClass(const std::string &c)=0
virtual void setRawCPFByFloatColumns(const std::vector< float > &array)=0
virtual bool isClassOrInterface(const std::string &type) const =0
virtual void setCPFByFloatRule(const std::vector< std::string > &labels, const std::vector< float > &values)=0
virtual void setReferenceSlot(const std::string &l_i, const std::string &r_i)=0
virtual void endAttribute()=0
virtual void addRangeType(const std::string &name, long minVal, long maxVal)=0
virtual void startAttribute(const std::string &type, const std::string &name, bool scalar_attr=false)=0
virtual void addTick(double tick)=0
virtual void startClass(const std::string &c, const std::string &extends="", const Set< std::string > *implements=nullptr, bool delayInheritance=false)=0
virtual void addParameter(const std::string &type, const std::string &name, double value)=0
virtual void startInterface(const std::string &i, const std::string &extends="", bool delayInheritance=false)=0
virtual void endDiscretizedType()=0
virtual void setRawCPFByColumns(const std::vector< std::string > &array)=0
virtual const PRMObject * getCurrent() const =0
virtual void addInstance(const std::string &type, const std::string &name)=0
virtual void setRawCPFByFloatLines(const std::vector< float > &array)=0
virtual void continueInterface(const std::string &name)=0
virtual std::string currentPackage() const =0
virtual void setCPFByRule(const std::vector< std::string > &labels, const std::vector< std::string > &values)=0
virtual void addArray(const std::string &type, const std::string &name, Size size)=0
virtual void endInterface()=0
virtual void addInstance(const std::string &type, const std::string &name, const HashTable< std::string, double > &params)=0
virtual void startSystem(const std::string &name)=0
virtual void incArray(const std::string &l_i, const std::string &r_i)=0
virtual PRMObject * getCurrent()=0
virtual void addReferenceSlot(const std::string &type, const std::string &name, bool isArray)=0
virtual void endClass(bool checkImplementations=true)=0
virtual std::string popPackage()=0
virtual PRMObject * closeCurrent()=0
virtual void startDiscretizedType(const std::string &name)=0
virtual void addParent(const std::string &name)=0
virtual void addAggregator(const std::string &name, const std::string &agg_type, const std::vector< std::string > &chains, const std::vector< std::string > &params, std::string type="")=0
virtual void addAttribute(const std::string &type, const std::string &name)=0
virtual void addLabel(const std::string &l, std::string extends="")=0
virtual bool isArrayInCurrentSystem(const std::string &name) const =0
virtual void addNoisyOrCompound(const std::string &name, const std::vector< std::string > &chains, const std::vector< float > &numbers, float leak, const std::vector< std::string > &label)=0
virtual void endDiscreteType()=0
virtual void startDiscreteType(const std::string &name, std::string super="")=0
virtual void setRawCPFByLines(const std::vector< std::string > &array)=0
virtual void endSystem()=0
virtual void setReferenceSlot(const std::string &left_instance, const std::string &left_reference, const std::string &right_instance)=0
virtual PRMObject::prm_type currentType() const =0
virtual void pushPackage(const std::string &name)=0