[Orxonox-commit 908] r5631 - code/branches/libraries/src/core
landauf at orxonox.net
landauf at orxonox.net
Wed Aug 12 01:03:07 CEST 2009
Author: landauf
Date: 2009-08-12 01:03:06 +0200 (Wed, 12 Aug 2009)
New Revision: 5631
Modified:
code/branches/libraries/src/core/DynLib.cc
code/branches/libraries/src/core/DynLib.h
code/branches/libraries/src/core/DynLibManager.cc
code/branches/libraries/src/core/DynLibManager.h
code/branches/libraries/src/core/TclThreadList.h
code/branches/libraries/src/core/Thread.cc
code/branches/libraries/src/core/Thread.h
code/branches/libraries/src/core/ThreadPool.cc
code/branches/libraries/src/core/ThreadPool.h
Log:
added some eolstyle:native properties
Modified: code/branches/libraries/src/core/DynLib.cc
===================================================================
--- code/branches/libraries/src/core/DynLib.cc 2009-08-11 22:59:51 UTC (rev 5630)
+++ code/branches/libraries/src/core/DynLib.cc 2009-08-11 23:03:06 UTC (rev 5631)
@@ -1,134 +1,134 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
- (Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2006 Torus Knot Software Ltd
-Also see acknowledgements in Readme.html
-
-This program is free software; you can redistribute it and/or modify it under
-the terms of the GNU Lesser General Public License as published by the Free Software
-Foundation; either version 2 of the License, or (at your option) any later
-version.
-
-This program is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place - Suite 330, Boston, MA 02111-1307, USA, or go to
-http://www.gnu.org/copyleft/lesser.txt.
-
-You may alternatively use this source under the terms of a specific version of
-the OGRE Unrestricted License provided you have obtained such a license from
-Torus Knot Software Ltd.
------------------------------------------------------------------------------
-*/
-
-// 08/11/2009: Small adjustments for Orxonox by Fabian 'x3n' Landau
-
-#include "DynLib.h"
-
-#include "util/Exception.h"
-
-#ifdef ORXONOX_PLATFORM_WINDOWS
-# define WIN32_LEAN_AND_MEAN
-# ifndef NOMINMAX
-# define NOMINMAX // required to stop windows.h messing up std::min
-# endif
-# include <windows.h>
-#endif
-
-#ifdef ORXONOX_PLATFORM_APPLE
-# include "macPlugins.h"
-#endif
-
-namespace orxonox
-{
- //-----------------------------------------------------------------------
- DynLib::DynLib( const std::string& name )
- {
- mName = name;
- m_hInst = NULL;
- }
-
- //-----------------------------------------------------------------------
- DynLib::~DynLib()
- {
- }
-
- //-----------------------------------------------------------------------
- void DynLib::load()
- {
- // Log library load
- COUT(2) << "Loading plugin " << mName << std::endl;
-
- std::string name = mName;
-#ifdef ORXONOX_PLATFORM_LINUX
- // dlopen() does not add .so to the filename, like windows does for .dll
- if (name.substr(name.length() - 3, 3) != ".so")
- name += ".so";
-#endif
-
- m_hInst = (DYNLIB_HANDLE)DYNLIB_LOAD( name.c_str() );
-
- if( !m_hInst )
- ThrowException(
- General,
- "Could not load dynamic library " + mName +
- ". System Error: " + dynlibError());
- }
-
- //-----------------------------------------------------------------------
- void DynLib::unload()
- {
- // Log library unload
- COUT(4) << "Unloading plugin " << mName << std::endl;
-
- if( DYNLIB_UNLOAD( m_hInst ) )
- {
- ThrowException(
- General,
- "Could not unload dynamic library " + mName +
- ". System Error: " + dynlibError());
- }
-
- }
-
- //-----------------------------------------------------------------------
- void* DynLib::getSymbol( const std::string& strName ) const throw()
- {
- return (void*)DYNLIB_GETSYM( m_hInst, strName.c_str() );
- }
- //-----------------------------------------------------------------------
- std::string DynLib::dynlibError( void )
- {
-#if defined(ORXONOX_PLATFORM_WINDOWS)
- LPVOID lpMsgBuf;
- FormatMessage(
- FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- GetLastError(),
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPTSTR) &lpMsgBuf,
- 0,
- NULL
- );
- std::string ret = (char*)lpMsgBuf;
- // Free the buffer.
- LocalFree( lpMsgBuf );
- return ret;
-#elif defined(ORXONOX_PLATFORM_LINUX)
- return std::string(dlerror());
-#elif defined(ORXONOX_PLATFORM_APPLE)
- return std::string(mac_errorBundle());
-#else
- return std::string("");
-#endif
- }
-
-}
+/*
+-----------------------------------------------------------------------------
+This source file is part of OGRE
+ (Object-oriented Graphics Rendering Engine)
+For the latest info, see http://www.ogre3d.org/
+
+Copyright (c) 2000-2006 Torus Knot Software Ltd
+Also see acknowledgements in Readme.html
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+
+You may alternatively use this source under the terms of a specific version of
+the OGRE Unrestricted License provided you have obtained such a license from
+Torus Knot Software Ltd.
+-----------------------------------------------------------------------------
+*/
+
+// 08/11/2009: Small adjustments for Orxonox by Fabian 'x3n' Landau
+
+#include "DynLib.h"
+
+#include "util/Exception.h"
+
+#ifdef ORXONOX_PLATFORM_WINDOWS
+# define WIN32_LEAN_AND_MEAN
+# ifndef NOMINMAX
+# define NOMINMAX // required to stop windows.h messing up std::min
+# endif
+# include <windows.h>
+#endif
+
+#ifdef ORXONOX_PLATFORM_APPLE
+# include "macPlugins.h"
+#endif
+
+namespace orxonox
+{
+ //-----------------------------------------------------------------------
+ DynLib::DynLib( const std::string& name )
+ {
+ mName = name;
+ m_hInst = NULL;
+ }
+
+ //-----------------------------------------------------------------------
+ DynLib::~DynLib()
+ {
+ }
+
+ //-----------------------------------------------------------------------
+ void DynLib::load()
+ {
+ // Log library load
+ COUT(2) << "Loading plugin " << mName << std::endl;
+
+ std::string name = mName;
+#ifdef ORXONOX_PLATFORM_LINUX
+ // dlopen() does not add .so to the filename, like windows does for .dll
+ if (name.substr(name.length() - 3, 3) != ".so")
+ name += ".so";
+#endif
+
+ m_hInst = (DYNLIB_HANDLE)DYNLIB_LOAD( name.c_str() );
+
+ if( !m_hInst )
+ ThrowException(
+ General,
+ "Could not load dynamic library " + mName +
+ ". System Error: " + dynlibError());
+ }
+
+ //-----------------------------------------------------------------------
+ void DynLib::unload()
+ {
+ // Log library unload
+ COUT(4) << "Unloading plugin " << mName << std::endl;
+
+ if( DYNLIB_UNLOAD( m_hInst ) )
+ {
+ ThrowException(
+ General,
+ "Could not unload dynamic library " + mName +
+ ". System Error: " + dynlibError());
+ }
+
+ }
+
+ //-----------------------------------------------------------------------
+ void* DynLib::getSymbol( const std::string& strName ) const throw()
+ {
+ return (void*)DYNLIB_GETSYM( m_hInst, strName.c_str() );
+ }
+ //-----------------------------------------------------------------------
+ std::string DynLib::dynlibError( void )
+ {
+#if defined(ORXONOX_PLATFORM_WINDOWS)
+ LPVOID lpMsgBuf;
+ FormatMessage(
+ FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ GetLastError(),
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPTSTR) &lpMsgBuf,
+ 0,
+ NULL
+ );
+ std::string ret = (char*)lpMsgBuf;
+ // Free the buffer.
+ LocalFree( lpMsgBuf );
+ return ret;
+#elif defined(ORXONOX_PLATFORM_LINUX)
+ return std::string(dlerror());
+#elif defined(ORXONOX_PLATFORM_APPLE)
+ return std::string(mac_errorBundle());
+#else
+ return std::string("");
+#endif
+ }
+
+}
Property changes on: code/branches/libraries/src/core/DynLib.cc
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: code/branches/libraries/src/core/DynLib.h
===================================================================
--- code/branches/libraries/src/core/DynLib.h 2009-08-11 22:59:51 UTC (rev 5630)
+++ code/branches/libraries/src/core/DynLib.h 2009-08-11 23:03:06 UTC (rev 5631)
@@ -1,121 +1,121 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
- (Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2006 Torus Knot Software Ltd
-Also see acknowledgements in Readme.html
-
-This program is free software; you can redistribute it and/or modify it under
-the terms of the GNU Lesser General Public License as published by the Free Software
-Foundation; either version 2 of the License, or (at your option) any later
-version.
-
-This program is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place - Suite 330, Boston, MA 02111-1307, USA, or go to
-http://www.gnu.org/copyleft/lesser.txt.
-
-You may alternatively use this source under the terms of a specific version of
-the OGRE Unrestricted License provided you have obtained such a license from
-Torus Knot Software Ltd.
------------------------------------------------------------------------------
-*/
-
-// 08/11/2009: Small adjustments for Orxonox by Fabian 'x3n' Landau
-
-#ifndef _DynLib_H__
-#define _DynLib_H__
-
-#include "CorePrereqs.h"
-
-#include <string>
-
-#if defined(ORXONOX_PLATFORM_WINDOWS)
-# define DYNLIB_HANDLE hInstance
-# define DYNLIB_LOAD( a ) LoadLibraryEx( a, NULL, LOAD_WITH_ALTERED_SEARCH_PATH )
-# define DYNLIB_GETSYM( a, b ) GetProcAddress( a, b )
-# define DYNLIB_UNLOAD( a ) !FreeLibrary( a )
-
-struct HINSTANCE__;
-typedef struct HINSTANCE__* hInstance;
-
-#elif defined(ORXONOX_PLATFORM_LINUX)
-# define DYNLIB_HANDLE void*
-# define DYNLIB_LOAD( a ) dlopen( a, RTLD_LAZY | RTLD_GLOBAL)
-# define DYNLIB_GETSYM( a, b ) dlsym( a, b )
-# define DYNLIB_UNLOAD( a ) dlclose( a )
-
-#elif defined(ORXONOX_PLATFORM_APPLE)
-# define DYNLIB_HANDLE CFBundleRef
-# define DYNLIB_LOAD( a ) mac_loadExeBundle( a )
-# define DYNLIB_GETSYM( a, b ) mac_getBundleSym( a, b )
-# define DYNLIB_UNLOAD( a ) mac_unloadExeBundle( a )
-#endif
-
-namespace orxonox
-{
- /** Resource holding data about a dynamic library.
- @remarks
- This class holds the data required to get symbols from
- libraries loaded at run-time (i.e. from DLL's for so's)
- @author
- Adrian Cearnãu (cearny at cearny.ro)
- @since
- 27 January 2002
- @see
- Resource
- */
- class _CoreExport DynLib
- {
- protected:
- std::string mName;
- /// Gets the last loading error
- std::string dynlibError(void);
- public:
- /** Default constructor - used by DynLibManager.
- @warning
- Do not call directly
- */
- DynLib( const std::string& name );
-
- /** Default destructor.
- */
- ~DynLib();
-
- /** Load the library
- */
- void load();
- /** Unload the library
- */
- void unload();
- /// Get the name of the library
- const std::string& getName(void) const { return mName; }
-
- /**
- Returns the address of the given symbol from the loaded library.
- @param
- strName The name of the symbol to search for
- @returns
- If the function succeeds, the returned value is a handle to
- the symbol.
- @par
- If the function fails, the returned value is <b>NULL</b>.
-
- */
- void* getSymbol( const std::string& strName ) const throw();
-
- protected:
-
- /// Handle to the loaded library.
- DYNLIB_HANDLE m_hInst;
- };
-
-}
-
-#endif
+/*
+-----------------------------------------------------------------------------
+This source file is part of OGRE
+ (Object-oriented Graphics Rendering Engine)
+For the latest info, see http://www.ogre3d.org/
+
+Copyright (c) 2000-2006 Torus Knot Software Ltd
+Also see acknowledgements in Readme.html
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+
+You may alternatively use this source under the terms of a specific version of
+the OGRE Unrestricted License provided you have obtained such a license from
+Torus Knot Software Ltd.
+-----------------------------------------------------------------------------
+*/
+
+// 08/11/2009: Small adjustments for Orxonox by Fabian 'x3n' Landau
+
+#ifndef _DynLib_H__
+#define _DynLib_H__
+
+#include "CorePrereqs.h"
+
+#include <string>
+
+#if defined(ORXONOX_PLATFORM_WINDOWS)
+# define DYNLIB_HANDLE hInstance
+# define DYNLIB_LOAD( a ) LoadLibraryEx( a, NULL, LOAD_WITH_ALTERED_SEARCH_PATH )
+# define DYNLIB_GETSYM( a, b ) GetProcAddress( a, b )
+# define DYNLIB_UNLOAD( a ) !FreeLibrary( a )
+
+struct HINSTANCE__;
+typedef struct HINSTANCE__* hInstance;
+
+#elif defined(ORXONOX_PLATFORM_LINUX)
+# define DYNLIB_HANDLE void*
+# define DYNLIB_LOAD( a ) dlopen( a, RTLD_LAZY | RTLD_GLOBAL)
+# define DYNLIB_GETSYM( a, b ) dlsym( a, b )
+# define DYNLIB_UNLOAD( a ) dlclose( a )
+
+#elif defined(ORXONOX_PLATFORM_APPLE)
+# define DYNLIB_HANDLE CFBundleRef
+# define DYNLIB_LOAD( a ) mac_loadExeBundle( a )
+# define DYNLIB_GETSYM( a, b ) mac_getBundleSym( a, b )
+# define DYNLIB_UNLOAD( a ) mac_unloadExeBundle( a )
+#endif
+
+namespace orxonox
+{
+ /** Resource holding data about a dynamic library.
+ @remarks
+ This class holds the data required to get symbols from
+ libraries loaded at run-time (i.e. from DLL's for so's)
+ @author
+ Adrian Cearnãu (cearny at cearny.ro)
+ @since
+ 27 January 2002
+ @see
+ Resource
+ */
+ class _CoreExport DynLib
+ {
+ protected:
+ std::string mName;
+ /// Gets the last loading error
+ std::string dynlibError(void);
+ public:
+ /** Default constructor - used by DynLibManager.
+ @warning
+ Do not call directly
+ */
+ DynLib( const std::string& name );
+
+ /** Default destructor.
+ */
+ ~DynLib();
+
+ /** Load the library
+ */
+ void load();
+ /** Unload the library
+ */
+ void unload();
+ /// Get the name of the library
+ const std::string& getName(void) const { return mName; }
+
+ /**
+ Returns the address of the given symbol from the loaded library.
+ @param
+ strName The name of the symbol to search for
+ @returns
+ If the function succeeds, the returned value is a handle to
+ the symbol.
+ @par
+ If the function fails, the returned value is <b>NULL</b>.
+
+ */
+ void* getSymbol( const std::string& strName ) const throw();
+
+ protected:
+
+ /// Handle to the loaded library.
+ DYNLIB_HANDLE m_hInst;
+ };
+
+}
+
+#endif
Property changes on: code/branches/libraries/src/core/DynLib.h
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: code/branches/libraries/src/core/DynLibManager.cc
===================================================================
--- code/branches/libraries/src/core/DynLibManager.cc 2009-08-11 22:59:51 UTC (rev 5630)
+++ code/branches/libraries/src/core/DynLibManager.cc 2009-08-11 23:03:06 UTC (rev 5631)
@@ -1,86 +1,86 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
- (Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2006 Torus Knot Software Ltd
-Also see acknowledgements in Readme.html
-
-This program is free software; you can redistribute it and/or modify it under
-the terms of the GNU Lesser General Public License as published by the Free Software
-Foundation; either version 2 of the License, or (at your option) any later
-version.
-
-This program is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place - Suite 330, Boston, MA 02111-1307, USA, or go to
-http://www.gnu.org/copyleft/lesser.txt.
-
-You may alternatively use this source under the terms of a specific version of
-the OGRE Unrestricted License provided you have obtained such a license from
-Torus Knot Software Ltd.
------------------------------------------------------------------------------
-*/
-
-// 08/11/2009: Small adjustments for Orxonox by Fabian 'x3n' Landau
-
-#include "DynLibManager.h"
-
-#include "DynLib.h"
-
-namespace orxonox
-{
- //-----------------------------------------------------------------------
- //! Static pointer to the singleton
- DynLibManager* DynLibManager::singletonPtr_s = 0;
-
- //-----------------------------------------------------------------------
- DynLibManager::DynLibManager()
- {
- }
- //-----------------------------------------------------------------------
- DynLib* DynLibManager::load( const std::string& filename)
- {
- DynLibList::iterator i = mLibList.find(filename);
- if (i != mLibList.end())
- {
- return i->second;
- }
- else
- {
- DynLib* pLib = new DynLib(filename);
- pLib->load();
- mLibList[filename] = pLib;
- return pLib;
- }
- }
- //-----------------------------------------------------------------------
- void DynLibManager::unload(DynLib* lib)
- {
- DynLibList::iterator i = mLibList.find(lib->getName());
- if (i != mLibList.end())
- {
- mLibList.erase(i);
- }
- lib->unload();
- delete lib;
- }
- //-----------------------------------------------------------------------
- DynLibManager::~DynLibManager()
- {
- // Unload & delete resources in turn
- for( DynLibList::iterator it = mLibList.begin(); it != mLibList.end(); ++it )
- {
- it->second->unload();
- delete it->second;
- }
-
- // Empty the list
- mLibList.clear();
- }
-}
+/*
+-----------------------------------------------------------------------------
+This source file is part of OGRE
+ (Object-oriented Graphics Rendering Engine)
+For the latest info, see http://www.ogre3d.org/
+
+Copyright (c) 2000-2006 Torus Knot Software Ltd
+Also see acknowledgements in Readme.html
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+
+You may alternatively use this source under the terms of a specific version of
+the OGRE Unrestricted License provided you have obtained such a license from
+Torus Knot Software Ltd.
+-----------------------------------------------------------------------------
+*/
+
+// 08/11/2009: Small adjustments for Orxonox by Fabian 'x3n' Landau
+
+#include "DynLibManager.h"
+
+#include "DynLib.h"
+
+namespace orxonox
+{
+ //-----------------------------------------------------------------------
+ //! Static pointer to the singleton
+ DynLibManager* DynLibManager::singletonPtr_s = 0;
+
+ //-----------------------------------------------------------------------
+ DynLibManager::DynLibManager()
+ {
+ }
+ //-----------------------------------------------------------------------
+ DynLib* DynLibManager::load( const std::string& filename)
+ {
+ DynLibList::iterator i = mLibList.find(filename);
+ if (i != mLibList.end())
+ {
+ return i->second;
+ }
+ else
+ {
+ DynLib* pLib = new DynLib(filename);
+ pLib->load();
+ mLibList[filename] = pLib;
+ return pLib;
+ }
+ }
+ //-----------------------------------------------------------------------
+ void DynLibManager::unload(DynLib* lib)
+ {
+ DynLibList::iterator i = mLibList.find(lib->getName());
+ if (i != mLibList.end())
+ {
+ mLibList.erase(i);
+ }
+ lib->unload();
+ delete lib;
+ }
+ //-----------------------------------------------------------------------
+ DynLibManager::~DynLibManager()
+ {
+ // Unload & delete resources in turn
+ for( DynLibList::iterator it = mLibList.begin(); it != mLibList.end(); ++it )
+ {
+ it->second->unload();
+ delete it->second;
+ }
+
+ // Empty the list
+ mLibList.clear();
+ }
+}
Property changes on: code/branches/libraries/src/core/DynLibManager.cc
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: code/branches/libraries/src/core/DynLibManager.h
===================================================================
--- code/branches/libraries/src/core/DynLibManager.h 2009-08-11 22:59:51 UTC (rev 5630)
+++ code/branches/libraries/src/core/DynLibManager.h 2009-08-11 23:03:06 UTC (rev 5631)
@@ -1,87 +1,87 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
- (Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2006 Torus Knot Software Ltd
-Also see acknowledgements in Readme.html
-
-This program is free software; you can redistribute it and/or modify it under
-the terms of the GNU Lesser General Public License as published by the Free Software
-Foundation; either version 2 of the License, or (at your option) any later
-version.
-
-This program is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place - Suite 330, Boston, MA 02111-1307, USA, or go to
-http://www.gnu.org/copyleft/lesser.txt.
-
-You may alternatively use this source under the terms of a specific version of
-the OGRE Unrestricted License provided you have obtained such a license from
-Torus Knot Software Ltd.
------------------------------------------------------------------------------
-*/
-
-// 08/11/2009: Small adjustments for Orxonox by Fabian 'x3n' Landau
-
-#ifndef _DynLibManager_H__
-#define _DynLibManager_H__
-
-#include "CorePrereqs.h"
-#include "util/Singleton.h"
-
-namespace orxonox
-{
- /** Manager for Dynamic-loading Libraries.
- @remarks
- This manager keeps a track of all the open dynamic-loading
- libraries, opens them and returns references to already-open
- libraries.
- */
- class _CoreExport DynLibManager: public Singleton<DynLibManager>
- {
- friend class Singleton<DynLibManager>;
-
- protected:
- typedef std::map<std::string, DynLib*> DynLibList;
- DynLibList mLibList;
-
- public:
- /** Default constructor.
- @note
- <br>Should never be called as the singleton is automatically
- created during the creation of the Root object.
- @see
- Root::Root
- */
- DynLibManager();
-
- /** Default destructor.
- @see
- Root::~Root
- */
- virtual ~DynLibManager();
-
- /** Loads the passed library.
- @param
- filename The name of the library. The extension can be omitted
- */
- DynLib* load(const std::string& filename);
-
- /** Unloads the passed library.
- @param
- filename The name of the library. The extension can be omitted
- */
- void unload(DynLib* lib);
-
- private:
- static DynLibManager* singletonPtr_s;
- };
-}
-
-#endif
+/*
+-----------------------------------------------------------------------------
+This source file is part of OGRE
+ (Object-oriented Graphics Rendering Engine)
+For the latest info, see http://www.ogre3d.org/
+
+Copyright (c) 2000-2006 Torus Knot Software Ltd
+Also see acknowledgements in Readme.html
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+
+You may alternatively use this source under the terms of a specific version of
+the OGRE Unrestricted License provided you have obtained such a license from
+Torus Knot Software Ltd.
+-----------------------------------------------------------------------------
+*/
+
+// 08/11/2009: Small adjustments for Orxonox by Fabian 'x3n' Landau
+
+#ifndef _DynLibManager_H__
+#define _DynLibManager_H__
+
+#include "CorePrereqs.h"
+#include "util/Singleton.h"
+
+namespace orxonox
+{
+ /** Manager for Dynamic-loading Libraries.
+ @remarks
+ This manager keeps a track of all the open dynamic-loading
+ libraries, opens them and returns references to already-open
+ libraries.
+ */
+ class _CoreExport DynLibManager: public Singleton<DynLibManager>
+ {
+ friend class Singleton<DynLibManager>;
+
+ protected:
+ typedef std::map<std::string, DynLib*> DynLibList;
+ DynLibList mLibList;
+
+ public:
+ /** Default constructor.
+ @note
+ <br>Should never be called as the singleton is automatically
+ created during the creation of the Root object.
+ @see
+ Root::Root
+ */
+ DynLibManager();
+
+ /** Default destructor.
+ @see
+ Root::~Root
+ */
+ virtual ~DynLibManager();
+
+ /** Loads the passed library.
+ @param
+ filename The name of the library. The extension can be omitted
+ */
+ DynLib* load(const std::string& filename);
+
+ /** Unloads the passed library.
+ @param
+ filename The name of the library. The extension can be omitted
+ */
+ void unload(DynLib* lib);
+
+ private:
+ static DynLibManager* singletonPtr_s;
+ };
+}
+
+#endif
Property changes on: code/branches/libraries/src/core/DynLibManager.h
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: code/branches/libraries/src/core/TclThreadList.h
===================================================================
--- code/branches/libraries/src/core/TclThreadList.h 2009-08-11 22:59:51 UTC (rev 5630)
+++ code/branches/libraries/src/core/TclThreadList.h 2009-08-11 23:03:06 UTC (rev 5631)
@@ -1,263 +1,263 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Fabian 'x3n' Landau
- * Co-authors:
- * ...
- *
- */
-
-#ifndef _TclThreadList_H__
-#define _TclThreadList_H__
-
-#include "CorePrereqs.h"
-
-#include <list>
-
-#include <boost/thread/condition_variable.hpp>
-#include <boost/thread/shared_mutex.hpp>
-#include <boost/thread/locks.hpp>
-
-namespace orxonox
-{
- template <class T>
- class TclThreadList
- {
- public:
- void push_front(const T& value);
- void push_back(const T& value);
- template <class InputIterator> void insert(typename std::list<T>::iterator position, InputIterator begin, InputIterator end);
-
- void wait_and_pop_front(T* value);
- void wait_and_pop_back(T* value);
- bool try_pop_front(T* value);
- bool try_pop_back(T* value);
- void clear();
-
- size_t size() const;
- bool empty() const;
- bool is_in(const T& value) const;
-
- /**
- @brief Returns a reference to the list. Don't forget to lock the mutex (see @ref getMutex).
- */
- inline std::list<T>& getList()
- { return this->list_; }
-
- /**
- @brief Returns a reference to the list. Don't forget to lock the mutex (see @ref getMutex).
- */
- inline const std::list<T>& getList() const
- { return this->list_; }
-
- /**
- @brief Returns a reference to the mutex which might be useful if you want to iterate through the list (see @ref begin and @ref end).
- */
- inline boost::shared_mutex& getMutex() const
- { return this->mutex_; }
-
- private:
- std::list<T> list_; ///< A standard list for type T
- mutable boost::shared_mutex mutex_; ///< A mutex to grant exclusive access to the list
- boost::condition_variable_any condition_; ///< A condition variable to wake threads waiting for the mutex to become ready
- };
-
- /**
- @brief Pushes a new element to the front of the list. A unique_lock is needed.
- */
- template <class T>
- void TclThreadList<T>::push_front(const T& value)
- {
- boost::unique_lock<boost::shared_mutex> lock(this->mutex_);
- this->list_.push_front(value);
- lock.unlock(); // unlock the mutex...
- this->condition_.notify_all(); // ...then call notify_all to wake threads waiting in wait_and_pop_front/back
- }
-
- /**
- @brief Pushes a new element to the back of the list. A unique_lock is needed.
- */
- template <class T>
- void TclThreadList<T>::push_back(const T& value)
- {
- boost::unique_lock<boost::shared_mutex> lock(this->mutex_);
- this->list_.push_back(value);
- lock.unlock(); // unlock the mutex...
- this->condition_.notify_all(); // ...then call notify_all to wake threads waiting in wait_and_pop_front/back
- }
-
- /**
- @brief Inserts new elements into the list. A unique_lock is needed.
- */
- template <class T>
- template <class InputIterator> void TclThreadList<T>::insert(typename std::list<T>::iterator position, InputIterator begin, InputIterator end)
- {
- boost::unique_lock<boost::shared_mutex> lock(this->mutex_);
- this->list_.insert(position, begin, end);
- lock.unlock(); // unlock the mutex...
- this->condition_.notify_all(); // ...then call notify_all to wake threads waiting in wait_and_pop_front/back
- }
-
- /**
- @brief Waits until the list contains at least one element and then pops and returns the front element.
- @param value The front value will be stored in the variable referenced by this pointer.
- */
- template <class T>
- void TclThreadList<T>::wait_and_pop_front(T* value)
- {
- boost::unique_lock<boost::shared_mutex> lock(this->mutex_);
-
- while (this->list_.empty()) // check if there's an element in the list
- this->condition_.wait(lock); // wait until the condition becomes true (a notification comes from push_front, push_back or insert
-
- *value = this->list_.front();
- this->list_.pop_front();
- }
-
- /**
- @brief Waits until the list contains at least one element and then pops and returns the back element.
- @param value The back value will be stored in the variable referenced by this pointer.
- */
- template <class T>
- void TclThreadList<T>::wait_and_pop_back(T* value)
- {
- boost::unique_lock<boost::shared_mutex> lock(this->mutex_);
-
- while (this->list_.empty()) // check if there's an element in the list
- this->condition_.wait(lock); // wait until the condition becomes true (a notification comes from push_front, push_back or insert
-
- *value = this->list_.back();
- this->list_.pop_back();
- }
-
- /**
- @brief Pops and returns the front element if there's at least one element in the list.
- @param value The front value will be stored in the variable referenced by this pointer.
- @return Returns true if there was at least one element in the list (which got poped). If the list was empty, false is returned immediately.
-
- Needs a unique_lock if there's an element to pop. If not, shared_lock is sufficient.
- */
- template <class T>
- bool TclThreadList<T>::try_pop_front(T* value)
- {
- boost::upgrade_lock<boost::shared_mutex> lock(this->mutex_); // gain shared lock
-
- if (this->list_.empty())
- {
- // No elements - return immediately
- return false;
- }
- else
- {
- // At least one element - write it into the passed variable and pop it from the list
- boost::upgrade_to_unique_lock<boost::shared_mutex> unique_lock(lock); // upgrade to unique lock to modify the list
- *value = this->list_.front();
- this->list_.pop_front();
- }
- return true;
- }
-
- /**
- @brief Pops and returns the back element if there's at least one element in the list.
- @param value The back value will be stored in the variable referenced by this pointer.
- @return Returns true if there was at least one element in the list (which got poped). If the list was empty, false is returned immediately.
-
- Needs a unique_lock if there's an element to pop. If not, shared_lock is sufficient.
- */
- template <class T>
- bool TclThreadList<T>::try_pop_back(T* value)
- {
- boost::upgrade_lock<boost::shared_mutex> lock(this->mutex_); // gain shared lock
-
- if (this->list_.empty())
- {
- // No elements - return immediately
- return false;
- }
- else
- {
- // At least one element - write it into the passed variable and pop it from the list
- boost::upgrade_to_unique_lock<boost::shared_mutex> unique_lock(lock); // upgrade to unique lock to modify the list
- *value = this->list_.back();
- this->list_.pop_back();
- }
- return true;
- }
-
- /**
- @brief Clears the list. A unique_lock is needed.
- */
- template <class T>
- void TclThreadList<T>::clear()
- {
- boost::unique_lock<boost::shared_mutex> lock(this->mutex_);
- this->list_.clear();
- }
-
- /**
- @brief Returns the size of the list. A shared_lock is needed.
-
- Warning: Don't change the list based on the result of size(). Use an atomic function instead. Other threads may change the list
- beween your call to size() and your further actions, so be careful and use this function only if you really want nothing else than
- just the size of the list.
- */
- template <class T>
- size_t TclThreadList<T>::size() const
- {
- boost::shared_lock<boost::shared_mutex> lock(this->mutex_);
- return this->list_.size();
- }
-
- /**
- @brief Returns true if the list is empty, false otherwise. A shared_lock is needed.
-
- Warning: Don't change the list based on the result of empty(). Use an atomic function instead. Other threads may change the list
- beween your call to empty() and your further actions, so be careful and use this function only if you really want nothing else than
- just if the list is empty or not.
- */
- template <class T>
- bool TclThreadList<T>::empty() const
- {
- boost::shared_lock<boost::shared_mutex> lock(this->mutex_);
- return this->list_.empty();
- }
-
- /**
- @brief Returns true if a given element is in the list, false otherwise. A shared_lock is needed.
-
- Warning: The result of this function might be wrong just one instruction after the call. Use this function just to get information
- about a temporary snapshot and don't change the list based on the result of this function.
- */
- template <class T>
- bool TclThreadList<T>::is_in(const T& value) const
- {
- boost::shared_lock<boost::shared_mutex> lock(this->mutex_);
-
- for (typename std::list<T>::const_iterator it = this->list_.begin(); it != this->list_.end(); ++it)
- if (*it == value)
- return true;
-
- return false;
- }
-}
-
-#endif /* _TclThreadList_H__ */
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _TclThreadList_H__
+#define _TclThreadList_H__
+
+#include "CorePrereqs.h"
+
+#include <list>
+
+#include <boost/thread/condition_variable.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/thread/locks.hpp>
+
+namespace orxonox
+{
+ template <class T>
+ class TclThreadList
+ {
+ public:
+ void push_front(const T& value);
+ void push_back(const T& value);
+ template <class InputIterator> void insert(typename std::list<T>::iterator position, InputIterator begin, InputIterator end);
+
+ void wait_and_pop_front(T* value);
+ void wait_and_pop_back(T* value);
+ bool try_pop_front(T* value);
+ bool try_pop_back(T* value);
+ void clear();
+
+ size_t size() const;
+ bool empty() const;
+ bool is_in(const T& value) const;
+
+ /**
+ @brief Returns a reference to the list. Don't forget to lock the mutex (see @ref getMutex).
+ */
+ inline std::list<T>& getList()
+ { return this->list_; }
+
+ /**
+ @brief Returns a reference to the list. Don't forget to lock the mutex (see @ref getMutex).
+ */
+ inline const std::list<T>& getList() const
+ { return this->list_; }
+
+ /**
+ @brief Returns a reference to the mutex which might be useful if you want to iterate through the list (see @ref begin and @ref end).
+ */
+ inline boost::shared_mutex& getMutex() const
+ { return this->mutex_; }
+
+ private:
+ std::list<T> list_; ///< A standard list for type T
+ mutable boost::shared_mutex mutex_; ///< A mutex to grant exclusive access to the list
+ boost::condition_variable_any condition_; ///< A condition variable to wake threads waiting for the mutex to become ready
+ };
+
+ /**
+ @brief Pushes a new element to the front of the list. A unique_lock is needed.
+ */
+ template <class T>
+ void TclThreadList<T>::push_front(const T& value)
+ {
+ boost::unique_lock<boost::shared_mutex> lock(this->mutex_);
+ this->list_.push_front(value);
+ lock.unlock(); // unlock the mutex...
+ this->condition_.notify_all(); // ...then call notify_all to wake threads waiting in wait_and_pop_front/back
+ }
+
+ /**
+ @brief Pushes a new element to the back of the list. A unique_lock is needed.
+ */
+ template <class T>
+ void TclThreadList<T>::push_back(const T& value)
+ {
+ boost::unique_lock<boost::shared_mutex> lock(this->mutex_);
+ this->list_.push_back(value);
+ lock.unlock(); // unlock the mutex...
+ this->condition_.notify_all(); // ...then call notify_all to wake threads waiting in wait_and_pop_front/back
+ }
+
+ /**
+ @brief Inserts new elements into the list. A unique_lock is needed.
+ */
+ template <class T>
+ template <class InputIterator> void TclThreadList<T>::insert(typename std::list<T>::iterator position, InputIterator begin, InputIterator end)
+ {
+ boost::unique_lock<boost::shared_mutex> lock(this->mutex_);
+ this->list_.insert(position, begin, end);
+ lock.unlock(); // unlock the mutex...
+ this->condition_.notify_all(); // ...then call notify_all to wake threads waiting in wait_and_pop_front/back
+ }
+
+ /**
+ @brief Waits until the list contains at least one element and then pops and returns the front element.
+ @param value The front value will be stored in the variable referenced by this pointer.
+ */
+ template <class T>
+ void TclThreadList<T>::wait_and_pop_front(T* value)
+ {
+ boost::unique_lock<boost::shared_mutex> lock(this->mutex_);
+
+ while (this->list_.empty()) // check if there's an element in the list
+ this->condition_.wait(lock); // wait until the condition becomes true (a notification comes from push_front, push_back or insert
+
+ *value = this->list_.front();
+ this->list_.pop_front();
+ }
+
+ /**
+ @brief Waits until the list contains at least one element and then pops and returns the back element.
+ @param value The back value will be stored in the variable referenced by this pointer.
+ */
+ template <class T>
+ void TclThreadList<T>::wait_and_pop_back(T* value)
+ {
+ boost::unique_lock<boost::shared_mutex> lock(this->mutex_);
+
+ while (this->list_.empty()) // check if there's an element in the list
+ this->condition_.wait(lock); // wait until the condition becomes true (a notification comes from push_front, push_back or insert
+
+ *value = this->list_.back();
+ this->list_.pop_back();
+ }
+
+ /**
+ @brief Pops and returns the front element if there's at least one element in the list.
+ @param value The front value will be stored in the variable referenced by this pointer.
+ @return Returns true if there was at least one element in the list (which got poped). If the list was empty, false is returned immediately.
+
+ Needs a unique_lock if there's an element to pop. If not, shared_lock is sufficient.
+ */
+ template <class T>
+ bool TclThreadList<T>::try_pop_front(T* value)
+ {
+ boost::upgrade_lock<boost::shared_mutex> lock(this->mutex_); // gain shared lock
+
+ if (this->list_.empty())
+ {
+ // No elements - return immediately
+ return false;
+ }
+ else
+ {
+ // At least one element - write it into the passed variable and pop it from the list
+ boost::upgrade_to_unique_lock<boost::shared_mutex> unique_lock(lock); // upgrade to unique lock to modify the list
+ *value = this->list_.front();
+ this->list_.pop_front();
+ }
+ return true;
+ }
+
+ /**
+ @brief Pops and returns the back element if there's at least one element in the list.
+ @param value The back value will be stored in the variable referenced by this pointer.
+ @return Returns true if there was at least one element in the list (which got poped). If the list was empty, false is returned immediately.
+
+ Needs a unique_lock if there's an element to pop. If not, shared_lock is sufficient.
+ */
+ template <class T>
+ bool TclThreadList<T>::try_pop_back(T* value)
+ {
+ boost::upgrade_lock<boost::shared_mutex> lock(this->mutex_); // gain shared lock
+
+ if (this->list_.empty())
+ {
+ // No elements - return immediately
+ return false;
+ }
+ else
+ {
+ // At least one element - write it into the passed variable and pop it from the list
+ boost::upgrade_to_unique_lock<boost::shared_mutex> unique_lock(lock); // upgrade to unique lock to modify the list
+ *value = this->list_.back();
+ this->list_.pop_back();
+ }
+ return true;
+ }
+
+ /**
+ @brief Clears the list. A unique_lock is needed.
+ */
+ template <class T>
+ void TclThreadList<T>::clear()
+ {
+ boost::unique_lock<boost::shared_mutex> lock(this->mutex_);
+ this->list_.clear();
+ }
+
+ /**
+ @brief Returns the size of the list. A shared_lock is needed.
+
+ Warning: Don't change the list based on the result of size(). Use an atomic function instead. Other threads may change the list
+ beween your call to size() and your further actions, so be careful and use this function only if you really want nothing else than
+ just the size of the list.
+ */
+ template <class T>
+ size_t TclThreadList<T>::size() const
+ {
+ boost::shared_lock<boost::shared_mutex> lock(this->mutex_);
+ return this->list_.size();
+ }
+
+ /**
+ @brief Returns true if the list is empty, false otherwise. A shared_lock is needed.
+
+ Warning: Don't change the list based on the result of empty(). Use an atomic function instead. Other threads may change the list
+ beween your call to empty() and your further actions, so be careful and use this function only if you really want nothing else than
+ just if the list is empty or not.
+ */
+ template <class T>
+ bool TclThreadList<T>::empty() const
+ {
+ boost::shared_lock<boost::shared_mutex> lock(this->mutex_);
+ return this->list_.empty();
+ }
+
+ /**
+ @brief Returns true if a given element is in the list, false otherwise. A shared_lock is needed.
+
+ Warning: The result of this function might be wrong just one instruction after the call. Use this function just to get information
+ about a temporary snapshot and don't change the list based on the result of this function.
+ */
+ template <class T>
+ bool TclThreadList<T>::is_in(const T& value) const
+ {
+ boost::shared_lock<boost::shared_mutex> lock(this->mutex_);
+
+ for (typename std::list<T>::const_iterator it = this->list_.begin(); it != this->list_.end(); ++it)
+ if (*it == value)
+ return true;
+
+ return false;
+ }
+}
+
+#endif /* _TclThreadList_H__ */
Property changes on: code/branches/libraries/src/core/TclThreadList.h
___________________________________________________________________
Added: svn:eol-style
+ native
Property changes on: code/branches/libraries/src/core/Thread.cc
___________________________________________________________________
Added: svn:eol-style
+ native
Property changes on: code/branches/libraries/src/core/Thread.h
___________________________________________________________________
Added: svn:eol-style
+ native
Property changes on: code/branches/libraries/src/core/ThreadPool.cc
___________________________________________________________________
Added: svn:eol-style
+ native
Property changes on: code/branches/libraries/src/core/ThreadPool.h
___________________________________________________________________
Added: svn:eol-style
+ native
More information about the Orxonox-commit
mailing list