Choreonoid  1.1
SeqBase.h
[詳解]
1 
6 #ifndef CNOID_UTIL_SEQ_BASE_H_INCLUDED
7 #define CNOID_UTIL_SEQ_BASE_H_INCLUDED
8 
9 #include <string>
10 #include <boost/shared_ptr.hpp>
11 #include "exportdecl.h"
12 
13 namespace cnoid {
14 
15  class YamlMapping;
16  class YamlWriter;
17 
18  static const double DEFAULT_FRAME_RATE = 100.0;
19 
21  {
22  public:
23 
24  SeqBase(const char* seqType);
25  SeqBase(const SeqBase& org);
26  virtual ~SeqBase();
27 
28  inline const std::string& seqType() const {
29  return seqType_;
30  }
31 
32  virtual double getFrameRate() const = 0;
33  virtual void setFrameRate(double frameRate) = 0;
34 
35  inline double getTimeStep() const {
36  return 1.0 / getFrameRate();
37  }
38 
39  inline void setTimeStep(double timeStep){
40  return setFrameRate(1.0 / timeStep);
41  }
42 
43  virtual int getNumFrames() const = 0;
44  virtual void setNumFrames(int n, bool clearNewElements = false) = 0;
45 
46  inline void setTimeLength(double length, bool clearNewElements = false){
47  return setNumFrames(static_cast<int>(length * getFrameRate()), clearNewElements);
48  }
49 
57  inline double getTimeLength() const {
58  return getNumFrames() / getFrameRate();
59  }
60 
61  inline const std::string& purpose() {
62  return purpose_;
63  }
64 
65  virtual void setPurpose(const std::string& purpose) {
66  purpose_ = purpose;
67  }
68 
69  virtual bool read(const YamlMapping& archive);
70  virtual bool write(YamlWriter& writer);
71 
72  inline const std::string& ioErrorMessage() const {
73  return ioErrorMessage_;
74  }
75 
76  protected:
77  void setIoErrorMessage(const std::string& message) {
78  ioErrorMessage_ = message;
79  }
80 
81  private:
82  const std::string seqType_;
83  std::string purpose_;
84  std::string ioErrorMessage_;
85  };
86 
87  typedef boost::shared_ptr<SeqBase> SeqBasePtr;
88 
89 
91  {
92  public:
93  MultiSeqBase(const char* seqType)
94  : SeqBase(seqType) { }
95  MultiSeqBase(const SeqBase& org)
96  : SeqBase(org) { }
97  virtual ~MultiSeqBase() { }
98 
99  virtual void setDimension(int numFrames, int numParts, bool claerNewElements = false) = 0;
100 
101  virtual void setNumParts(int numParts, bool clearNewElements = false) = 0;
102  virtual int getNumParts() const = 0;
103 
104  virtual bool read(const YamlMapping& archive);
105  virtual bool write(YamlWriter& writer);
106  };
107 
108  typedef boost::shared_ptr<MultiSeqBase> MultiSeqBasePtr;
109 }
110 
111 #endif
Definition: YamlWriter.h:18
double getTimeLength() const
Definition: SeqBase.h:57
bool read(const YamlMapping &mapping, const std::string &key, Eigen::MatrixBase< Derived > &x)
Definition: EigenYaml.h:14
const std::string & ioErrorMessage() const
Definition: SeqBase.h:72
void setIoErrorMessage(const std::string &message)
Definition: SeqBase.h:77
const std::string & seqType() const
Definition: SeqBase.h:28
boost::shared_ptr< SeqBase > SeqBasePtr
Definition: SeqBase.h:87
YamlSequence & write(YamlMapping &mapping, const std::string &key, const Eigen::MatrixBase< Derived > &x)
Definition: EigenYaml.h:46
Definition: SeqBase.h:20
MultiSeqBase(const char *seqType)
Definition: SeqBase.h:93
void setTimeStep(double timeStep)
Definition: SeqBase.h:39
Definition: EasyScanner.h:16
void setTimeLength(double length, bool clearNewElements=false)
Definition: SeqBase.h:46
virtual ~MultiSeqBase()
Definition: SeqBase.h:97
Definition: YamlNodes.h:212
Definition: SeqBase.h:90
MultiSeqBase(const SeqBase &org)
Definition: SeqBase.h:95
double getTimeStep() const
Definition: SeqBase.h:35
virtual void setPurpose(const std::string &purpose)
Definition: SeqBase.h:65
boost::shared_ptr< MultiSeqBase > MultiSeqBasePtr
Definition: SeqBase.h:108
#define CNOID_EXPORT
Definition: Util/exportdecl.h:13
const std::string & purpose()
Definition: SeqBase.h:61