]> git.mxchange.org Git - flightgear.git/commitdiff
std:: namespace fixes, AIBase cleanup.
authorJames Turner <zakalawe@mac.com>
Thu, 28 Mar 2013 16:49:52 +0000 (16:49 +0000)
committerJames Turner <zakalawe@mac.com>
Thu, 28 Mar 2013 16:49:52 +0000 (16:49 +0000)
Make data members in AIBase protected, and move FGAIModelData to be
a private helper in the .cxx file.

18 files changed:
src/AIModel/AIAircraft.hxx
src/AIModel/AIBallistic.cxx
src/AIModel/AIBallistic.hxx
src/AIModel/AIBase.cxx
src/AIModel/AIBase.hxx
src/AIModel/AIFlightPlan.cxx
src/AIModel/AIFlightPlanCreate.cxx
src/AIModel/AIFlightPlanCreateCruise.cxx
src/AIModel/AIFlightPlanCreatePushBack.cxx
src/AIModel/AIGroundVehicle.cxx
src/AIModel/AIMultiplayer.cxx
src/AIModel/AIShip.cxx
src/AIModel/AIShip.hxx
src/AIModel/AITanker.cxx
src/AIModel/AITanker.hxx
src/AIModel/submodel.cxx
src/ATC/atc_mgr.cxx
src/Main/positioninit.cxx

index 58fd417f63306816f8702942abf1e0714244d9b3..2f7c2d547e433b8c54101d800790baea46e912a6 100644 (file)
@@ -52,7 +52,7 @@ public:
     void initializeFlightPlan();
     FGAIFlightPlan* GetFlightPlan() const { return fp; };
     void ProcessFlightPlan( double dt, time_t now );
-    time_t checkForArrivalTime(const string& wptName);
+    time_t checkForArrivalTime(const std::string& wptName);
     
     void AccelTo(double speed);
     void PitchTo(double angle);
index 962795e88fc743e09ca074fa69fd001fc62bc33b..5a50034b1518e1c3e314ff36bfc0e3cd64b64939 100644 (file)
@@ -35,6 +35,7 @@
 #include <Environment/gravity.hxx>
 
 using namespace simgear;
+using std::string;
 
 const double FGAIBallistic::slugs_to_kgs = 14.5939029372;
 const double FGAIBallistic::slugs_to_lbs = 32.1740485564;
@@ -505,7 +506,7 @@ bool FGAIBallistic::getHtAGL(double start){
             _ht_agl_ft = pos.getElevationFt() - _elevation_m * SG_METER_TO_FEET;
 
             if (material) {
-                const vector<string>& names = material->get_names();
+                const std::vector<string>& names = material->get_names();
                 _solid = material->get_solid();
                 _load_resistance = material->get_load_resistance();
                 _frictionFactor = material->get_friction_factor();
index fbbeeb4d7eb54f28560b65569658d6741c6c3478..ca8b92879bb125486994efc416c568c3053f8c60 100644 (file)
@@ -31,9 +31,6 @@
 #include "AIManager.hxx"
 #include "AIBase.hxx"
 
-using std::vector;
-using std::list;
-
 class FGAIBallistic : public FGAIBase {
 
 public:
@@ -72,15 +69,15 @@ public:
     void setCollision(bool c);
     void setExpiry(bool e);
     void setImpact(bool i);
-    void setImpactReportNode(const string&);
+    void setImpactReportNode(const std::string&);
     void setContentsNode(const SGPropertyNode_ptr);
     void setFuseRange(double f);
-    void setSMPath(const string&);
+    void setSMPath(const std::string&);
     void setSubID(int i);
-    void setSubmodel(const string&);
+    void setSubmodel(const std::string&);
     void setExternalForce( bool f );
-    void setForcePath(const string&);
-    void setContentsPath(const string&);
+    void setForcePath(const std::string&);
+    void setContentsPath(const std::string&);
     void setForceStabilisation( bool val );
     void setGroundOffset(double g);
     void setLoadOffset(double l);
@@ -188,7 +185,7 @@ private:
     bool   _slave_load_to_ac;// if true, object will be slaved to the parent ac pos
     double _contents_lb;     // contents of the object
     double _weight_lb;       // weight of the object (no contents if appropriate) (lbs)
-    string _mat_name;
+    std::string _mat_name;
 
     bool   _report_collision;       // if true a collision point with AI Objects is calculated
     bool   _report_impact;          // if true an impact point on the terrain is calculated
@@ -215,9 +212,9 @@ private:
     double _dt_count;
     double _next_run;
 
-    string _submodel;
-    string _force_path;
-    string _contents_path;
+    std::string _submodel;
+    std::string _force_path;
+    std::string _contents_path;
 
     void handle_collision();
     void handle_expiry();
index 01c0c26916aa2c6a1f8f8ead4960abf8c30f4eec..4db3e8f11edae8e09e3c75beb530ee1fa6e9019b 100644 (file)
@@ -53,8 +53,52 @@ const char *default_model = "Models/Geometry/glider.ac";
 const double FGAIBase::e = 2.71828183;
 const double FGAIBase::lbs_to_slugs = 0.031080950172;   //conversion factor
 
+using std::string;
 using namespace simgear;
 
+class FGAIModelData : public simgear::SGModelData {
+public:
+    FGAIModelData(SGPropertyNode *root = NULL)
+        : _nasal( new FGNasalModelDataProxy(root) ),
+        _ready(false),
+        _initialized(false)
+    {
+    }
+
+    
+    ~FGAIModelData()
+    {
+    }
+    
+    /** osg callback, thread-safe */
+    void modelLoaded(const std::string& path, SGPropertyNode *prop, osg::Node *n)
+    {
+        // WARNING: Called in a separate OSG thread! Only use thread-safe stuff here...
+        if (_ready)
+            return;
+        
+        _fxpath = prop->getStringValue("sound/path");
+        _nasal->modelLoaded(path, prop, n);
+        
+        _ready = true;
+
+    }
+    
+    /** init hook to be called after model is loaded.
+     * Not thread-safe. Call from main thread only. */
+    void init(void) { _initialized = true; }
+    
+    bool needInitilization(void) { return _ready && !_initialized;}
+    bool isInitialized(void) { return _initialized;}
+    inline std::string& get_sound_path() { return _fxpath;}
+    
+private:
+    std::auto_ptr<FGNasalModelDataProxy> _nasal;
+    std::string _fxpath;
+    bool _ready;
+    bool _initialized;
+};
+
 FGAIBase::FGAIBase(object_type ot, bool enableHot) :
     _max_speed(300),
     _name(""),
@@ -843,27 +887,4 @@ int FGAIBase::_newAIModelID() {
 }
 
 
-FGAIModelData::FGAIModelData(SGPropertyNode *root)
-  : _nasal( new FGNasalModelDataProxy(root) ),
-    _ready(false),
-    _initialized(false)
-{
-}
 
-FGAIModelData::~FGAIModelData()
-{
-    delete _nasal;
-    _nasal = NULL;
-}
-
-void FGAIModelData::modelLoaded(const string& path, SGPropertyNode *prop, osg::Node *n)
-{
-    // WARNING: Called in a separate OSG thread! Only use thread-safe stuff here...
-    if (_ready)
-        return;
-
-    _fxpath = prop->getStringValue("sound/path");
-    _nasal->modelLoaded(path, prop, n);
-
-    _ready = true;
-}
index 70e7c97184c834ab0ebbea4ad8349cbf52661647..52be8e5a3d89b7b205f671f89ef150d26fc14da3 100644 (file)
 
 #include <string>
 
+#include <osg/LOD>
+
 #include <simgear/constants.h>
 #include <simgear/scene/model/placement.hxx>
-#include <simgear/scene/model/modellib.hxx>
 #include <simgear/misc/sg_path.hxx>
 #include <simgear/structure/SGSharedPtr.hxx>
 #include <simgear/structure/SGReferenced.hxx>
 
 #include <Main/fg_props.hxx>
 
-
-using std::string;
-
 namespace simgear {
 class BVHMaterial;
 }
 class FGAIManager;
 class FGAIFlightPlan;
 class FGFX;
-class FGNasalModelDataProxy;
 class FGAIModelData;    // defined below
 
 
@@ -71,8 +68,8 @@ public:
     void updateLOD();
     void setManager(FGAIManager* mgr, SGPropertyNode* p);
     void setPath( const char* model );
-    void setSMPath( const string& p );
-    void setCallSign(const string& );
+    void setSMPath( const std::string& p );
+    void setCallSign(const std::string& );
     void setSpeed( double speed_KTAS );
     void setAltitude( double altitude_ft );
     void setAltitudeAGL( double altitude_agl_ft );
@@ -95,8 +92,8 @@ public:
     void setImpactLat( double lat );
     void setImpactLon( double lon );
     void setImpactElev( double e );
-    void setParentName(const string& p);
-    void setName(const string& n);
+    void setParentName(const std::string& p);
+    void setName(const std::string& n);
     void setMaxSpeed(double kts);
 
     void calcRangeBearing(double lat, double lon, double lat2, double lon2,
@@ -118,29 +115,31 @@ public:
     bool getGroundElevationM(const SGGeod& pos, double& elev,
                              const simgear::BVHMaterial** material) const;
 
-    double _elevation_m;
 
     double _getCartPosX() const;
     double _getCartPosY() const;
     double _getCartPosZ() const;
+    
+protected:
+    double _elevation_m;
+    
 
     double _x_offset;
     double _y_offset;
     double _z_offset;
-
+    
     double _pitch_offset;
     double _roll_offset;
     double _yaw_offset;
-
+    
     double _max_speed;
-
-    string _path;
-    string _callsign;
-    string _submodel;
+    
+    std::string _path;
+    std::string _callsign;
+    std::string _submodel;
     std::string _name;
-    string _parent;
-
-protected:
+    std::string _parent;
+    
     /**
      * Tied-properties helper, record nodes which are tied for easy un-tie-ing
      */
@@ -195,7 +194,7 @@ protected:
     double rotation;     // value used by radar display instrument
     double ht_diff;      // value used by radar display instrument
 
-    string model_path;   //Path to the 3D model
+    std::string model_path;   //Path to the 3D model
     SGModelPlacement aip;
 
     bool delete_me;
@@ -318,7 +317,7 @@ public:
 
     static bool _isNight();
 
-     string & getCallSign();
+    std::string & getCallSign();
 };
 
 inline void FGAIBase::setManager(FGAIManager* mgr, SGPropertyNode* p) {
@@ -330,7 +329,7 @@ inline void FGAIBase::setPath(const char* model ) {
     model_path.append(model);
 }
 
-inline void FGAIBase::setSMPath(const string& p) {
+inline void FGAIBase::setSMPath(const std::string& p) {
     _path = p;
 }
 
@@ -376,10 +375,10 @@ inline void FGAIBase::setLatitude ( double latitude ) {
     pos.setLatitudeDeg( latitude );
 }
 
-inline void FGAIBase::setCallSign(const string& s) {
+inline void FGAIBase::setCallSign(const std::string& s) {
     _callsign = s;
 }
-inline string& FGAIBase::getCallSign() {
+inline std::string& FGAIBase::getCallSign() {
     return _callsign;
 }
 
@@ -407,11 +406,11 @@ inline void FGAIBase::setYawoffset(double y) {
     _yaw_offset = y;
 }
 
-inline void FGAIBase::setParentName(const string& p) {
+inline void FGAIBase::setParentName(const std::string& p) {
     _parent = p;
 }
 
-inline void FGAIBase::setName(const string& n) {
+inline void FGAIBase::setName(const std::string& n) {
     _name = n;
 }
 
@@ -453,27 +452,4 @@ inline void FGAIBase::setMaxSpeed(double m) {
 }
 
 
-class FGAIModelData : public simgear::SGModelData {
-public:
-    FGAIModelData(SGPropertyNode *root = 0);
-    ~FGAIModelData();
-
-    /** osg callback, thread-safe */
-    void modelLoaded(const string& path, SGPropertyNode *prop, osg::Node *n);
-
-    /** init hook to be called after model is loaded.
-     * Not thread-safe. Call from main thread only. */
-    void init(void) { _initialized = true; }
-
-    bool needInitilization(void) { return _ready && !_initialized;}
-    bool isInitialized(void) { return _initialized;}
-    inline std::string& get_sound_path() { return _fxpath;}
-
-private:
-    FGNasalModelDataProxy *_nasal;
-    std::string _fxpath;
-    bool _ready;
-    bool _initialized;
-};
-
 #endif // _FG_AIBASE_HXX
index ce20ea2b30f44dfcd336bffe821f80695f66cd86..61ba0e56bbccfe345a97ae68518ca903d371c143 100644 (file)
@@ -45,6 +45,7 @@
 #include "AIAircraft.hxx"
 
 using std::cerr;
+using std::string;
 
 FGAIWaypoint::FGAIWaypoint() {
   speed       = 0;
index caad321e2ad3e6ec1022e7a3a428f44c8bf4fb96..9ec77c2c38e56f6c2be1ab4e84966701585ed35f 100644 (file)
@@ -41,6 +41,7 @@
 #include <FDM/LaRCsim/basic_aero.h>
 #include <Navaids/navrecord.hxx>
 
+using std::string;
 
 /* FGAIFlightPlan::create()
  * dynamically create a flight plan for AI traffic, based on data provided by the
index beecef8eb23946941a24563c0731f64234d522e6..709378f90013bc8d16d5278b4e21962b99f39f8d 100644 (file)
@@ -38,6 +38,7 @@
 #include "performancedata.hxx"
 
 using std::iostream;
+using std::string;
 
 /*
 void FGAIFlightPlan::evaluateRoutePart(double deplat,
index cb5ade5cc79bbe3452490b08ed9ec80a192073c5..0e7efc80ce18fae7f674271a1f294b666029788f 100644 (file)
@@ -38,6 +38,7 @@
 #include "AIAircraft.hxx"
 #include "performancedata.hxx"
 
+using std::string;
 
 // TODO: Use James Turner's createOnGround functions.
 bool FGAIFlightPlan::createPushBack(FGAIAircraft *ac,
index b813b3c8211f3e3b2cf1d3f0f72366db4a70ec90..15424079e9bd6448960444764762875add4269a9 100644 (file)
@@ -30,6 +30,8 @@
 
 #include "AIGroundVehicle.hxx"
 
+using std::string;
+
 FGAIGroundVehicle::FGAIGroundVehicle() :
 FGAIShip(otGroundVehicle),
 
index 0c9bd974003cb48bbb92642cee5179433b8a45f5..2b9c09c4e9a726a5418c04c41d1a2204676ac271 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "AIMultiplayer.hxx"
 
+using std::string;
 
 // #define SG_DEBUG SG_ALERT
 
index 0ec8f65f8d3ad7b36587a114056ea57925618adc..a202feb48b677748193e236c046d050078ea7475 100644 (file)
@@ -40,6 +40,7 @@
 
 #include "AIShip.hxx"
 
+using std::string;
 
 FGAIShip::FGAIShip(object_type ot) :
 // allow HOT to be enabled
index 34038db90200615172e7dc20d3f0ba739096e6d1..009b735f58311f92944ee7d0c03d9832e2dc52c6 100644 (file)
@@ -52,9 +52,9 @@ public:
     void YawTo(double angle);
     void ClimbTo(double altitude);
     void TurnTo(double heading);
-    void setCurrName(const string&);
-    void setNextName(const string&);
-    void setPrevName(const string&);
+    void setCurrName(const std::string&);
+    void setNextName(const std::string&);
+    void setPrevName(const std::string&);
     void setLeadAngleGain(double g);
     void setLeadAngleLimit(double l);
     void setLeadAngleProp(double p);
@@ -99,8 +99,8 @@ private:
 
     void setServiceable(bool s);
     void Run(double dt);
-    void setStartTime(const string&);
-    void setUntilTime(const string&);
+    void setStartTime(const std::string&);
+    void setUntilTime(const std::string&);
     //void setWPPos();
     void setWPAlt();
     void setXTrackError();
@@ -110,7 +110,7 @@ private:
     double getRange(double lat, double lon, double lat2, double lon2) const;
     double getCourse(double lat, double lon, double lat2, double lon2) const;
     double getDaySeconds();
-    double processTimeString(const string& time);
+    double processTimeString(const std::string& time);
 
     bool initFlightPlan();
     bool advanceFlightPlan (double elapsed_sec, double day_sec);
@@ -129,9 +129,9 @@ private:
     double _xtrack_error;
     double _curr_alt, _prev_alt;
 
-    string _prev_name, _curr_name, _next_name;
-    string _path;
-    string _start_time, _until_time;
+    std::string _prev_name, _curr_name, _next_name;
+    std::string _path;
+    std::string _start_time, _until_time;
 
     bool _repeat;
     bool _fp_init;
index 6ab43e0349a16ca458e452f32dc6952e838f7a70..73ec625381584d1a4c47db303c939718ff4dfd45 100644 (file)
@@ -25,6 +25,8 @@
 
 #include "AITanker.hxx"
 
+using std::string;
+
 FGAITanker::FGAITanker(FGAISchedule* ref): FGAIAircraft(ref){
 }
 
index 8dcfe11adf6b7ac372b1e0d4396af727427cf673..fcea6a28fcd1ad2a2dd6ff6eb9cb937436eb887c 100644 (file)
@@ -44,10 +44,10 @@ public:
 
     virtual const char* getTypeString(void) const { return "tanker"; }
 
-    void setTACANChannelID(const string& id);
+    void setTACANChannelID(const std::string& id);
     
 private:
-    string TACAN_channel_id;     // The TACAN channel of this tanker
+    std::string TACAN_channel_id;     // The TACAN channel of this tanker
     bool contact;                // set if this tanker is within fuelling range
 
     virtual void Run(double dt);
index dac04da9da2554d53a53431d40cc1fc2d98ca17e..b3721466a9fa53ca3cb5e3e8bbf0bbca684327fc 100644 (file)
@@ -25,6 +25,8 @@
 
 using std::cout;
 using std::endl;
+using std::string;
+using std::vector;
 
 const double FGSubmodelMgr::lbs_to_slugs = 0.031080950172;
 
index 4326af82a5b009e262a08d423b41e9ba56ed58e5..416229ca7ee47bb7213919bc8e503c0c8f91d600 100644 (file)
@@ -32,6 +32,8 @@
 #include "atc_mgr.hxx"
 
 
+using std::string;
+
 FGATCManager::FGATCManager() {
     controller = 0;
     prevController = 0;
index 0c148d6d6d88abaeee0c271d0a7f1f575008d8b7..d189b917b4ae8a01ab339df184897497a4ca4886 100644 (file)
@@ -37,6 +37,7 @@
 #include <AIModel/AIManager.hxx>
 
 using std::endl;
+using std::string;
 
 namespace flightgear
 {