aGrUM  0.20.2
a C++ library for (probabilistic) graphical models
IPRMFactory.h
Go to the documentation of this file.
1 /**
2  *
3  * Copyright 2005-2020 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,
73  std::string super = "")
74  = 0;
75  virtual void addLabel(const std::string& l, std::string extends = "") = 0;
76  virtual void endDiscreteType() = 0;
77  virtual void startDiscretizedType(const std::string& name) = 0;
78  virtual void addTick(double tick) = 0;
79  virtual void endDiscretizedType() = 0;
80  virtual void addRangeType(const std::string& name, long minVal, long maxVal)
81  = 0;
82  virtual void startClass(const std::string& c,
83  const std::string& extends = "",
84  const Set< std::string >* implements = nullptr,
85  bool delayInheritance = false)
86  = 0;
87  virtual void continueClass(const std::string& c) = 0;
88  virtual void endClass(bool checkImplementations = true) = 0;
89  virtual void startInterface(const std::string& i,
90  const std::string& extends = "",
91  bool delayInheritance = false)
92  = 0;
93  virtual void continueInterface(const std::string& name) = 0;
94  virtual void addAttribute(const std::string& type, const std::string& name)
95  = 0;
96  virtual void endInterface() = 0;
97  // virtual void addAttribute ( PRMAttribute<GUM_SCALAR>* attr ) =0;
98  virtual void startAttribute(const std::string& type,
99  const std::string& name,
100  bool scalar_attr = false)
101  = 0;
102  virtual void continueAttribute(const std::string& name) = 0;
103  virtual void addParent(const std::string& name) = 0;
104  virtual void setRawCPFByFloatLines(const std::vector< float >& array) = 0;
105  virtual void setRawCPFByFloatColumns(const std::vector< float >& array) = 0;
106  virtual void setCPFByFloatRule(const std::vector< std::string >& labels,
107  const std::vector< float >& values)
108  = 0;
109  virtual void setCPFByRule(const std::vector< std::string >& labels,
110  const std::vector< std::string >& values)
111  = 0;
112  virtual void setRawCPFByColumns(const std::vector< std::string >& array) = 0;
113  virtual void setRawCPFByLines(const std::vector< std::string >& array) = 0;
114  virtual void endAttribute() = 0;
115  virtual void addParameter(const std::string& type,
116  const std::string& name,
117  double value)
118  = 0;
119  virtual void addAggregator(const std::string& name,
120  const std::string& agg_type,
121  const std::vector< std::string >& chains,
122  const std::vector< std::string >& params,
123  std::string type = "")
124  = 0;
125  virtual void addNoisyOrCompound(const std::string& name,
126  const std::vector< std::string >& chains,
127  const std::vector< float >& numbers,
128  float leak,
129  const std::vector< std::string >& label)
130  = 0;
131  virtual void addReferenceSlot(const std::string& type,
132  const std::string& name,
133  bool isArray)
134  = 0;
135  virtual void startSystem(const std::string& name) = 0;
136  virtual void endSystem() = 0;
137  virtual void addInstance(const std::string& type, const std::string& name)
138  = 0;
139  virtual void addInstance(const std::string& type,
140  const std::string& name,
141  const HashTable< std::string, double >& params)
142  = 0;
143  virtual void
144  addArray(const std::string& type, const std::string& name, Size size)
145  = 0;
146  virtual void incArray(const std::string& l_i, const std::string& r_i) = 0;
147  virtual void setReferenceSlot(const std::string& left_instance,
148  const std::string& left_reference,
149  const std::string& right_instance)
150  = 0;
151  virtual void setReferenceSlot(const std::string& l_i, const std::string& r_i)
152  = 0;
153 
154  virtual bool isClassOrInterface(const std::string& type) const = 0;
155  virtual bool isArrayInCurrentSystem(const std::string& name) const = 0;
156  };
157  } /* namespace prm */
158 } /* namespace gum */
159 
160 #endif /* GUM_IPRM_FACTORY_H */