X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FScripting%2FNasalModelData.hxx;h=dbe59b76132207d276039c0d7b39cee46a033645;hb=3b23892ccf9c33d05fa642e025c5bdba739bba3b;hp=ea472451b9de71bce4691df9666b3affb0426239;hpb=7b663cd7f7aaceb185a5970b5ea43f8445cc58f1;p=flightgear.git diff --git a/src/Scripting/NasalModelData.hxx b/src/Scripting/NasalModelData.hxx index ea472451b..dbe59b761 100644 --- a/src/Scripting/NasalModelData.hxx +++ b/src/Scripting/NasalModelData.hxx @@ -20,7 +20,9 @@ #include #include -using std::string; +class FGNasalModelData; +typedef SGSharedPtr FGNasalModelDataRef; +typedef std::list FGNasalModelDataList; /** Nasal model data container. * load and unload methods must be run in main thread (not thread-safe). */ @@ -28,26 +30,45 @@ class FGNasalModelData : public SGReferenced { public: /** Constructor to be run in an arbitrary thread. */ - FGNasalModelData(SGPropertyNode *root, const string& path, SGPropertyNode *prop, - SGPropertyNode* load, SGPropertyNode* unload) : - _path(path), - _root(root), _prop(prop), - _load(load), _unload(unload) - { - } + FGNasalModelData( SGPropertyNode *root, + const std::string& path, + SGPropertyNode *prop, + SGPropertyNode* load, + SGPropertyNode* unload, + osg::Node* branch ); + ~FGNasalModelData(); + /** Load hook. Always call from inside the main loop. */ void load(); /** Unload hook. Always call from inside the main loop. */ void unload(); + /** + * Get osg scenegraph node of model + */ + osg::Node* getNode(); + + /** + * Get FGNasalModelData for model with the given module id. Every scenery + * model containing a nasal load or unload tag gets assigned a module id + * automatically. + * + * @param id Module id + * @return model data or NULL if does not exists + */ + static FGNasalModelData* getByModuleId(unsigned int id); + private: - static unsigned int _module_id; - - string _module, _path; + static unsigned int _max_module_id; + static FGNasalModelDataList _loaded_models; + + std::string _module, _path; SGPropertyNode_ptr _root, _prop; SGConstPropertyNode_ptr _load, _unload; + osg::ref_ptr _branch; + unsigned int _module_id; }; /** Thread-safe proxy for FGNasalModelData. @@ -64,11 +85,15 @@ public: ~FGNasalModelDataProxy(); - void modelLoaded(const string& path, SGPropertyNode *prop, osg::Node *); + void modelLoaded( const std::string& path, + SGPropertyNode *prop, + osg::Node *branch ); + virtual FGNasalModelDataProxy* clone() const { return new FGNasalModelDataProxy(_root); } + protected: SGPropertyNode_ptr _root; - SGSharedPtr _data; + FGNasalModelDataRef _data; }; #endif // of NASAL_MODEL_DATA_HXX