/usr/include/bulletml/bulletmlrunnerimpl.h is in libbulletml-dev 0.0.6-5.
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 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | #ifndef BULLETRUNNER_IMPL_H_
#define BULLETRUNNER_IMPL_H_
#include "bulletmltree.h"
#include <vector>
#include <memory>
#include <stack>
#include <tr1/memory>
class BulletMLRunner;
class BulletMLState;
class BulletMLParser;
typedef std::vector<double> BulletMLParameter;
template<class C_>
class Validatable {
public:
Validatable() : isValidate_(false) {}
bool isValidate() const { return isValidate_; }
void enValidate() { isValidate_ = true; }
void disValidate() { isValidate_ = false; }
operator C_& () { return val_; }
C_& operator = (const C_& rhs) {
isValidate_ = true;
val_ = rhs;
return *this;
}
protected:
C_ val_;
bool isValidate_;
};
/// xy�̏����l�E�I�l����C�ӂ�x�ɑ���y�̐��`��Ԃ�N���X
template <class X_ = double, class Y_ = double>
class LinearFunc {
public:
LinearFunc(const X_& firstX, const X_& lastX,
const Y_& firstY, const Y_& lastY)
: firstX_(firstX), lastX_(lastX),
firstY_(firstY), lastY_(lastY),
gradient_((lastY-firstY)/(lastX-firstX)) {}
Y_ getValue(const X_& x) {
return firstY_ + gradient_ * (x-firstX_);
}
bool isLast(const X_& x) {
return x >= lastX_;
}
Y_ getLast() {
return lastY_;
}
protected:
X_ firstX_, lastX_;
Y_ firstY_, lastY_;
Y_ gradient_;
};
class BulletMLRunnerImpl {
public:
explicit BulletMLRunnerImpl(BulletMLState* state, BulletMLRunner* runner);
virtual ~BulletMLRunnerImpl();
/// ���s����
void run();
public:
/// ���s���I�����Ă��邩�ǂ���
bool isEnd() const {
return end_;
}
public:
/// �e�̕����ύX��o�^���A���O�Ŋe�^�[���ύX����
virtual void calcChangeDirection(double direction, int term, bool seq);
/// �e�̑��x�ύX��o�^���A���O�Ŋe�^�[���ύX����
virtual void calcChangeSpeed(double speed, int term);
/// �e�̉�����o�^���A���O�Ŋe�^�[���ύX����
/**
* @todo horizontal, vertical �� type �͖������ł��B
*/
virtual void calcAccelX(double vertical, int term,
BulletMLNode::Type type);
/// �e�̉�����o�^���A���O�Ŋe�^�[���ύX����
/**
* @todo horizontal, vertical �� type �͖������ł��B
*/
virtual void calcAccelY(double horizontal, int term,
BulletMLNode::Type type);
protected:
/**
* �{���ɋ������C�ɓ���Ȃ��ꍇ�͉��z�������āA
* �����̃I�[�o�[���C�h���l���Ă��������B
*/
//@{
void runBullet();
void runAction();
void runFire();
void runWait();
void runRepeat();
void runBulletRef();
void runActionRef();
void runFireRef();
void runChangeDirection();
void runChangeSpeed();
void runAccel();
void runVanish();
//@}
private:
void changes();
void runSub();
void init();
bool isTurnEnd();
void doWait(int frame);
void setDirection();
void setSpeed();
void shotInit() {
spd_.disValidate();
dir_.disValidate();
}
double getNumberContents(const BulletMLNode* node);
std::vector<double>* getParameters();
double getSpeed(BulletMLNode* spdNode);
double getDirection(BulletMLNode* dirNode);
private:
private:
std::auto_ptr<LinearFunc<int, double> > changeDir_;
std::auto_ptr<LinearFunc<int, double> > changeSpeed_;
std::auto_ptr<LinearFunc<int, double> > accelx_;
std::auto_ptr<LinearFunc<int, double> > accely_;
protected:
Validatable<double> spd_, dir_, prevSpd_, prevDir_;
typedef BulletMLParameter Parameters;
std::tr1::shared_ptr<Parameters> parameters_;
protected:
BulletMLParser* bulletml_;
BulletMLNode* act_;
std::vector<BulletMLNode*> node_;
int actTurn_;
std::vector<int> actTurns_;
int endTurn_;
size_t actIte_;
bool end_;
protected:
struct RepeatElem {
RepeatElem(int i, int e, BulletMLNode* a)
: ite(i), end(e), act(a) {}
int ite, end;
BulletMLNode* act;
};
typedef std::stack<RepeatElem*> RepeatStack;
RepeatStack repeatStack_;
typedef std::stack<std::pair<BulletMLNode*,
std::tr1::shared_ptr<Parameters> > > RefStack;
RefStack refStack_;
typedef void (BulletMLRunnerImpl::*Method)();
static Method commandMap_[BulletMLNode::nameSize];
protected:
BulletMLRunner* runner_;
};
#endif // ! BULLETRUNNER_IMPL_H_
|