aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
IPRMFactory.h
Go to the documentation of this file.
1 /**
2  *
3  * Copyright (c) 2005-2021 by Pierre-Henri WUILLEMIN(@LIP6) & Christophe GONZALES(@AMU)
4  * info_at_agrum_dot_org
5  *
6  * This library is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library. If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 
22 /**
23  * @file
24  * @brief Headers of IPRMFactory.
25  *
26  * @author Lionel TORTI and Pierre-Henri WUILLEMIN(@LIP6)
27  */
28 
29 #ifndef GUM_IPRM_FACTORY_H
30 #define GUM_IPRM_FACTORY_H
31 
32 #include <iostream>
33 #include <limits>
34 #include <sstream>
35 #include <string>
36 #include <vector>
37 
38 #include <agrum/agrum.h>
39 
40 #include <agrum/tools/core/hashTable.h>
41 #include <agrum/tools/multidim/implementations/multiDimSparse.h>
42 #include <agrum/tools/variables/discreteVariable.h>
43 
44 #include <agrum/PRM/PRM.h>
45 #include <agrum/PRM/utils_prm.h>
46 
47 namespace gum {
48 
49  namespace prm {
50  /**
51  * @class IPRMFactory
52  * @brief non-template interface-like parent for every PRM Factory
53  *
54  * @ingroup prm_group
55  */
56  struct IPRMFactory {
57  virtual ~IPRMFactory(){};
58 
59  // virtual PRM<GUM_SCALAR>* prm() const=0;
60  virtual PRMObject::prm_type currentType() const = 0;
61  virtual PRMObject* getCurrent() = 0;
62  virtual const PRMObject* getCurrent() const = 0;
63  virtual PRMObject* closeCurrent() = 0;
64  virtual std::string currentPackage() const = 0;
65  // Class<GUM_SCALAR>& retrieveClass ( const std::string& name )=0;
66  // PRMType& retrieveType ( const std::string& name )=0;
67  // PRMType& retrieveCommonType ( const
68  // std::vector<PRMClassElement<GUM_SCALAR>*>& elts )=0;
69  virtual void pushPackage(const std::string& name) = 0;
70  virtual std::string popPackage() = 0;
71  virtual void addImport(const std::string& name) = 0;
72  virtual void startDiscreteType(const std::string& name, std::string super = "") = 0;
73  virtual void addLabel(const std::string& l, std::string extends = "") = 0;
74  virtual void endDiscreteType() = 0;
75  virtual void startDiscretizedType(const std::string& name) = 0;
76  virtual void addTick(double tick) = 0;
77  virtual void endDiscretizedType() = 0;
78  virtual void addRangeType(const std::string& name, long minVal, long maxVal) = 0;
79  virtual void startClass(const std::string& c,
80  const std::string& extends = "",
81  const Set< std::string >* implements = nullptr,
82  bool delayInheritance = false)
83  = 0;
84  virtual void continueClass(const std::string& c) = 0;
85  virtual void endClass(bool checkImplementations = true) = 0;
86  virtual void startInterface(const std::string& i,
87  const std::string& extends = "",
88  bool delayInheritance = false)
89  = 0;
90  virtual void continueInterface(const std::string& name) = 0;
91  virtual void addAttribute(const std::string& type, const std::string& name) = 0;
92  virtual void endInterface() = 0;
93  // virtual void addAttribute ( PRMAttribute<GUM_SCALAR>* attr ) =0;
94  virtual void
95  startAttribute(const std::string& type, const std::string& name, bool scalar_attr = false)
96  = 0;
97  virtual void continueAttribute(const std::string& name) = 0;
98  virtual void addParent(const std::string& name) = 0;
99  virtual void setRawCPFByFloatLines(const std::vector< float >& array) = 0;
100  virtual void setRawCPFByFloatColumns(const std::vector< float >& array) = 0;
101  virtual void setCPFByFloatRule(const std::vector< std::string >& labels,
102  const std::vector< float >& values)
103  = 0;
104  virtual void setCPFByRule(const std::vector< std::string >& labels,
105  const std::vector< std::string >& values)
106  = 0;
107  virtual void setRawCPFByColumns(const std::vector< std::string >& array) = 0;
108  virtual void setRawCPFByLines(const std::vector< std::string >& array) = 0;
109  virtual void endAttribute() = 0;
110  virtual void addParameter(const std::string& type, const std::string& name, double value) = 0;
111  virtual void addAggregator(const std::string& name,
112  const std::string& agg_type,
113  const std::vector< std::string >& chains,
114  const std::vector< std::string >& params,
115  std::string type = "")
116  = 0;
117  virtual void addNoisyOrCompound(const std::string& name,
118  const std::vector< std::string >& chains,
119  const std::vector< float >& numbers,
120  float leak,
121  const std::vector< std::string >& label)
122  = 0;
123  virtual void addReferenceSlot(const std::string& type, const std::string& name, bool isArray)
124  = 0;
125  virtual void startSystem(const std::string& name) = 0;
126  virtual void endSystem() = 0;
127  virtual void addInstance(const std::string& type, const std::string& name) = 0;
128  virtual void addInstance(const std::string& type,
129  const std::string& name,
130  const HashTable< std::string, double >& params)
131  = 0;
132  virtual void addArray(const std::string& type, const std::string& name, Size size) = 0;
133  virtual void incArray(const std::string& l_i, const std::string& r_i) = 0;
134  virtual void setReferenceSlot(const std::string& left_instance,
135  const std::string& left_reference,
136  const std::string& right_instance)
137  = 0;
138  virtual void setReferenceSlot(const std::string& l_i, const std::string& r_i) = 0;
139 
140  virtual bool isClassOrInterface(const std::string& type) const = 0;
141  virtual bool isArrayInCurrentSystem(const std::string& name) const = 0;
142  };
143  } /* namespace prm */
144 } /* namespace gum */
145 
146 #endif /* GUM_IPRM_FACTORY_H */