aGrUM  0.16.0
O3prm.h
Go to the documentation of this file.
1 
31 #include <string>
32 #include <utility>
33 #include <vector>
34 
35 #include <agrum/agrum.h>
36 #include <agrum/core/hashTable.h>
38 
39 #ifndef GUM_PRM_O3PRM_PRM_H
40 # define GUM_PRM_O3PRM_PRM_H
41 
42 namespace gum {
43  namespace prm {
44  namespace o3prm {
45 
53  class O3Position {
54  public:
55  O3Position();
56  O3Position(const std::string& filename, int line, int column);
57  O3Position(const O3Position& src);
58  O3Position(O3Position&& src);
59  ~O3Position();
60 
61  O3Position& operator=(const O3Position& src);
63 
64  std::string& file();
65  const std::string& file() const;
66 
67  int& line();
68  int line() const;
69 
70  int& column();
71  int column() const;
72 
73  private:
74  std::string __file;
75  int __line;
76  int __column;
77  };
78 
86  class O3Formula {
87  public:
88  O3Formula();
89  O3Formula(const O3Position& pos, const Formula& formula);
90  O3Formula(const O3Formula& src);
91  O3Formula(O3Formula&& src);
92  ~O3Formula();
93 
94  O3Formula& operator=(const O3Formula& src);
96 
97  O3Position& position();
98  const O3Position& position() const;
99 
100  Formula& formula();
101  const Formula& formula() const;
102 
103  private:
105  std::unique_ptr< Formula > __formula;
106  };
107 
115  class O3Float {
116  public:
117  O3Float();
118  O3Float(const O3Position& pos, float value);
119  O3Float(const O3Float& src);
120  O3Float(O3Float&& src);
121  ~O3Float();
122 
123  O3Float& operator=(const O3Float& src);
124  O3Float& operator=(O3Float&& src);
125 
126  O3Position& position();
127  const O3Position& position() const;
128 
129  float& value();
130  float value() const;
131 
132  private:
134  float __value;
135  };
136 
144  class O3Integer {
145  public:
146  O3Integer();
147  O3Integer(const O3Position& pos, int value);
148  O3Integer(const O3Integer& src);
149  O3Integer(O3Integer&& src);
150  ~O3Integer();
151 
152  O3Integer& operator=(const O3Integer& src);
153  O3Integer& operator=(O3Integer&& src);
154 
155  O3Position& position();
156  const O3Position& position() const;
157 
158  int& value();
159  int value() const;
160 
161  private:
163  int __value;
164  };
165 
173  class O3Label {
174  public:
175  O3Label();
176  O3Label(const O3Position& pos, const std::string& label);
177  O3Label(const O3Label& src);
178  O3Label(O3Label&& src);
179  ~O3Label();
180 
181  O3Label& operator=(const O3Label& src);
182  O3Label& operator=(O3Label&& src);
183 
184  O3Position& position();
185  const O3Position& position() const;
186 
187  std::string& label();
188  const std::string& label() const;
189 
190  private:
192  std::string __label;
193  };
194 
195  std::ostream& operator<<(std::ostream& o, const O3Label& src);
196 
204  class O3Type {
205  public:
206  using LabelPair = std::pair< O3Label, O3Label >;
207  using LabelMap = std::vector< LabelPair >;
208 
209  O3Type();
210  O3Type(const O3Type& src);
211  O3Type(O3Type&& src);
212  ~O3Type();
213 
214  O3Type& operator=(const O3Type& src);
215  O3Type& operator=(O3Type&& src);
216 
217  O3Position& position();
218  const O3Position& position() const;
219 
220  O3Label& name();
221  const O3Label& name() const;
222 
223  O3Label& superLabel();
224  const O3Label& superLabel() const;
225 
226  LabelMap& labels();
227  const LabelMap& labels() const;
228 
229  bool& deprecated();
230  const bool& deprecated() const;
231 
232  private:
238  };
239 
247  class O3IntType {
248  public:
249  O3IntType();
250  O3IntType(const O3IntType& src);
251  O3IntType(O3IntType&& src);
252  ~O3IntType();
253 
254  O3IntType& operator=(const O3IntType& src);
255  O3IntType& operator=(O3IntType&& src);
256 
257  O3Position& position();
258  const O3Position& position() const;
259 
260  O3Label& name();
261  const O3Label& name() const;
262 
263  O3Integer& start();
264  const O3Integer& start() const;
265 
266  O3Integer& end();
267  const O3Integer& end() const;
268 
269  bool& deprecated();
270  const bool& deprecated() const;
271 
272  private:
278  };
279 
287  class O3RealType {
288  public:
289  O3RealType();
290  O3RealType(const O3RealType& src);
291  O3RealType(O3RealType&& src);
292  ~O3RealType();
293 
294  O3RealType& operator=(const O3RealType& src);
296 
297  O3Position& position();
298  const O3Position& position() const;
299 
300  O3Label& name();
301  const O3Label& name() const;
302 
303  std::vector< O3Float >& values();
304  const std::vector< O3Float >& values() const;
305 
306  bool& deprecated();
307  const bool& deprecated() const;
308 
309  private:
312  std::vector< O3Float > __values;
314  };
315 
324  public:
326  O3InterfaceElement(const O3Label& type, const O3Label& name, bool isArray);
330 
333 
334  O3Label& type();
335  const O3Label& type() const;
336 
337  O3Label& name();
338  const O3Label& name() const;
339 
340  bool& isArray();
341  bool isArray() const;
342 
343  private:
346  bool __isArray;
347  };
348 
356  class O3Interface {
357  public:
358  using O3InterfaceElementList = std::vector< O3InterfaceElement >;
359 
360  O3Interface();
361  O3Interface(const O3Interface& src);
362  O3Interface(O3Interface&& src);
363  ~O3Interface();
364 
365  O3Interface& operator=(const O3Interface& src);
367 
368  O3Position& position();
369  const O3Position& position() const;
370 
371  O3Label& name();
372  const O3Label& name() const;
373 
374  O3Label& superLabel();
375  const O3Label& superLabel() const;
376 
377  O3InterfaceElementList& elements();
378  const O3InterfaceElementList& elements() const;
379 
380  private:
384  std::unique_ptr< O3InterfaceElementList > __elts;
385  };
386 
394  class O3Parameter {
395  public:
396  enum class PRMType { NONE, INT, FLOAT };
397 
398  O3Parameter();
399  O3Parameter(const O3Position& pos,
400  const O3Label& name,
401  const O3Integer& value);
402  O3Parameter(const O3Position& pos,
403  const O3Label& name,
404  const O3Float& value);
405  O3Parameter(const O3Parameter& src);
406  O3Parameter(O3Parameter&& src);
407  ~O3Parameter();
408 
409  O3Parameter& operator=(const O3Parameter& src);
411 
412  PRMType& type();
413  PRMType type() const;
414 
415  O3Position& position();
416  const O3Position& position() const;
417 
418  O3Label& name();
419  const O3Label& name() const;
420 
421  O3Float& value();
422  const O3Float& value() const;
423 
424  private:
429  };
430 
439  public:
440  O3ReferenceSlot();
441  O3ReferenceSlot(const O3Label& type, const O3Label& name, bool isArray);
442  O3ReferenceSlot(const O3ReferenceSlot& src);
444  ~O3ReferenceSlot();
445 
448 
449  O3Label& type();
450  const O3Label& type() const;
451 
452  O3Label& name();
453  const O3Label& name() const;
454 
455  bool& isArray();
456  bool isArray() const;
457 
458  private:
461  bool __isArray;
462  };
463 
471  class O3Attribute {
472  public:
473  using O3LabelList = std::vector< O3Label >;
474 
475  O3Attribute();
476  O3Attribute(const O3Label& type,
477  const O3Label& name,
478  const O3LabelList& parents);
479  O3Attribute(const O3Attribute& src);
480  O3Attribute(O3Attribute&& src);
481  virtual ~O3Attribute();
482 
483  virtual O3Attribute& operator=(const O3Attribute& src);
484  virtual O3Attribute& operator=(O3Attribute&& src);
485 
486  virtual O3Label& type();
487  virtual const O3Label& type() const;
488 
489  virtual O3Label& name();
490  virtual const O3Label& name() const;
491 
492  virtual O3LabelList& parents();
493  virtual const O3LabelList& parents() const;
494 
495  virtual std::unique_ptr< O3Attribute > copy() const = 0;
496 
497  private:
501  };
502 
510  class O3RawCPT : public O3Attribute {
511  public:
512  using O3FormulaList = std::vector< O3Formula >;
513 
514  O3RawCPT();
515  O3RawCPT(const O3Label& type,
516  const O3Label& name,
517  const O3Attribute::O3LabelList& parents,
518  const O3FormulaList& values);
519  O3RawCPT(const O3RawCPT& src);
520  O3RawCPT(O3RawCPT&& src);
521  ~O3RawCPT();
522 
523  virtual O3RawCPT& operator=(const O3RawCPT& src);
524  virtual O3RawCPT& operator=(O3RawCPT&& src);
525 
526  virtual O3FormulaList& values();
527  virtual const O3FormulaList& values() const;
528 
529  virtual std::unique_ptr< O3Attribute > copy() const;
530 
531  private:
532  std::unique_ptr< O3FormulaList > __values;
533  };
534 
542  class O3RuleCPT : public O3Attribute {
543  public:
544  using O3LabelList = std::vector< O3Label >;
545  using O3FormulaList = std::vector< O3Formula >;
546  using O3Rule = std::pair< O3LabelList, O3FormulaList >;
547  using O3RuleList = std::vector< O3Rule >;
548 
549  O3RuleCPT();
550  O3RuleCPT(const O3Label& type,
551  const O3Label& name,
552  const O3Attribute::O3LabelList& parents,
553  O3RuleList&& rules);
554  O3RuleCPT(const O3RuleCPT& src);
555  O3RuleCPT(O3RuleCPT&& src);
556  ~O3RuleCPT();
557 
558  virtual O3RuleCPT& operator=(const O3RuleCPT& src);
559  virtual O3RuleCPT& operator=(O3RuleCPT&& src);
560 
561  virtual O3RuleList& rules();
562  virtual const O3RuleList& rules() const;
563 
564  virtual std::unique_ptr< O3Attribute > copy() const;
565 
566  private:
567  std::unique_ptr< O3RuleList > __rules;
568  };
569 
577  class O3Aggregate {
578  public:
579  using O3LabelList = std::vector< O3Label >;
580 
581  O3Aggregate();
582  O3Aggregate(const O3Aggregate& src);
583  O3Aggregate(O3Aggregate&& src);
584  virtual ~O3Aggregate();
585 
586  O3Aggregate& operator=(const O3Aggregate& src);
588 
589  O3Label& variableType();
590  const O3Label& variableType() const;
591 
592  O3Label& aggregateType();
593  const O3Label& aggregateType() const;
594 
595  O3Label& name();
596  const O3Label& name() const;
597 
598  O3LabelList& parents();
599  const O3LabelList& parents() const;
600 
601  O3LabelList& parameters();
602  const O3LabelList& parameters() const;
603 
604  private:
610  };
611 
619  class O3Class {
620  public:
621  using O3LabelList = std::vector< O3Label >;
622  using O3ParameterList = std::vector< O3Parameter >;
623  using O3ReferenceSlotList = std::vector< O3ReferenceSlot >;
624  using O3AttributeList = std::vector< std::unique_ptr< O3Attribute > >;
625  using O3AggregateList = std::vector< O3Aggregate >;
626 
627  O3Class();
628  O3Class(const O3Class& src);
629  O3Class(O3Class&& src);
630  ~O3Class();
631 
632  O3Class& operator=(const O3Class& src);
633  O3Class& operator=(O3Class&& src);
634 
635  O3Position& position();
636  const O3Position& position() const;
637 
638  O3Label& name();
639  const O3Label& name() const;
640 
641  O3Label& superLabel();
642  const O3Label& superLabel() const;
643 
644  O3LabelList& interfaces();
645  const O3LabelList& interfaces() const;
646 
647  O3ParameterList& parameters();
648  const O3ParameterList& parameters() const;
649 
650  O3ReferenceSlotList& referenceSlots();
651  const O3ReferenceSlotList& referenceSlots() const;
652 
653  O3AttributeList& attributes();
654  const O3AttributeList& attributes() const;
655 
656  O3AggregateList& aggregates();
657  const O3AggregateList& aggregates() const;
658 
659  private:
663  std::unique_ptr< O3LabelList > __interfaces;
664  std::unique_ptr< O3ParameterList > __params;
665  std::unique_ptr< O3ReferenceSlotList > __refs;
666  std::unique_ptr< O3AttributeList > __attrs;
667  std::unique_ptr< O3AggregateList > __aggs;
668  };
669 
677  class O3Assignment {
678  public:
679  O3Assignment();
680  O3Assignment(const O3Assignment& src);
681  O3Assignment(O3Assignment&& src);
682  ~O3Assignment();
683 
684  O3Assignment& operator=(const O3Assignment& src);
686 
687  O3Label& leftInstance();
688  const O3Label& leftInstance() const;
689 
690  O3Integer& leftIndex();
691  const O3Integer& leftIndex() const;
692 
693  O3Label& leftReference();
694  const O3Label& leftReference() const;
695 
696  O3Label& rightInstance();
697  const O3Label& rightInstance() const;
698 
699  O3Integer& rightIndex();
700  const O3Integer& rightIndex() const;
701 
702  private:
708  };
709 
717  class O3Increment {
718  public:
719  O3Increment();
720  O3Increment(const O3Increment& src);
721  O3Increment(O3Increment&& src);
722  ~O3Increment();
723 
724  O3Increment& operator=(const O3Increment& src);
726 
727  O3Label& leftInstance();
728  const O3Label& leftInstance() const;
729 
730  O3Integer& leftIndex();
731  const O3Integer& leftIndex() const;
732 
733  O3Label& leftReference();
734  const O3Label& leftReference() const;
735 
736  O3Label& rightInstance();
737  const O3Label& rightInstance() const;
738 
739  O3Integer& rightIndex();
740  const O3Integer& rightIndex() const;
741 
742  private:
748  };
749 
759  public:
764 
767 
768  O3Label& name();
769  const O3Label& name() const;
770 
771  O3Float& value();
772  const O3Float& value() const;
773 
774  bool& isInteger();
775  bool isInteger() const;
776 
777  private:
781  };
782 
790  class O3Instance {
791  public:
792  using O3InstanceParameterList = std::vector< O3InstanceParameter >;
793 
794  O3Instance();
795  O3Instance(const O3Instance& src);
796  O3Instance(O3Instance&& src);
797  ~O3Instance();
798 
799  O3Instance& operator=(const O3Instance& src);
801 
802  O3Label& type();
803  const O3Label& type() const;
804 
805  O3Label& name();
806  const O3Label& name() const;
807 
808  O3Integer& size();
809  const O3Integer& size() const;
810 
811  O3InstanceParameterList& parameters();
812  const O3InstanceParameterList& parameters() const;
813 
814  private:
819  };
820 
828  class O3System {
829  public:
830  using O3InstanceList = std::vector< O3Instance >;
831  using O3AssignmentList = std::vector< O3Assignment >;
832  using O3IncrementList = std::vector< O3Increment >;
833 
834  O3System();
835  O3System(const O3System& src);
836  O3System(O3System&& src);
837  ~O3System();
838 
839  O3System& operator=(const O3System& src);
840  O3System& operator=(O3System&& src);
841 
842  O3Label& name();
843  const O3Label& name() const;
844 
845  O3InstanceList& instances();
846  const O3InstanceList& instances() const;
847 
848  O3AssignmentList& assignments();
849  const O3AssignmentList& assignments() const;
850 
851  O3IncrementList& increments();
852  const O3IncrementList& increments() const;
853 
854  private:
859  };
860 
868  class O3Import {
869  public:
870  O3Import();
871  O3Import(const O3Import& src);
872  O3Import(O3Import&& src);
873  ~O3Import();
874 
875  O3Import& operator=(const O3Import& src);
876  O3Import& operator=(O3Import&& src);
877 
878  O3Label& import();
879  const O3Label& import() const;
880 
881  private:
883  };
884 
892  class O3PRM {
893  public:
894  using O3TypeList = std::vector< std::unique_ptr< O3Type > >;
895  using O3IntTypeList = std::vector< std::unique_ptr< O3IntType > >;
896  using O3RealTypeList = std::vector< std::unique_ptr< O3RealType > >;
897  using O3InterfaceList = std::vector< std::unique_ptr< O3Interface > >;
898  using O3ClassList = std::vector< std::unique_ptr< O3Class > >;
899  using O3SystemList = std::vector< std::unique_ptr< O3System > >;
900  using O3ImportList = std::vector< std::unique_ptr< O3Import > >;
901 
902  O3PRM();
903  O3PRM(const O3PRM& src);
904  O3PRM(O3PRM&& src);
905  ~O3PRM();
906 
907  O3PRM& operator=(const O3PRM& src);
908  O3PRM& operator=(O3PRM&& src);
909 
910  O3TypeList& types();
911  const O3TypeList& types() const;
912 
913  O3IntTypeList& int_types();
914  const O3IntTypeList& int_types() const;
915 
916  O3RealTypeList& real_types();
917  const O3RealTypeList& real_types() const;
918 
919  O3InterfaceList& interfaces();
920  const O3InterfaceList& interfaces() const;
921 
922  O3ClassList& classes();
923  const O3ClassList& classes() const;
924 
925  O3SystemList& systems();
926  const O3SystemList& systems() const;
927 
928  O3ImportList& imports();
929  const O3ImportList& imports() const;
930 
931  private:
939  };
940 
941  } // namespace o3prm
942  } // namespace prm
943 } // namespace gum
944 
945 #endif // GUM_PRM_O3PRM_PRM_H
std::vector< std::unique_ptr< O3RealType > > O3RealTypeList
Definition: O3prm.h:896
O3SystemList __systems
Definition: O3prm.h:937
std::pair< O3LabelList, O3FormulaList > O3Rule
Definition: O3prm.h:546
std::vector< O3ReferenceSlot > O3ReferenceSlotList
Definition: O3prm.h:623
O3LabelList __parameters
Definition: O3prm.h:609
O3ClassList __classes
Definition: O3prm.h:936
O3Position & operator=(const O3Position &src)
Definition: O3prm.cpp:59
std::unique_ptr< O3ParameterList > __params
Definition: O3prm.h:664
std::vector< O3InstanceParameter > O3InstanceParameterList
Definition: O3prm.h:792
O3IncrementList __increments
Definition: O3prm.h:858
The O3Increment is part of the AST of the O3PRM language.
Definition: O3prm.h:717
std::vector< O3Increment > O3IncrementList
Definition: O3prm.h:832
The O3InstanceParameter is part of the AST of the O3PRM language.
Definition: O3prm.h:758
O3Position __pos
Definition: O3prm.h:660
The O3Parameter is part of the AST of the O3PRM language.
Definition: O3prm.h:394
The O3IntType is part of the AST of the O3PRM language.
Definition: O3prm.h:247
Evaluates a string as a algebraic formula.
Definition: formula.h:274
std::unique_ptr< O3ReferenceSlotList > __refs
Definition: O3prm.h:665
O3Position __pos
Definition: O3prm.h:133
std::vector< std::unique_ptr< O3Attribute > > O3AttributeList
Definition: O3prm.h:624
std::unique_ptr< O3LabelList > __interfaces
Definition: O3prm.h:663
std::vector< std::unique_ptr< O3Import > > O3ImportList
Definition: O3prm.h:900
The O3Aggregate is part of the AST of the O3PRM language.
Definition: O3prm.h:577
std::ostream & operator<<(std::ostream &o, const O3Label &src)
Definition: O3prm.cpp:1315
std::vector< std::unique_ptr< O3IntType > > O3IntTypeList
Definition: O3prm.h:895
The O3RealType is part of the AST of the O3PRM language.
Definition: O3prm.h:287
std::unique_ptr< O3AttributeList > __attrs
Definition: O3prm.h:666
std::vector< O3Label > O3LabelList
Definition: O3prm.h:621
The O3Type is part of the AST of the O3PRM language.
Definition: O3prm.h:204
The O3Label is part of the AST of the O3PRM language.
Definition: O3prm.h:173
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
The O3Attribute is part of the AST of the O3PRM language.
Definition: O3prm.h:471
std::unique_ptr< O3FormulaList > __values
Definition: O3prm.h:532
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
O3RealTypeList __real_types
Definition: O3prm.h:934
The O3Import is part of the AST of the O3PRM language.
Definition: O3prm.h:868
std::string __file
Definition: O3prm.h:74
std::vector< O3Label > O3LabelList
Definition: O3prm.h:473
std::vector< O3Formula > O3FormulaList
Definition: O3prm.h:512
std::string & file()
Definition: O3prm.cpp:75
O3IntTypeList __int_types
Definition: O3prm.h:933
std::vector< std::unique_ptr< O3Interface > > O3InterfaceList
Definition: O3prm.h:897
The O3RuleCPT is part of the AST of the O3PRM language.
Definition: O3prm.h:542
The O3Position is part of the AST of the O3PRM language.
Definition: O3prm.h:53
std::unique_ptr< O3AggregateList > __aggs
Definition: O3prm.h:667
std::vector< O3Float > __values
Definition: O3prm.h:312
std::unique_ptr< O3RuleList > __rules
Definition: O3prm.h:567
std::vector< std::unique_ptr< O3Class > > O3ClassList
Definition: O3prm.h:898
O3Position __pos
Definition: O3prm.h:191
The O3Class is part of the AST of the O3PRM language.
Definition: O3prm.h:619
std::vector< O3Rule > O3RuleList
Definition: O3prm.h:547
O3TypeList __types
Definition: O3prm.h:932
std::string __label
Definition: O3prm.h:192
The O3Instance is part of the AST of the O3PRM language.
Definition: O3prm.h:790
std::unique_ptr< O3InterfaceElementList > __elts
Definition: O3prm.h:384
The O3ReferenceSlot is part of the AST of the O3PRM language.
Definition: O3prm.h:438
std::vector< LabelPair > LabelMap
Definition: O3prm.h:207
O3InstanceParameterList __parameters
Definition: O3prm.h:818
std::vector< O3Aggregate > O3AggregateList
Definition: O3prm.h:625
std::vector< O3Parameter > O3ParameterList
Definition: O3prm.h:622
std::pair< O3Label, O3Label > LabelPair
Definition: O3prm.h:206
The O3System is part of the AST of the O3PRM language.
Definition: O3prm.h:828
std::vector< std::unique_ptr< O3Type > > O3TypeList
Definition: O3prm.h:894
O3InterfaceList __interfaces
Definition: O3prm.h:935
std::vector< O3Formula > O3FormulaList
Definition: O3prm.h:545
The O3Float is part of the AST of the O3PRM language.
Definition: O3prm.h:115
The O3RawCPT is part of the AST of the O3PRM language.
Definition: O3prm.h:510
O3ImportList __imports
Definition: O3prm.h:938
std::vector< O3Label > O3LabelList
Definition: O3prm.h:579
The O3Assignment is part of the AST of the O3PRM language.
Definition: O3prm.h:677
std::vector< O3InterfaceElement > O3InterfaceElementList
Definition: O3prm.h:358
std::unique_ptr< Formula > __formula
Definition: O3prm.h:105
The O3Integer is part of the AST of the O3PRM language.
Definition: O3prm.h:144
std::vector< O3Instance > O3InstanceList
Definition: O3prm.h:830
The O3InterfaceElement is part of the AST of the O3PRM language.
Definition: O3prm.h:323
The O3PRM is part of the AST of the O3PRM language.
Definition: O3prm.h:892
O3Position __pos
Definition: O3prm.h:233
O3InstanceList __instances
Definition: O3prm.h:856
The O3Interface is part of the AST of the O3PRM language.
Definition: O3prm.h:356
O3AssignmentList __assigments
Definition: O3prm.h:857
std::vector< std::unique_ptr< O3System > > O3SystemList
Definition: O3prm.h:899
The O3Formula is part of the AST of the O3PRM language.
Definition: O3prm.h:86
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
std::vector< O3Assignment > O3AssignmentList
Definition: O3prm.h:831
O3Label __superLabel
Definition: O3prm.h:235