Choreonoid  1.8
MprStatement.h
Go to the documentation of this file.
1 #ifndef CNOID_MANIPULATOR_PLUGIN_MPR_STATEMENT_H
2 #define CNOID_MANIPULATOR_PLUGIN_MPR_STATEMENT_H
3 
4 #include <cnoid/ClonableReferenced>
5 #include <cnoid/HierarchicalClassRegistry>
6 #include <cnoid/PolymorphicFunctionSet>
7 #include <string>
8 #include "exportdecl.h"
9 
10 namespace cnoid {
11 
12 class MprProgram;
13 class MprStructuredStatement;
14 class Mapping;
15 
16 class CNOID_EXPORT MprStatement : public ClonableReferenced
17 {
18 public:
19  int classId() const {
20  if(classId_ < 0) validateClassId();
21  return classId_;
22  }
23 
24  MprStatement* clone() const {
25  return static_cast<MprStatement*>(doClone(nullptr));
26  }
27  MprStatement* clone(CloneMap& cloneMap) const {
28  return static_cast<MprStatement*>(doClone(&cloneMap));
29  }
30 
31  std::string label() const;
32  virtual std::string label(int index) const = 0;
33 
34  MprProgram* holderProgram() const;
35  MprStructuredStatement* holderStatement() const;
36  MprProgram* topLevelProgram() const;
37 
38  virtual MprProgram* getLowerLevelProgram();
39 
40  void notifyUpdate();
41 
42  virtual bool read(MprProgram* program, const Mapping& archive) = 0;
43  virtual bool write(Mapping& archive) const = 0;
44 
45 protected:
46  MprStatement();
47  MprStatement(const MprStatement& org);
48  ~MprStatement();
49 
50 private:
51  mutable int classId_;
52  weak_ref_ptr<MprProgram> holderProgram_;
53 
54  void validateClassId() const;
55 
56  friend class MprProgram;
57 };
58 
60 
61 
62 class CNOID_EXPORT MprStatementClassRegistry : public HierarchicalClassRegistry<MprStatement>
63 {
64 public:
65  static MprStatementClassRegistry& instance();
66 
67 private:
69 };
70 
71 
72 class CNOID_EXPORT PolymorphicMprStatementFunctionSet : public PolymorphicFunctionSet<MprStatement>
73 {
74 public:
76 };
77 
78 typedef PolymorphicMprStatementFunctionSet::Dispatcher MprStatementFunctionDispatcher;
79 
80 }
81 
82 #endif
cnoid::HierarchicalClassRegistry
Definition: HierarchicalClassRegistry.h:30
cnoid::MprStatementClassRegistry
Definition: MprStatement.h:62
cnoid::Mapping
Definition: ValueTree.h:253
cnoid::MprStructuredStatement
Definition: MprStructuredStatement.h:10
cnoid::write
Listing * write(Mapping *mapping, const std::string &key, const Eigen::MatrixBase< Derived > &x)
Definition: EigenArchive.h:145
cnoid::weak_ref_ptr
Definition: Referenced.h:276
cnoid::read
bool read(const Mapping *mapping, const std::string &key, Eigen::MatrixBase< Derived > &x)
Definition: EigenArchive.h:43
cnoid::ref_ptr< MprStatement >
cnoid::MprStatementPtr
ref_ptr< MprStatement > MprStatementPtr
Definition: MprStatement.h:59
cnoid::MprStatementFunctionDispatcher
PolymorphicMprStatementFunctionSet::Dispatcher MprStatementFunctionDispatcher
Definition: MprStatement.h:78
cnoid
Definition: AbstractSceneLoader.h:11
cnoid::ClonableReferenced
Definition: ClonableReferenced.h:10
cnoid::CloneMap
Definition: CloneMap.h:13
cnoid::MprStatement
Definition: MprStatement.h:16
cnoid::PolymorphicMprStatementFunctionSet
Definition: MprStatement.h:72
cnoid::MprStatement::clone
MprStatement * clone(CloneMap &cloneMap) const
Definition: MprStatement.h:27
cnoid::MprProgram
Definition: MprProgram.h:21
cnoid::MprStatement::classId
int classId() const
Definition: MprStatement.h:19
cnoid::PolymorphicFunctionSet
Definition: PolymorphicFunctionSet.h:15
cnoid::MprStatement::clone
MprStatement * clone() const
Definition: MprStatement.h:24