X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FNavaids%2Fpositioned.hxx;h=8b4fb6a3f8c4b4c86e9816d9ed50677eb86efbb4;hb=b30408b862ae0a300ff32ef90b20cdde9efdd499;hp=42476d8545e17c44d97f78de2c5fa5703371e8df;hpb=8d56b4664ac77597571dbc0a40459fecf2b4c44e;p=flightgear.git diff --git a/src/Navaids/positioned.hxx b/src/Navaids/positioned.hxx index 42476d854..8b4fb6a3f 100644 --- a/src/Navaids/positioned.hxx +++ b/src/Navaids/positioned.hxx @@ -32,6 +32,7 @@ class FGPositioned; typedef SGSharedPtr FGPositionedRef; +typedef std::vector FGPositionedList; typedef int64_t PositionedID; typedef std::vector PositionedIDVec; @@ -91,8 +92,6 @@ public: LAST_TYPE } Type; - typedef std::vector List; - virtual ~FGPositioned(); Type type() const @@ -164,7 +163,7 @@ public: class TypeFilter : public Filter { public: - TypeFilter(Type aTy); + TypeFilter(Type aTy = INVALID); virtual bool pass(FGPositioned* aPos) const; virtual Type minType() const @@ -174,14 +173,17 @@ public: { return mMaxType; } void addType(Type aTy); + + static TypeFilter fromString(const std::string& aFilterSpec); private: + std::vector types; Type mMinType, mMaxType; }; - static List findWithinRange(const SGGeod& aPos, double aRangeNm, Filter* aFilter = NULL); + static FGPositionedList findWithinRange(const SGGeod& aPos, double aRangeNm, Filter* aFilter = NULL); - static List findWithinRangePartial(const SGGeod& aPos, double aRangeNm, Filter* aFilter, bool& aPartial); + static FGPositionedList findWithinRangePartial(const SGGeod& aPos, double aRangeNm, Filter* aFilter, bool& aPartial); static FGPositionedRef findClosestWithIdent(const std::string& aIdent, const SGGeod& aPos, Filter* aFilter = NULL); @@ -191,17 +193,17 @@ public: * Find all items with the specified ident * @param aFilter - optional filter on items */ - static List findAllWithIdent(const std::string& aIdent, Filter* aFilter = NULL, bool aExact = true); + static FGPositionedList findAllWithIdent(const std::string& aIdent, Filter* aFilter = NULL, bool aExact = true); /** * As above, but searches names instead of idents */ - static List findAllWithName(const std::string& aName, Filter* aFilter = NULL, bool aExact = true); + static FGPositionedList findAllWithName(const std::string& aName, Filter* aFilter = NULL, bool aExact = true); /** * Sort an FGPositionedList by distance from a position */ - static void sortByRange(List&, const SGGeod& aPos); + static void sortByRange(FGPositionedList&, const SGGeod& aPos); /** * Find the closest item to a position, which pass the specified filter @@ -223,53 +225,31 @@ public: * @param aN - number of matches to find * @param aCutoffNm - maximum distance to search within, in nautical miles */ - static List findClosestN(const SGGeod& aPos, unsigned int aN, double aCutoffNm, Filter* aFilter = NULL); + static FGPositionedList findClosestN(const SGGeod& aPos, unsigned int aN, double aCutoffNm, Filter* aFilter = NULL); /** * Same as above, but with a time-bound in msec too. */ - static List findClosestNPartial(const SGGeod& aPos, unsigned int aN, double aCutoffNm, Filter* aFilter, + static FGPositionedList findClosestNPartial(const SGGeod& aPos, unsigned int aN, double aCutoffNm, Filter* aFilter, bool& aPartial); - - /** - * Map a candidate type string to a real type. Returns INVALID if the string - * does not correspond to a defined type. - */ - static Type typeFromName(const std::string& aName); - - /** - * Map a type to a human-readable string - */ - static const char* nameForType(Type aTy); - static FGPositioned* createUserWaypoint(const std::string& aIdent, const SGGeod& aPos); - static void deleteUserWaypoint(const std::string& aIdent); -protected: - friend class flightgear::NavDataCache; - - FGPositioned(PositionedID aGuid, Type ty, const std::string& aIdent, const SGGeod& aPos); - - void modifyPosition(const SGGeod& newPos); - - static FGPositioned* loadByIdImpl(PositionedID id); - template - static T* loadById(PositionedID id) + static SGSharedPtr loadById(PositionedID id) { - return static_cast( loadByIdImpl(id) ); + return static_pointer_cast( loadByIdImpl(id) ); } template - static T* loadById(const PositionedIDVec& id_vec, size_t index) + static SGSharedPtr loadById(const PositionedIDVec& id_vec, size_t index) { assert(index >= 0 && index < id_vec.size()); return loadById(id_vec[index]); } template - static std::vector loadAllById(const PositionedIDVec& id_vec) + static std::vector > loadAllById(const PositionedIDVec& id_vec) { - std::vector vec(id_vec.size()); + std::vector > vec(id_vec.size()); for(size_t i = 0; i < id_vec.size(); ++i) vec[i] = loadById(id_vec[i]); @@ -277,6 +257,28 @@ protected: return vec; } + /** + * Map a candidate type string to a real type. Returns INVALID if the string + * does not correspond to a defined type. + */ + static Type typeFromName(const std::string& aName); + + /** + * Map a type to a human-readable string + */ + static const char* nameForType(Type aTy); + + static FGPositioned* createUserWaypoint(const std::string& aIdent, const SGGeod& aPos); + static bool deleteUserWaypoint(const std::string& aIdent); +protected: + friend class flightgear::NavDataCache; + + FGPositioned(PositionedID aGuid, Type ty, const std::string& aIdent, const SGGeod& aPos); + + void modifyPosition(const SGGeod& newPos); + + static FGPositionedRef loadByIdImpl(PositionedID id); + const PositionedID mGuid; const SGGeod mPosition; const SGVec3d mCart;