/usr/include/choreonoid-1.1/cnoid/src/Util/Seq.h is in libcnoid-dev 1.1.0+dfsg-6.1+b4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | /**
@file
@author Shin'ichiro Nakaoka
*/
#ifndef CNOID_UTIL_SEQ_H_INCLUDED
#define CNOID_UTIL_SEQ_H_INCLUDED
#include "SeqBase.h"
#include <vector>
#include "exportdecl.h"
namespace cnoid {
template <typename ElementType> class Seq : public SeqBase
{
public:
typedef boost::shared_ptr< Seq<ElementType> > Ptr;
Seq(const char* seqType, int nFrames = 0.0, double frameRate = 100.0)
: SeqBase(seqType),
container(nFrames) {
frameRate_ = frameRate;
}
Seq(const Seq<ElementType>& org)
: SeqBase(org),
container(org.container) {
frameRate_ = org.frameRate_;
}
virtual ~Seq() { }
virtual double getFrameRate() const {
return frameRate_;
}
inline double frameRate() const {
return frameRate_;
}
virtual void setFrameRate(double frameRate) {
frameRate_ = frameRate;
}
virtual int getNumFrames() const {
return container.size();
}
inline int numFrames() const {
return container.size();
}
virtual void setNumFrames(int n, bool clearNewElements = false) {
if(clearNewElements){
container.resize(n, defaultValue());
} else {
container.resize(n);
}
}
inline bool empty() const {
return container.empty();
}
inline int frameOfTime(double time) const {
return (int)(time * frameRate_);
}
inline double timeOfFrame(int frame) const {
return (frame / frameRate_);
}
inline ElementType& operator[](int frameIndex) {
return container[frameIndex];
}
inline const ElementType& operator[](int frameIndex) const {
return container[frameIndex];
}
inline ElementType& at(int frameIndex) {
return container[frameIndex];
}
inline const ElementType& at(int frameIndex) const {
return container[frameIndex];
}
virtual bool read(const YamlMapping& archive) { return SeqBase::read(archive); }
virtual bool write(YamlWriter& writer) { return SeqBase::write(writer); }
protected:
std::vector<ElementType> container;
double frameRate_;
virtual ElementType defaultValue() const { return ElementType(); }
};
}
#endif
|