Update of /cvsroot/pclasses/pclasses2/src/System
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14086
Added Files:
SharedLib.generic.cpp
Log Message:
egg
--- NEW FILE: SharedLib.generic.cpp ---
#include "pclasses/Phoenix.h"
#include "pclasses/System/SharedLib.h"
#ifdef PCLASSES_WITH_STL
# include <list>
#endif
namespace P { namespace System {
#ifdef PCLASSES_WITH_STL
/**
An internal helper type to clean up a list of SharedLib
objects.
*/
template <typename ContainterT>
struct SharedLibCleaner
{
typedef ContainterT list_t;
SharedLibCleaner()
{
}
~SharedLibCleaner()
{
typename list_t::iterator it = m_list.begin();
while( m_list.end() != it )
{
delete( (*it) );
}
m_list.clear();
}
list_t & container()
{
return this->m_list;
}
private:
list_t m_list;
};
/** Internal marker type. */
struct opened_libs_context {};
/**
Internal SharedLib container type.
*/
typedef std::list<SharedLib *> OpenedLibsList;
// internal list of libs opened via openSharedLib()
OpenedLibsList & opened_shared_libs()
{
return ::P::Phoenix<
SharedLibCleaner<OpenedLibsList>,
opened_libs_context>
::instance().container();
}
SharedLib * openSharedLib( const std::string & path ) throw(RuntimeError)
{
SharedLib * sh = new SharedLib( path );
// ^^^^ if this throws, the mem is deallocated, right?
opened_shared_libs().push_back( sh );
return sh;
}
#endif // PCLASSES_WITH_STL
} } // namespace P::System
|