/* */ %module pyplanet %{ #include #include #include #include #include #include %} class OSSIMPLANET_DLL ossimPlanetCallback : public osg::Referenced { public: ossimPlanetCallback() :theEnableFlag(true) {} void setEnableFlag(bool flag) { OpenThreads::ScopedLock lock(theCallbackMutex); theEnableFlag = flag; } bool enableFlag()const { OpenThreads::ScopedLock lock(theCallbackMutex); return theEnableFlag; } protected: mutable ossimPlanetReentrantMutex theCallbackMutex; bool theEnableFlag; }; template class ossimPlanetCallbackListInterface { public: typedef std::vector > CallbackListType; ossimPlanetCallbackListInterface() :theBlockCallbacksFlag(false) { } virtual ~ ossimPlanetCallbackListInterface(){} virtual void addCallback(T* callback) { OpenThreads::ScopedLock lock(theCallbackListMutex); if(!hasCallbackNoMutex(callback)) { theCallbackList.push_back(callback); } } virtual void addCallback(osg::ref_ptr callback) { addCallback(callback.get()); } virtual void removeCallback(T* callback); virtual void removeCallback(osg::ref_ptr callback) { removeCallback(callback.get()); } virtual void blockCallbacks(bool flag) { OpenThreads::ScopedLock lock(theCallbackListMutex); theBlockCallbacksFlag = flag; } bool hasCallback(const T* callback)const; protected: bool hasCallbackNoMutex(const T* callback)const; mutable ossimPlanetReentrantMutex theCallbackListMutex; CallbackListType theCallbackList; bool theBlockCallbacksFlag; }; template void ossimPlanetCallbackListInterface::removeCallback(T* callback) { OpenThreads::ScopedLock lock(theCallbackListMutex); unsigned int idx; for(idx = 0; idx < theCallbackList.size(); ++idx) { if(theCallbackList[idx] == callback) { theCallbackList.erase(theCallbackList.begin() + idx); break; } } } template bool ossimPlanetCallbackListInterface::hasCallback(const T* callback)const { OpenThreads::ScopedLock lock(theCallbackListMutex); return hasCallbackNoMutex(callback); } template bool ossimPlanetCallbackListInterface::hasCallbackNoMutex(const T* callback)const; /*%template(ossimPlanetCallbackIface_ossimPlanetOperationCallback) ossimPlanetCallbackListInterface;*/ /*%template(ossimPlanetCallbackIface_ossimPlanetNodeCallback) ossimPlanetCallbackListInterface;*/ /*%template(ossimPlanetCallbackIface_ossimPlanetTextureLayerCallback) ossimPlanetCallbackListInterface;*/ /*%template(ossimPlanetCallbackIface_ossimPlanetLsrSpaceTransformCallback)ossimPlanetCallbackListInterface< ossimPlanetLsrSpaceTransformCallback >;*/