/usr/include/bulletml/formula.h is in libbulletml-dev 0.0.6-6.
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 | /// �����N���X
#ifndef FORMULA_H_
#define FORMULA_H_
#include "bulletmlcommon.h"
template <typename Val_>
class AbstractNumber {
public:
DECLSPEC virtual Val_ value() const =0;
DECLSPEC virtual ~AbstractNumber() {}
};
template <typename Val_>
class Number : public AbstractNumber<Val_> {
public:
DECLSPEC explicit Number(Val_ val) : val_(val) {}
DECLSPEC virtual Val_ value() const { return val_; }
private:
Val_ val_;
};
typedef enum { op_null =0, op_add, op_sub, op_mul, op_div } Operator;
template <typename Val_>
class Formula : public AbstractNumber<Val_> {
private:
typedef AbstractNumber<Val_> ANumber;
public:
DECLSPEC virtual ~Formula() {
delete lhs_;
delete rhs_;
}
/// public �����njĂȂ��ʼn������B
/**
* @todo yacc �̎g�������ׂāA����� private ��
*/
//@{
DECLSPEC explicit Formula(ANumber* val)
: lhs_(val), rhs_(0), op_(op_null), headsub_(false) {}
DECLSPEC Formula(ANumber* lhs, Operator op, ANumber* rhs)
: lhs_(lhs), rhs_(rhs), op_(op), headsub_(false) {}
DECLSPEC Formula* setHeadSub() { headsub_ = true; return this; }
//@}
DECLSPEC virtual Val_ value() const {
if (headsub_) return -valueBeforeHeadSub();
else return valueBeforeHeadSub();
}
private:
Val_ valueBeforeHeadSub() const {
switch (op_) {
case op_null:
return lhs_->value();
case op_add:
return lhs_->value() + rhs_->value();
case op_sub:
return lhs_->value() - rhs_->value();
case op_mul:
return lhs_->value() * rhs_->value();
case op_div:
return lhs_->value() / rhs_->value();
default:
return 0; // avoid warning
}
}
private:
ANumber *lhs_, *rhs_;
Operator op_;
bool headsub_;
};
#endif // ! FORMULA_H_
|