Changeset 44 for trunk/src/framework/Policies
- Timestamp:
- 11/19/08 13:27:40 (17 years ago)
- Location:
- trunk/src/framework/Policies
- Files:
-
- 6 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/framework/Policies/CreationPolicy.h
r2 r44 1 1 /* 2 * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> 2 * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> 3 * 4 * Thanks to the original authors: MaNGOS <http://www.mangosproject.org/> 3 5 * 4 6 * This program is free software; you can redistribute it and/or modify … … 9 11 * This program is distributed in the hope that it will be useful, 10 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 14 * GNU General Public License for more details. 13 15 * 14 16 * You should have received a copy of the GNU General Public License 15 17 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 19 */ 18 20 19 #ifndef MANGOS_CREATIONPOLICY_H20 #define MANGOS_CREATIONPOLICY_H21 #ifndef TRINITY_CREATIONPOLICY_H 22 #define TRINITY_CREATIONPOLICY_H 21 23 22 24 #include <stdlib.h> 23 25 #include "Platform/Define.h" 24 26 25 namespace MaNGOS27 namespace Trinity 26 28 { 27 29 /** … … 29 31 */ 30 32 template <class T> 31 class MANGOS_DLL_DECL OperatorNew33 class TRINITY_DLL_DECL OperatorNew 32 34 { 33 35 public: … … 41 43 */ 42 44 template <class T> 43 class MANGOS_DLL_DECL LocalStaticCreation45 class TRINITY_DLL_DECL LocalStaticCreation 44 46 { 45 47 union MaxAlign … … 70 72 */ 71 73 template<class T> 72 class MANGOS_DLL_DECL CreateUsingMalloc74 class TRINITY_DLL_DECL CreateUsingMalloc 73 75 { 74 76 public: … … 91 93 */ 92 94 template<class T, class CALL_BACK> 93 class MANGOS_DLL_DECL CreateOnCallBack95 class TRINITY_DLL_DECL CreateOnCallBack 94 96 { 95 97 public: -
trunk/src/framework/Policies/ObjectLifeTime.cpp
r2 r44 1 1 /* 2 * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> 2 * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> 3 * 4 * Thanks to the original authors: MaNGOS <http://www.mangosproject.org/> 3 5 * 4 6 * This program is free software; you can redistribute it and/or modify … … 9 11 * This program is distributed in the hope that it will be useful, 10 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 14 * GNU General Public License for more details. 13 15 * 14 16 * You should have received a copy of the GNU General Public License 15 17 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 19 */ 18 20 … … 20 22 #include "ObjectLifeTime.h" 21 23 22 namespace MaNGOS24 namespace Trinity 23 25 { 24 26 extern "C" void external_wrapper(void *p) … … 27 29 } 28 30 29 void MANGOS_DLL_SPEC at_exit( void (*func)() )31 void TRINITY_DLL_SPEC at_exit( void (*func)() ) 30 32 { 31 33 external_wrapper((void*)func); -
trunk/src/framework/Policies/ObjectLifeTime.h
r2 r44 1 1 /* 2 * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> 2 * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> 3 * 4 * Thanks to the original authors: MaNGOS <http://www.mangosproject.org/> 3 5 * 4 6 * This program is free software; you can redistribute it and/or modify … … 9 11 * This program is distributed in the hope that it will be useful, 10 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 14 * GNU General Public License for more details. 13 15 * 14 16 * You should have received a copy of the GNU General Public License 15 17 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 19 */ 18 20 19 #ifndef MANGOS_OBJECTLIFETIME_H20 #define MANGOS_OBJECTLIFETIME_H21 #ifndef TRINITY_OBJECTLIFETIME_H 22 #define TRINITY_OBJECTLIFETIME_H 21 23 22 24 #include <stdexcept> … … 25 27 typedef void (* Destroyer)(void); 26 28 27 namespace MaNGOS29 namespace Trinity 28 30 { 29 void MANGOS_DLL_SPEC at_exit( void (*func)() );31 void TRINITY_DLL_SPEC at_exit( void (*func)() ); 30 32 31 33 template <class T> 32 class MANGOS_DLL_DECL ObjectLifeTime34 class TRINITY_DLL_DECL ObjectLifeTime 33 35 { 34 36 public: -
trunk/src/framework/Policies/Singleton.h
r2 r44 1 1 /* 2 * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> 2 * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> 3 * 4 * Thanks to the original authors: MaNGOS <http://www.mangosproject.org/> 3 5 * 4 6 * This program is free software; you can redistribute it and/or modify … … 9 11 * This program is distributed in the hope that it will be useful, 10 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 14 * GNU General Public License for more details. 13 15 * 14 16 * You should have received a copy of the GNU General Public License 15 17 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 19 */ 18 20 19 #ifndef MANGOS_SINGLETON_H20 #define MANGOS_SINGLETON_H21 #ifndef TRINITY_SINGLETON_H 22 #define TRINITY_SINGLETON_H 21 23 22 24 /** … … 28 30 #include "ObjectLifeTime.h" 29 31 30 namespace MaNGOS32 namespace Trinity 31 33 { 32 34 template 33 35 < 34 36 typename T, 35 class ThreadingModel = MaNGOS::SingleThreaded<T>,36 class CreatePolicy = MaNGOS::OperatorNew<T>,37 class LifeTimePolicy = MaNGOS::ObjectLifeTime<T>37 class ThreadingModel = Trinity::SingleThreaded<T>, 38 class CreatePolicy = Trinity::OperatorNew<T>, 39 class LifeTimePolicy = Trinity::ObjectLifeTime<T> 38 40 > 39 class MANGOS_DLL_DECL Singleton41 class TRINITY_DLL_DECL Singleton 40 42 { 41 43 public: -
trunk/src/framework/Policies/SingletonImp.h
r2 r44 1 1 /* 2 * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> 2 * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> 3 * 4 * Thanks to the original authors: MaNGOS <http://www.mangosproject.org/> 3 5 * 4 6 * This program is free software; you can redistribute it and/or modify … … 9 11 * This program is distributed in the hope that it will be useful, 10 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 14 * GNU General Public License for more details. 13 15 * 14 16 * You should have received a copy of the GNU General Public License 15 17 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 19 */ 18 20 19 #ifndef MANGOS_SINGLETONIMPL_H20 #define MANGOS_SINGLETONIMPL_H21 #ifndef TRINITY_SINGLETONIMPL_H 22 #define TRINITY_SINGLETONIMPL_H 21 23 22 24 #include "Singleton.h" … … 33 35 > 34 36 T& 35 MaNGOS::Singleton<T, ThreadingModel, CreatePolicy, LifeTimePolicy >::Instance()37 Trinity::Singleton<T, ThreadingModel, CreatePolicy, LifeTimePolicy >::Instance() 36 38 { 37 39 if( !si_instance ) … … 62 64 > 63 65 void 64 MaNGOS::Singleton<T, ThreadingModel, CreatePolicy, LifeTimePolicy>::DestroySingleton()66 Trinity::Singleton<T, ThreadingModel, CreatePolicy, LifeTimePolicy>::DestroySingleton() 65 67 { 66 68 CreatePolicy::Destroy(si_instance); … … 70 72 71 73 #define INSTANTIATE_SINGLETON_1(TYPE) \ 72 template class MANGOS_DLL_DECL MaNGOS::Singleton<TYPE, MaNGOS::SingleThreaded<TYPE>, MaNGOS::OperatorNew<TYPE>, MaNGOS::ObjectLifeTime<TYPE> >; \73 template<> TYPE* MaNGOS::Singleton<TYPE, MaNGOS::SingleThreaded<TYPE>, MaNGOS::OperatorNew<TYPE>, MaNGOS::ObjectLifeTime<TYPE> >::si_instance = 0; \74 template<> bool MaNGOS::Singleton<TYPE, MaNGOS::SingleThreaded<TYPE>, MaNGOS::OperatorNew<TYPE>, MaNGOS::ObjectLifeTime<TYPE> >::si_destroyed = false74 template class TRINITY_DLL_DECL Trinity::Singleton<TYPE, Trinity::SingleThreaded<TYPE>, Trinity::OperatorNew<TYPE>, Trinity::ObjectLifeTime<TYPE> >; \ 75 template<> TYPE* Trinity::Singleton<TYPE, Trinity::SingleThreaded<TYPE>, Trinity::OperatorNew<TYPE>, Trinity::ObjectLifeTime<TYPE> >::si_instance = 0; \ 76 template<> bool Trinity::Singleton<TYPE, Trinity::SingleThreaded<TYPE>, Trinity::OperatorNew<TYPE>, Trinity::ObjectLifeTime<TYPE> >::si_destroyed = false 75 77 76 78 #define INSTANTIATE_SINGLETON_2(TYPE, THREADINGMODEL) \ 77 template class MANGOS_DLL_DECL MaNGOS::Singleton<TYPE, THREADINGMODEL, MaNGOS::OperatorNew<TYPE>, MaNGOS::ObjectLifeTime<TYPE> >; \78 template<> TYPE* MaNGOS::Singleton<TYPE, THREADINGMODEL, MaNGOS::OperatorNew<TYPE>, MaNGOS::ObjectLifeTime<TYPE> >::si_instance = 0; \79 template<> bool MaNGOS::Singleton<TYPE, THREADINGMODEL, MaNGOS::OperatorNew<TYPE>, MaNGOS::ObjectLifeTime<TYPE> >::si_destroyed = false79 template class TRINITY_DLL_DECL Trinity::Singleton<TYPE, THREADINGMODEL, Trinity::OperatorNew<TYPE>, Trinity::ObjectLifeTime<TYPE> >; \ 80 template<> TYPE* Trinity::Singleton<TYPE, THREADINGMODEL, Trinity::OperatorNew<TYPE>, Trinity::ObjectLifeTime<TYPE> >::si_instance = 0; \ 81 template<> bool Trinity::Singleton<TYPE, THREADINGMODEL, Trinity::OperatorNew<TYPE>, Trinity::ObjectLifeTime<TYPE> >::si_destroyed = false 80 82 81 83 #define INSTANTIATE_SINGLETON_3(TYPE, THREADINGMODEL, CREATIONPOLICY ) \ 82 template class MANGOS_DLL_DECL MaNGOS::Singleton<TYPE, THREADINGMODEL, CREATIONPOLICY, MaNGOS::ObjectLifeTime<TYPE> >; \83 template<> TYPE* MaNGOS::Singleton<TYPE, THREADINGMODEL, CREATIONPOLICY, MaNGOS::ObjectLifeTime<TYPE> >::si_instance = 0; \84 template<> bool MaNGOS::Singleton<TYPE, THREADINGMODEL, CREATIONPOLICY, MaNGOS::ObjectLifeType<TYPE> >::si_destroyed = false84 template class TRINITY_DLL_DECL Trinity::Singleton<TYPE, THREADINGMODEL, CREATIONPOLICY, Trinity::ObjectLifeTime<TYPE> >; \ 85 template<> TYPE* Trinity::Singleton<TYPE, THREADINGMODEL, CREATIONPOLICY, Trinity::ObjectLifeTime<TYPE> >::si_instance = 0; \ 86 template<> bool Trinity::Singleton<TYPE, THREADINGMODEL, CREATIONPOLICY, Trinity::ObjectLifeType<TYPE> >::si_destroyed = false 85 87 86 88 #define INSTANTIATE_SINGLETON_4(TYPE, THREADINGMODEL, CREATIONPOLICY, OBJECTLIFETIME) \ 87 template class MANGOS_DLL_DECL MaNGOS::Singleton<TYPE, THREADINGMODEL, CREATIONPOLICY, OBJECTLIFETIME >; \88 template<> TYPE* MaNGOS::Singleton<TYPE, THREADINGMODEL, CREATIONPOLICY, OBJECTLIFETIME >::si_instance = 0; \89 template<> bool MaNGOS::Singleton<TYPE, THREADINGMODEL, CREATIONPOLICY, OBJECTLIFETIME >::si_destroyed = false89 template class TRINITY_DLL_DECL Trinity::Singleton<TYPE, THREADINGMODEL, CREATIONPOLICY, OBJECTLIFETIME >; \ 90 template<> TYPE* Trinity::Singleton<TYPE, THREADINGMODEL, CREATIONPOLICY, OBJECTLIFETIME >::si_instance = 0; \ 91 template<> bool Trinity::Singleton<TYPE, THREADINGMODEL, CREATIONPOLICY, OBJECTLIFETIME >::si_destroyed = false 90 92 #endif -
trunk/src/framework/Policies/ThreadingModel.h
r2 r44 1 1 /* 2 * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> 2 * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> 3 * 4 * Thanks to the original authors: MaNGOS <http://www.mangosproject.org/> 3 5 * 4 6 * This program is free software; you can redistribute it and/or modify … … 9 11 * This program is distributed in the hope that it will be useful, 10 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 14 * GNU General Public License for more details. 13 15 * 14 16 * You should have received a copy of the GNU General Public License 15 17 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 19 */ 18 20 19 #ifndef MANGOS_THREADINGMODEL_H20 #define MANGOS_THREADINGMODEL_H21 #ifndef TRINITY_THREADINGMODEL_H 22 #define TRINITY_THREADINGMODEL_H 21 23 22 24 /** … … 27 29 #include "Platform/Define.h" 28 30 29 namespace MaNGOS31 namespace Trinity 30 32 { 31 33 inline void Guard(void *) {} 32 34 33 template<typename MUTEX> class MANGOS_DLL_DECL GeneralLock35 template<typename MUTEX> class TRINITY_DLL_DECL GeneralLock 34 36 { 35 37 public: … … 50 52 51 53 template <class T> 52 class MANGOS_DLL_DECL SingleThreaded54 class TRINITY_DLL_DECL SingleThreaded 53 55 { 54 56 public: … … 68 70 // object level lockable 69 71 template<class T, class MUTEX> 70 class MANGOS_DLL_DECL ObjectLevelLockable72 class TRINITY_DLL_DECL ObjectLevelLockable 71 73 { 72 74 public: … … 97 99 98 100 template<class T, class MUTEX> 99 class MANGOS_DLL_DECL ClassLevelLockable101 class TRINITY_DLL_DECL ClassLevelLockable 100 102 { 101 103 public: … … 121 123 } 122 124 123 template<class T, class MUTEX> MUTEX MaNGOS::ClassLevelLockable<T, MUTEX>::si_mtx;125 template<class T, class MUTEX> MUTEX Trinity::ClassLevelLockable<T, MUTEX>::si_mtx; 124 126 125 127 #define INSTANTIATE_CLASS_MUTEX(CTYPE,MUTEX) \ 126 template class MANGOS_DLL_DECL MaNGOS::ClassLevelLockable<CTYPE, MUTEX >128 template class TRINITY_DLL_DECL Trinity::ClassLevelLockable<CTYPE, MUTEX > 127 129 #endif