#ifndef SONSOR_DEF_H #define SONSOR_DEF_H namespace algorithm{ namespace base{ //传感器类 template class Sensor{ public: Sensor(){ value = 0; }; virtual ~Sensor(){}; protected: T value; public: virtual T& GetValue(){return value;}; virtual void SetValue(const T& val){ this->value = val; } }; //加速度计 template class Accelerometer:public Sensor{ public: Accelerometer(){ x = y = z = value = 0; }; Accelerometer(const T& x,const T& y,const T& z){ this->x = x; this->y = y; this->z = z; value = 0; }; ~Accelerometer(){}; private: T x; T y; T z; T value; public: T& getX(){return x;} void setX(const T& v){this->x = v;} T& getY(){return y;} void setY(const T& v){this->y = v;} T& getZ(){return z;} void setZ(const T& v){this->z = v;} virtual void SetValue(const T& val){ value = val; } virtual T& GetValue(){ return value; }; }; //磁感应计 template class MagneticSensor:public Sensor{ public: MagneticSensor(){}; ~MagneticSensor(){}; }; //陀螺仪 template class Gyroscope:public Sensor{ public: Gyroscope(){ value = 0; } ~Gyroscope(){} private: T value; public: virtual T& GetValue(){return value;}; virtual void SetValue(const T& val){ this->value = val; } }; }; }; #endif