aGrUM 3.1.1
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-2026 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-2026 *
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
62#include <string_view>
63
64namespace gum {
65
66 namespace prm {
73 struct IPRMFactory {
74 virtual ~IPRMFactory() = default;
75
76 // virtual PRM<GUM_SCALAR>* prm() const=0;
77 virtual PRMObject::prm_type currentType() const = 0;
78 virtual PRMObject* getCurrent() = 0;
79 virtual const PRMObject* getCurrent() const = 0;
80 virtual PRMObject* closeCurrent() = 0;
81 virtual std::string currentPackage() const = 0;
82 // Class<GUM_SCALAR>& retrieveClass ( const std::string& name )=0;
83 // PRMType& retrieveType ( const std::string& name )=0;
84 // PRMType& retrieveCommonType ( const
85 // std::vector<PRMClassElement<GUM_SCALAR>*>& elts )=0;
86 virtual void pushPackage(std::string_view name) = 0;
87 virtual std::string popPackage() = 0;
88 virtual void addImport(std::string_view name) = 0;
89 virtual void startDiscreteType(std::string_view name, std::string_view super = "") = 0;
90 virtual void addLabel(std::string_view l, std::string_view extends = "") = 0;
91 virtual void endDiscreteType() = 0;
92 virtual void startDiscretizedType(std::string_view name) = 0;
93 virtual void addTick(double tick) = 0;
94 virtual void endDiscretizedType() = 0;
95 virtual void addRangeType(std::string_view name, long minVal, long maxVal) = 0;
96 virtual void startClass(std::string_view c,
97 std::string_view extends = "",
98 const Set< std::string >* implements = nullptr,
99 bool delayInheritance = false) = 0;
100 virtual void continueClass(std::string_view c) = 0;
101 virtual void endClass(bool checkImplementations = true) = 0;
102 virtual void startInterface(std::string_view i,
103 std::string_view extends = "",
104 bool delayInheritance = false) = 0;
105 virtual void continueInterface(std::string_view name) = 0;
106 virtual void addAttribute(std::string_view type, std::string_view name) = 0;
107 virtual void endInterface() = 0;
108 // virtual void addAttribute ( PRMAttribute<GUM_SCALAR>* attr ) =0;
109 virtual void startAttribute(std::string_view type,
110 std::string_view name,
111 bool scalar_attr = false) = 0;
112 virtual void continueAttribute(std::string_view name) = 0;
113 virtual void addParent(std::string_view 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) = 0;
118 virtual void setCPFByRule(const std::vector< std::string >& labels,
119 const std::vector< std::string >& values) = 0;
120 virtual void setRawCPFByColumns(const std::vector< std::string >& array) = 0;
121 virtual void setRawCPFByLines(const std::vector< std::string >& array) = 0;
122 virtual void endAttribute() = 0;
123 virtual void addParameter(std::string_view type, std::string_view name, double value) = 0;
124 virtual void addAggregator(std::string_view name,
125 std::string_view agg_type,
126 const std::vector< std::string >& chains,
127 const std::vector< std::string >& params,
128 std::string_view type = "") = 0;
129 virtual void addNoisyOrCompound(std::string_view name,
130 const std::vector< std::string >& chains,
131 const std::vector< float >& numbers,
132 float leak,
133 const std::vector< std::string >& label) = 0;
134 virtual void addReferenceSlot(std::string_view type, std::string_view name, bool isArray) = 0;
135 virtual void startSystem(std::string_view name) = 0;
136 virtual void endSystem() = 0;
137 virtual void addInstance(std::string_view type, std::string_view name) = 0;
138 virtual void addInstance(std::string_view type,
139 std::string_view name,
140 const HashTable< std::string, double >& params) = 0;
141 virtual void addArray(std::string_view type, std::string_view name, Size size) = 0;
142 virtual void incArray(std::string_view l_i, std::string_view r_i) = 0;
143 virtual void setReferenceSlot(std::string_view left_instance,
144 std::string_view left_reference,
145 std::string_view right_instance) = 0;
146 virtual void setReferenceSlot(std::string_view l_i, std::string_view r_i) = 0;
147
148 virtual bool isClassOrInterface(std::string_view type) const = 0;
149 virtual bool isArrayInCurrentSystem(std::string_view name) const = 0;
150 };
151 } /* namespace prm */
152} /* namespace gum */
153
154#endif /* GUM_IPRM_FACTORY_H */
Headers of PRM.
Abstract base class for any element defined in a PRM.
Definition PRMObject.h:77
prm_type
Enumeration of the different types of objects handled by a PRM.
Definition PRMObject.h:90
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:73
virtual void addArray(std::string_view type, std::string_view name, Size size)=0
virtual void addNoisyOrCompound(std::string_view name, const std::vector< std::string > &chains, const std::vector< float > &numbers, float leak, const std::vector< std::string > &label)=0
virtual void continueAttribute(std::string_view name)=0
virtual void addImport(std::string_view name)=0
virtual void startAttribute(std::string_view type, std::string_view name, bool scalar_attr=false)=0
virtual void addLabel(std::string_view l, std::string_view extends="")=0
virtual void setRawCPFByFloatColumns(const std::vector< float > &array)=0
virtual void setCPFByFloatRule(const std::vector< std::string > &labels, const std::vector< float > &values)=0
virtual void addReferenceSlot(std::string_view type, std::string_view name, bool isArray)=0
virtual void setReferenceSlot(std::string_view left_instance, std::string_view left_reference, std::string_view right_instance)=0
virtual void addRangeType(std::string_view name, long minVal, long maxVal)=0
virtual void endAttribute()=0
virtual void addTick(double tick)=0
virtual void startInterface(std::string_view i, std::string_view extends="", bool delayInheritance=false)=0
virtual void pushPackage(std::string_view name)=0
virtual void endDiscretizedType()=0
virtual void setRawCPFByColumns(const std::vector< std::string > &array)=0
virtual const PRMObject * getCurrent() const =0
virtual void setRawCPFByFloatLines(const std::vector< float > &array)=0
virtual void startSystem(std::string_view name)=0
virtual void continueInterface(std::string_view name)=0
virtual void startDiscreteType(std::string_view name, std::string_view super="")=0
virtual std::string currentPackage() const =0
virtual void addInstance(std::string_view type, std::string_view name, const HashTable< std::string, double > &params)=0
virtual void setCPFByRule(const std::vector< std::string > &labels, const std::vector< std::string > &values)=0
virtual void setReferenceSlot(std::string_view l_i, std::string_view r_i)=0
virtual void endInterface()=0
virtual bool isClassOrInterface(std::string_view type) const =0
virtual void addParent(std::string_view name)=0
virtual PRMObject * getCurrent()=0
virtual void endClass(bool checkImplementations=true)=0
virtual std::string popPackage()=0
virtual PRMObject * closeCurrent()=0
virtual void continueClass(std::string_view c)=0
virtual void startClass(std::string_view c, std::string_view extends="", const Set< std::string > *implements=nullptr, bool delayInheritance=false)=0
virtual void startDiscretizedType(std::string_view name)=0
virtual void addAttribute(std::string_view type, std::string_view name)=0
virtual void addAggregator(std::string_view name, std::string_view agg_type, const std::vector< std::string > &chains, const std::vector< std::string > &params, std::string_view type="")=0
virtual void endDiscreteType()=0
virtual ~IPRMFactory()=default
virtual void setRawCPFByLines(const std::vector< std::string > &array)=0
virtual void addParameter(std::string_view type, std::string_view name, double value)=0
virtual void endSystem()=0
virtual bool isArrayInCurrentSystem(std::string_view name) const =0
virtual void addInstance(std::string_view type, std::string_view name)=0
virtual PRMObject::prm_type currentType() const =0
virtual void incArray(std::string_view l_i, std::string_view r_i)=0