]> git.mxchange.org Git - flightgear.git/commitdiff
Use SGRawValueMethods rather than SGRawValueFunctions because that allows one to...
authorehofman <ehofman>
Fri, 28 May 2004 08:46:33 +0000 (08:46 +0000)
committerehofman <ehofman>
Fri, 28 May 2004 08:46:33 +0000 (08:46 +0000)
src/AIModel/AIBase.cxx
src/AIModel/AIBase.hxx
src/AIModel/AIManager.cxx

index 8759b3a662be25cb771abcde00715a7940a6a469..182c3e11459b5918ea14889c5864ad1f3d2e103a 100644 (file)
@@ -117,18 +117,22 @@ void FGAIBase::bind() {
    props->tie("id", SGRawValuePointer<int>(&id));
    props->tie("velocities/true-airspeed-kt",  SGRawValuePointer<double>(&speed));
    props->tie("velocities/vertical-speed-fps",
-               SGRawValueFunctions<double>(FGAIBase::_getVS_fps,
-                                           FGAIBase::_setVS_fps, this));
+               SGRawValueMethods<FGAIBase,double>(*this,
+                                         FGAIBase::_getVS_fps,
+                                         FGAIBase::_setVS_fps));
 
    props->tie("position/altitude-ft",
-               SGRawValueFunctions<double>(FGAIBase::_getAltitude,
-                                           FGAIBase::_setAltitude, this));
+               SGRawValueMethods<FGAIBase,double>(*this,
+                                         FGAIBase::_getAltitude,
+                                         FGAIBase::_setAltitude));
    props->tie("position/latitude-deg",
-               SGRawValueFunctions<double>(FGAIBase::_getLatitude,
-                                           FGAIBase::_setLatitude, this));
+               SGRawValueMethods<FGAIBase,double>(*this,
+                                         FGAIBase::_getLatitude,
+                                         FGAIBase::_setLatitude));
    props->tie("position/longitude-deg",
-               SGRawValueFunctions<double>(FGAIBase::_getLongitude,
-                                           FGAIBase::_setLongitude, this));
+               SGRawValueMethods<FGAIBase,double>(*this,
+                                         FGAIBase::_getLongitude,
+                                         FGAIBase::_setLongitude));
 
    props->tie("orientation/pitch-deg",   SGRawValuePointer<double>(&pitch));
    props->tie("orientation/roll-deg",    SGRawValuePointer<double>(&roll));
@@ -144,7 +148,7 @@ void FGAIBase::bind() {
    props->tie("radar/rotation", SGRawValuePointer<double>(&rotation));
 
    props->tie("controls/lighting/nav-lights",
-               SGRawValueFunctions<bool>(FGAIBase::_isNight));
+               SGRawValueMethods<FGAIBase,bool>(*this, _isNight));
    props->setBoolValue("controls/lighting/beacon", true);
    props->setBoolValue("controls/lighting/strobe", true);
 }
@@ -178,46 +182,37 @@ void FGAIBase::unbind() {
 /*
  * getters and Setters
  */
-void FGAIBase::_setLongitude( double longitude, void *p ) {
-    FGAIBase *self = (FGAIBase *)p;
-    self->pos.setlon(longitude);
+void FGAIBase::_setLongitude( double longitude ) {
+    pos.setlon(longitude);
 }
-void FGAIBase::_setLatitude ( double latitude, void *p )  {
-    FGAIBase *self = (FGAIBase *)p;
-    self->pos.setlat(latitude);
+void FGAIBase::_setLatitude ( double latitude )  {
+    pos.setlat(latitude);
 }
 
-double FGAIBase::_getLongitude(void *p) {
-    FGAIBase *self = (FGAIBase *)p;
-    return self->pos.lon();
+double FGAIBase::_getLongitude() const {
+    return pos.lon();
 }
-double FGAIBase::_getLatitude (void *p) {
-    FGAIBase *self = (FGAIBase *)p;
-    return self->pos.lat();
+double FGAIBase::_getLatitude () const {
+    return pos.lat();
 }
-double FGAIBase::_getRdot(void *p)      {
-    FGAIBase *self = (FGAIBase *)p;
-    return self->rdot;
+double FGAIBase::_getRdot() const {
+    return rdot;
 }
-double FGAIBase::_getVS_fps(void *p) {
-    FGAIBase *self = (FGAIBase *)p;
-    return self->vs*60.0;
+double FGAIBase::_getVS_fps() const {
+    return vs*60.0;
 }
-void FGAIBase::_setVS_fps( double _vs, void *p ) {
-    FGAIBase *self = (FGAIBase *)p;
-    self->vs = _vs/60.0;
+void FGAIBase::_setVS_fps( double _vs ) {
+    vs = _vs/60.0;
 }
 
-double FGAIBase::_getAltitude(void *p) {
-    FGAIBase *self = (FGAIBase *)p;
-    return self->altitude;
+double FGAIBase::_getAltitude() const {
+    return altitude;
 }
-void FGAIBase::_setAltitude( double _alt, void *p ) {
-    FGAIBase *self = (FGAIBase *)p;
-    self->setAltitude( _alt );
+void FGAIBase::_setAltitude( double _alt ) {
+    setAltitude( _alt );
 }
 
-bool FGAIBase::_isNight() {
+bool FGAIBase::_isNight() const {
     return (fgGetFloat("/sim/time/sun-angle-rad") > 1.57);
 }
 
index cdca809f5066a4acc4903575e3c6f31da5717271..d418d9237b083fa2a81cdc0b7afe281b9f764512 100644 (file)
@@ -115,32 +115,30 @@ public:
     object_type getType();
     bool isa( object_type otype );
 
-    static double _getVS_fps(void *p);
-    static void _setVS_fps( double _vs, void *p );
+    double _getVS_fps() const;
+    void _setVS_fps( double _vs );
 
-    static double _getAltitude(void *p);
-    static void _setAltitude( double _alt, void *p );
+    double _getAltitude() const;
+    void _setAltitude( double _alt );
 
-    static void _setLongitude( double longitude, void *p );
-    static void _setLatitude ( double latitude, void *p );
+    void _setLongitude( double longitude );
+    void _setLatitude ( double latitude );
 
-    static double _getLongitude(void *p);
-    static double _getLatitude (void *p);
+    double _getLongitude() const;
+    double _getLatitude () const;
 
-    static double _getBearing(void *p);
-    static double _getElevation(void *p);
-    inline double _getRange() { return range; };
-    static double _getRdot(void *p);
-    static double _getH_offset(void *p);
-    static double _getV_offset(void *p);
-    static double _getX_shift(void *p);
-    static double _getY_shift(void *p);
-    static double _getRotation(void *p);
+    double _getBearing() const;
+    double _getElevation() const;
+    double _getRdot() const;
+    double _getH_offset() const;
+    double _getV_offset() const;
+    double _getX_shift() const;
+    double _getY_shift() const;
+    double _getRotation() const;
 
-    static bool _isNight();
+    inline double _getRange() { return range; };
 
-private:
-    FGAIBase *self;
+    bool _isNight() const;
 };
 
 
index dad75ddac63232ab953e82c079b68efc54639d25..b53ac439b3686443dfcff2a3bd6ba7e9d62dde15 100644 (file)
@@ -217,7 +217,6 @@ int FGAIManager::createAircraft( string model_class, string path,
               double heading, double speed, double pitch, double roll ) {
      
         FGAIAircraft* ai_plane = new FGAIAircraft(this);
-cout << "ai_plane: " << ai_plane << endl;
         ai_list.push_back(ai_plane);
         ai_plane->setID( assignID() );
         ++numObjects;
@@ -249,7 +248,6 @@ int FGAIManager::createAircraft( string model_class, string path,
               FGAIFlightPlan* flightplan ) {
      
         FGAIAircraft* ai_plane = new FGAIAircraft(this);
-cout << "ai_plane1: " << ai_plane << endl;
         ai_list.push_back(ai_plane);
         ai_plane->setID( assignID() );
         ++numObjects;