#include <OSGSharedObjectHandler.h>

Public Types | |
| enum | SharedObjectType { Invalid = 0x0000, Application = 0x0001, SharedLibrary = 0x0002 } |
Public Member Functions | |
| bool | open (void) |
| AnonSymbolHandle | getSymbol (const Char8 *szSymbolName) |
| bool | isOpen (void) |
| bool | reOpen (void) |
| const std::string & | getName (void) |
| const Char8 * | getCName (void) |
| void | dump (void) |
Reference Counting | |
| void | addRef (void) |
| void | subRef (void) |
| Int32 | getRefCount (void) |
Protected Member Functions | |
| SharedObject (const Char8 *szName) | |
| virtual | ~SharedObject (void) |
| bool | close (void) |
Protected Attributes | |
| std::string | _szName |
| SharedHandle | _pHandle |
| SharedObjectType | _type |
Static Protected Attributes | |
| static Char8 | _szApplicationObjectName [] = "Application" |
Private Types | |
| typedef MemoryObject | Inherited |
Private Member Functions | |
| SharedObject (const SharedObject &source) | |
| void | operator= (const SharedObject &source) |
Friends | |
| class | SharedObjectHandler |
Definition at line 99 of file OSGSharedObjectHandler.h.
typedef MemoryObject osg::SharedObject::Inherited [private] |
Definition at line 132 of file OSGSharedObjectHandler.h.
Definition at line 111 of file OSGSharedObjectHandler.h.
00112 { 00113 Invalid = 0x0000, 00114 Application = 0x0001, 00115 SharedLibrary = 0x0002 00116 };
| osg::SharedObject::SharedObject | ( | const SharedObject & | source | ) | [private] |
| SharedObject::SharedObject | ( | const Char8 * | szName | ) | [protected] |
Definition at line 109 of file OSGSharedObjectHandler.cpp.
References _szApplicationObjectName, _szName, _type, Application, and FINFO.
00109 : 00110 Inherited( ), 00111 _szName ( ), 00112 _pHandle (NULL ), 00113 _type (Invalid) 00114 { 00115 if(szName == NULL) 00116 { 00117 _szName.assign(_szApplicationObjectName); 00118 00119 _type = Application; 00120 } 00121 else 00122 { 00123 _szName.assign(szName); 00124 00125 _type = SharedLibrary; 00126 } 00127 00128 FINFO(("construct SharedObject %s\n", _szName.c_str())); 00129 }
| SharedObject::~SharedObject | ( | void | ) | [protected, virtual] |
| void osg::SharedObject::operator= | ( | const SharedObject & | source | ) | [private] |
| bool SharedObject::close | ( | void | ) | [protected] |
Definition at line 136 of file OSGSharedObjectHandler.cpp.
References _pHandle.
Referenced by reOpen().
00137 { 00138 bool returnValue = false; 00139 00140 if(_pHandle != NULL) 00141 { 00142 #ifndef WIN32 00143 returnValue = (dlclose(_pHandle) == 0); 00144 #else 00145 returnValue = FreeLibrary(_pHandle); 00146 #endif 00147 _pHandle = NULL; 00148 } 00149 00150 return returnValue; 00151 }
| bool SharedObject::open | ( | void | ) |
Definition at line 159 of file OSGSharedObjectHandler.cpp.
References _pHandle, _szName, _type, and FWARNING.
Referenced by osg::SharedObjectHandler::getSharedObject(), getSymbol(), and reOpen().
00160 { 00161 const Char8 *libName = NULL; 00162 00163 if(_pHandle != NULL) 00164 { 00165 return true; 00166 } 00167 00168 if(_type == SharedLibrary) 00169 { 00170 libName = _szName.c_str(); 00171 } 00172 00173 #ifndef WIN32 00174 #ifdef OSG_DLOPEN_LAZY 00175 _pHandle = dlopen(libName, RTLD_LAZY); 00176 #else 00177 _pHandle = dlopen(libName, RTLD_NOW); 00178 #endif 00179 00180 if(_pHandle == NULL) 00181 { 00182 FWARNING(("Could not open shared object : %s\n", dlerror())); 00183 } 00184 #else 00185 00186 if(libName == NULL) 00187 { 00188 Char8 szModuleName[1024]; 00189 00190 GetModuleFileName(NULL, szModuleName, 1024); 00191 00192 _pHandle = LoadLibrary(szModuleName); 00193 } 00194 else 00195 { 00196 _pHandle = LoadLibrary(libName); 00197 } 00198 #endif 00199 00200 return (_pHandle != NULL); 00201 }
| AnonSymbolHandle SharedObject::getSymbol | ( | const Char8 * | szSymbolName | ) |
Definition at line 203 of file OSGSharedObjectHandler.cpp.
References _pHandle, FWARNING, isOpen(), and open().
00204 { 00205 AnonSymbolHandle returnValue = NULL; 00206 00207 if(isOpen() == false) 00208 { 00209 if(open() == false) 00210 { 00211 return returnValue; 00212 } 00213 } 00214 00215 if(_pHandle != NULL && szSymbolName != NULL) 00216 { 00217 #ifndef WIN32 00218 returnValue = dlsym(_pHandle, szSymbolName); 00219 #else 00220 returnValue = GetProcAddress(_pHandle, szSymbolName); 00221 #endif 00222 } 00223 00224 #ifndef WIN32 00225 if(returnValue == NULL) 00226 { 00227 FWARNING(("could not get symbol %s : %s\n", szSymbolName, dlerror())); 00228 } 00229 #else 00230 #endif 00231 00232 return returnValue; 00233 }
| bool SharedObject::isOpen | ( | void | ) |
Definition at line 235 of file OSGSharedObjectHandler.cpp.
References _pHandle.
Referenced by getSymbol().
00236 { 00237 return _pHandle != NULL; 00238 }
| bool SharedObject::reOpen | ( | void | ) |
| const std::string & SharedObject::getName | ( | void | ) |
Definition at line 247 of file OSGSharedObjectHandler.cpp.
References _szName.
Referenced by osg::SharedObjectHandler::getSharedObject().
00248 { 00249 return _szName; 00250 }
| const Char8 * SharedObject::getCName | ( | void | ) |
Definition at line 252 of file OSGSharedObjectHandler.cpp.
References _szName.
Referenced by osg::SharedObjectHandler::removeSharedObject().
00253 { 00254 return _szName.c_str(); 00255 }
| void SharedObject::dump | ( | void | ) |
| void MemoryObject::addRef | ( | void | ) | [inherited] |
Definition at line 64 of file OSGMemoryObject.cpp.
References osg::MemoryObject::_refCount.
Referenced by osg::SharedObjectHandler::getSharedObject(), and osg::SharedObjectHandler::initialize().
00065 { 00066 _refCount++; 00067 }
| void MemoryObject::subRef | ( | void | ) | [inherited] |
| Int32 MemoryObject::getRefCount | ( | void | ) | [inherited] |
Definition at line 77 of file OSGMemoryObject.cpp.
References osg::MemoryObject::_refCount.
00078 { 00079 return _refCount; 00080 }
friend class SharedObjectHandler [friend] |
Definition at line 138 of file OSGSharedObjectHandler.h.
Char8 SharedObject::_szApplicationObjectName = "Application" [static, protected] |
Definition at line 179 of file OSGSharedObjectHandler.h.
Referenced by osg::SharedObjectHandler::findSharedObject(), osg::SharedObjectHandler::removeSharedObject(), and SharedObject().
std::string osg::SharedObject::_szName [protected] |
Definition at line 189 of file OSGSharedObjectHandler.h.
Referenced by dump(), getCName(), getName(), open(), SharedObject(), and ~SharedObject().
SharedHandle osg::SharedObject::_pHandle [protected] |
Definition at line 190 of file OSGSharedObjectHandler.h.
Referenced by close(), dump(), getSymbol(), isOpen(), and open().
SharedObjectType osg::SharedObject::_type [protected] |
1.5.5