gpucalc::Library Class Reference

This class represnt dynamically loaded libraries (DLLs). More...

#include <library.h>

Inheritance diagram for gpucalc::Library:

Inheritance graph

List of all members.

Public Member Functions

const std::string & getClassName () const
 Returns name of class of our object.
const std::string & getObjectName () const
 Returns name of our object.
void getSpecificParameter (const std::string &ParameterName, void *ParameterValue)
 Method for obtaining some specific parameters, such as texture specific params, and so on.
LIBRARY_HANDLE getSymbol (const std::string &SymbolName) const
 Get symbol from this library.
bool isLoaded () const
bool isLocked () const
 returns state of object.
 Library (const std::string &LibraryName)
 Default constructor.
void load ()
 Loads library.
void unload ()
 Unloads library.
 ~Library ()

Protected Member Functions

void addSpecificParameter (const std::string &ParameterName, void *ParameterValue, size_t Size)
void lock ()
void unlock ()

Private Member Functions

std::string libraryError () const

Private Attributes

LIBRARY_HANDLE mhInst
bool mIsLoaded


Detailed Description

This class represnt dynamically loaded libraries (DLLs).

This class can only load and unload DLL, also can get symbols from this library.

Definition at line 78 of file library.h.


Constructor & Destructor Documentation

gpucalc::Library::Library ( const std::string &  LibraryName  )  [inline]

Default constructor.

Parameters:
LibraryName - path to our library.

Definition at line 91 of file library.h.

00091                                          :
00092     Object(_LibraryClassName, LibraryName), mhInst(0), mIsLoaded(false)
00093    {
00094    }

gpucalc::Library::~Library (  )  [inline]

Definition at line 97 of file library.h.

00098    {
00099     if (mIsLoaded)
00100     {
00101      unload();
00102     }
00103    }


Member Function Documentation

void gpucalc::Object::addSpecificParameter ( const std::string &  ParameterName,
void *  ParameterValue,
size_t  Size 
) [inline, protected, inherited]

Definition at line 254 of file object.h.

00255    {
00256     SpecificParametersMap::iterator i = mSpecificParameters.find(ParameterName);
00257     if (i != mSpecificParameters.end())
00258     {
00259      mSpecificParameters.erase(i);
00260     }
00261     mSpecificParameters[ParameterName] = Any(ParameterValue, Size);
00262    }

const std::string& gpucalc::Object::getClassName (  )  const [inline, inherited]

Returns name of class of our object.

Definition at line 92 of file object.h.

00093    {
00094     return mClassName;
00095    }

const std::string& gpucalc::Object::getObjectName (  )  const [inline, inherited]

Returns name of our object.

Definition at line 101 of file object.h.

00102    {
00103     return mObjectName;
00104    }

void gpucalc::Object::getSpecificParameter ( const std::string &  ParameterName,
void *  ParameterValue 
) [inline, inherited]

Method for obtaining some specific parameters, such as texture specific params, and so on.

Parameters:
ParameterName - name of parameter, usually it similar to specific method of some object (for example, GLTextureID)
ParameterValue - contain value of named parameter, it must be allocated and have sufficient size.
Todo:
Think for better realization.

Definition at line 128 of file object.h.

00129    {
00130     SpecificParametersMap::iterator i = mSpecificParameters.find(ParameterName);
00131     if (i != mSpecificParameters.end())
00132     {
00133      i->second.copyValue(ParameterValue);
00134     }
00135     else
00136     {
00137      Except<ERR_ITEM_NOT_FOUND>(this, "Parameter \"" + ParameterName + "\" does not exists.", "Object::getSpecificParameter()", __FILE__, __LINE__);
00138     }
00139    }

LIBRARY_HANDLE gpucalc::Library::getSymbol ( const std::string &  SymbolName  )  const

Get symbol from this library.

Parameters:
SymbolName - name of returned symbol in Library.

Definition at line 88 of file library.cpp.

00089  {
00090   LogManager::getSingleton().logMessage(this, "Exporting symbol \"" + SymbolName + "\"...", LML_Trivial);
00091   return (LIBRARY_HANDLE)LIBRARY_GETSYM(mhInst, SymbolName.c_str());
00092  }

bool gpucalc::Library::isLoaded (  )  const [inline]

Definition at line 122 of file library.h.

00123    {
00124     return mIsLoaded;
00125    }

bool gpucalc::Object::isLocked (  )  const [inline, inherited]

returns state of object.

If object is locked then we cannot change some state of it, because object is used in computation. If object is unlocked then we can change some state of it, object is not in computation.

Definition at line 113 of file object.h.

00114    {
00115     return mIsLocked;
00116    }

std::string gpucalc::Library::libraryError (  )  const [private]

Definition at line 95 of file library.cpp.

00096  {
00097 #if PLATFORM == PLATFORM_WIN32
00098   LPVOID lpMsgBuf;
00099   FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
00100    0, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, 0);
00101   std::string ret = (char*)lpMsgBuf;
00102         // Free the buffer.
00103   LocalFree( lpMsgBuf );
00104   return ret;
00105 #elif OGRE_PLATFORM == OGRE_PLATFORM_LINUX
00106   return std::string(dlerror());
00107 #elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE
00108   return std::string(mac_errorBundle());
00109 #else
00110   return std::string("");
00111 #endif
00112  }

void gpucalc::Library::load (  ) 

Loads library.

Path to this library sets in constructor Library::Library()

Definition at line 57 of file library.cpp.

00058  {
00059   std::string name = this->getObjectName();
00060 #  if PLATFORM == PLATFORM_LINUX
00061   if (name.substr(name.length() - 3, 3) != ".so")
00062    name += ".so";
00063 #  endif
00064 
00065   mhInst = (LIBRARY_HANDLE)LIBRARY_LOAD(name.c_str());
00066   if (!mhInst)
00067   {
00068    Except<ERR_INTERNAL_ERROR>(this, "Could not load dynamic library \"" + name + "\". System Error: " + libraryError(),
00069     "DynLib::load", __FILE__, __LINE__);
00070   }
00071 
00072   LogManager::getSingleton().logMessage(this, "Library loaded.", LML_Trivial);
00073   mIsLoaded = true;
00074  }

void gpucalc::Object::lock (  )  [inline, protected, inherited]

Definition at line 265 of file object.h.

00266    {
00267     mIsLocked = true;
00268    }

void gpucalc::Library::unload (  ) 

Unloads library.

Path to this library sets in constructor Library::Library()

Definition at line 77 of file library.cpp.

00078  {
00079   if (LIBRARY_UNLOAD(mhInst))
00080   {
00081    Except<ERR_INTERNAL_ERROR>(this, "Could not unload dynamic library \"" + this->getObjectName() + "\". System Error: " + libraryError(),
00082     "DynLib::unload", __FILE__, __LINE__);
00083   }
00084   LogManager::getSingleton().logMessage(this, "Library unloaded.", LML_Trivial);
00085   mIsLoaded = false;
00086  }

void gpucalc::Object::unlock (  )  [inline, protected, inherited]

Definition at line 271 of file object.h.

00272    {
00273     mIsLocked = false;
00274    }


Member Data Documentation

LIBRARY_HANDLE gpucalc::Library::mhInst [private]

Definition at line 137 of file library.h.

Definition at line 143 of file library.h.


The documentation for this class was generated from the following files:

Generated on Thu Mar 5 22:36:45 2009 for gpucalc by  doxygen 1.5.6