├── .gitattributes ├── .github └── FUNDING.yml ├── .gitignore ├── EntityComponentSystem.sln ├── EntityComponentSystem ├── ClassDiagram.cd ├── EntityComponentSystem.vcxproj ├── EntityComponentSystem.vcxproj.filters ├── include │ └── ECS │ │ ├── API.h │ │ ├── Component.h │ │ ├── ComponentManager.h │ │ ├── ECS.h │ │ ├── Engine.h │ │ ├── Entity.h │ │ ├── EntityManager.h │ │ ├── Event │ │ ├── Event.h │ │ ├── EventDelegate.h │ │ ├── EventDispatcher.h │ │ ├── EventHandler.h │ │ ├── IEvent.h │ │ ├── IEventDispatcher.h │ │ └── IEventListener.h │ │ ├── IComponent.h │ │ ├── IEntity.h │ │ ├── ISystem.h │ │ ├── Log │ │ ├── Logger.h │ │ ├── LoggerMacro.h │ │ └── LoggerManager.h │ │ ├── Memory │ │ ├── Allocator │ │ │ ├── IAllocator.h │ │ │ ├── LinearAllocator.h │ │ │ ├── PoolAllocator.h │ │ │ └── StackAllocator.h │ │ ├── ECSMM.h │ │ └── MemoryChunkAllocator.h │ │ ├── Platform.h │ │ ├── System.h │ │ ├── SystemManager.h │ │ └── util │ │ ├── FamilyTypeID.h │ │ ├── Handle.h │ │ └── Timer.h └── src │ ├── API.cpp │ ├── ComponentManager.cpp │ ├── Engine.cpp │ ├── EntityManager.cpp │ ├── Event │ ├── EventHandler.cpp │ ├── IEvent.cpp │ └── IEventListener.cpp │ ├── IComponent.cpp │ ├── IEntity.cpp │ ├── ISystem.cpp │ ├── Log │ ├── Logger.cpp │ └── LoggerManager.cpp │ ├── Memory │ ├── Allocator │ │ ├── IAllocator.cpp │ │ ├── LinearAllocator.cpp │ │ ├── PoolAllocator.cpp │ │ └── StackAllocator.cpp │ └── ECSMM.cpp │ ├── SystemManager.cpp │ └── util │ ├── FamilyTypeID.cpp │ └── Timer.cpp ├── ThirdParty └── log4cplus-1.2.1-rc2 │ └── include │ └── log4cplus │ ├── appender.h │ ├── asyncappender.h │ ├── boost │ └── deviceappender.hxx │ ├── clfsappender.h │ ├── clogger.h │ ├── config.h.cmake.in │ ├── config.h.in │ ├── config.hxx │ ├── config │ ├── defines.hxx.in │ ├── macosx.h │ ├── win32.h │ └── windowsh-inc.h │ ├── configurator.h │ ├── consoleappender.h │ ├── fileappender.h │ ├── fstreams.h │ ├── helpers │ ├── appenderattachableimpl.h │ ├── connectorthread.h │ ├── fileinfo.h │ ├── lockfile.h │ ├── loglog.h │ ├── logloguser.h │ ├── pointer.h │ ├── property.h │ ├── queue.h │ ├── sleep.h │ ├── snprintf.h │ ├── socket.h │ ├── socketbuffer.h │ ├── stringhelper.h │ ├── thread-config.h │ └── timehelper.h │ ├── hierarchy.h │ ├── hierarchylocker.h │ ├── internal │ ├── cygwin-win32.h │ ├── env.h │ ├── internal.h │ └── socket.h │ ├── layout.h │ ├── log4judpappender.h │ ├── logger.h │ ├── loggingmacros.h │ ├── loglevel.h │ ├── mdc.h │ ├── msttsappender.h │ ├── ndc.h │ ├── nteventlogappender.h │ ├── nullappender.h │ ├── qt4debugappender.h │ ├── qt5debugappender.h │ ├── socketappender.h │ ├── spi │ ├── appenderattachable.h │ ├── factory.h │ ├── filter.h │ ├── loggerfactory.h │ ├── loggerimpl.h │ ├── loggingevent.h │ ├── objectregistry.h │ └── rootlogger.h │ ├── streams.h │ ├── syslogappender.h │ ├── tchar.h │ ├── thread │ ├── impl │ │ ├── syncprims-cxx11.h │ │ ├── syncprims-impl.h │ │ ├── syncprims-pmsm.h │ │ ├── syncprims-pthreads.h │ │ ├── syncprims-win32.h │ │ ├── threads-impl.h │ │ └── tls.h │ ├── syncprims-pub-impl.h │ ├── syncprims.h │ └── threads.h │ ├── tracelogger.h │ ├── tstring.h │ ├── version.h │ ├── win32consoleappender.h │ └── win32debugappender.h └── testEntityComponentSystem ├── HandleTest.cpp ├── TestDynVsCRTPCallSpeed.cpp ├── Timer.cpp ├── stdafx.cpp ├── stdafx.h ├── targetver.h ├── testEntityComponentSystem.vcxproj └── testEntityComponentSystem.vcxproj.filters /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: tobias-stein # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: tobiasstein # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 13 | custom: ["https://www.paypal.com/paypalme/tstein88"] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 14 | -------------------------------------------------------------------------------- /EntityComponentSystem.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26730.12 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EntityComponentSystem", "EntityComponentSystem\EntityComponentSystem.vcxproj", "{FEF185A4-404A-4CA9-9A6D-6F5857E34E39}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testEntityComponentSystem", "testEntityComponentSystem\testEntityComponentSystem.vcxproj", "{09A0E8AA-F0EE-4500-BF96-7C1011279D83}" 9 | ProjectSection(ProjectDependencies) = postProject 10 | {FEF185A4-404A-4CA9-9A6D-6F5857E34E39} = {FEF185A4-404A-4CA9-9A6D-6F5857E34E39} 11 | EndProjectSection 12 | EndProject 13 | Global 14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 15 | Debug|Win32 = Debug|Win32 16 | Debug|x64 = Debug|x64 17 | Release|Win32 = Release|Win32 18 | Release|x64 = Release|x64 19 | EndGlobalSection 20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 21 | {FEF185A4-404A-4CA9-9A6D-6F5857E34E39}.Debug|Win32.ActiveCfg = Debug|Win32 22 | {FEF185A4-404A-4CA9-9A6D-6F5857E34E39}.Debug|Win32.Build.0 = Debug|Win32 23 | {FEF185A4-404A-4CA9-9A6D-6F5857E34E39}.Debug|x64.ActiveCfg = Debug|x64 24 | {FEF185A4-404A-4CA9-9A6D-6F5857E34E39}.Debug|x64.Build.0 = Debug|x64 25 | {FEF185A4-404A-4CA9-9A6D-6F5857E34E39}.Release|Win32.ActiveCfg = Release|Win32 26 | {FEF185A4-404A-4CA9-9A6D-6F5857E34E39}.Release|Win32.Build.0 = Release|Win32 27 | {FEF185A4-404A-4CA9-9A6D-6F5857E34E39}.Release|x64.ActiveCfg = Release|x64 28 | {FEF185A4-404A-4CA9-9A6D-6F5857E34E39}.Release|x64.Build.0 = Release|x64 29 | {09A0E8AA-F0EE-4500-BF96-7C1011279D83}.Debug|Win32.ActiveCfg = Debug|Win32 30 | {09A0E8AA-F0EE-4500-BF96-7C1011279D83}.Debug|Win32.Build.0 = Debug|Win32 31 | {09A0E8AA-F0EE-4500-BF96-7C1011279D83}.Debug|x64.ActiveCfg = Debug|x64 32 | {09A0E8AA-F0EE-4500-BF96-7C1011279D83}.Debug|x64.Build.0 = Debug|x64 33 | {09A0E8AA-F0EE-4500-BF96-7C1011279D83}.Release|Win32.ActiveCfg = Release|Win32 34 | {09A0E8AA-F0EE-4500-BF96-7C1011279D83}.Release|Win32.Build.0 = Release|Win32 35 | {09A0E8AA-F0EE-4500-BF96-7C1011279D83}.Release|x64.ActiveCfg = Release|x64 36 | {09A0E8AA-F0EE-4500-BF96-7C1011279D83}.Release|x64.Build.0 = Release|x64 37 | EndGlobalSection 38 | GlobalSection(SolutionProperties) = preSolution 39 | HideSolutionNode = FALSE 40 | EndGlobalSection 41 | GlobalSection(ExtensibilityGlobals) = postSolution 42 | SolutionGuid = {6EC1CC34-C2BA-440C-8EE0-ED03D5A47A8C} 43 | EndGlobalSection 44 | EndGlobal 45 | -------------------------------------------------------------------------------- /EntityComponentSystem/ClassDiagram.cd: -------------------------------------------------------------------------------- 1 |  2 | -------------------------------------------------------------------------------- /EntityComponentSystem/include/ECS/API.h: -------------------------------------------------------------------------------- 1 | ///------------------------------------------------------------------------------------------------- 2 | /// File: include\API.h. 3 | /// 4 | /// Summary: API. 5 | /// 6 | 7 | /* 8 | Preprocessor defines: 9 | 10 | ECS_DISABLE_LOGGING - Disable logging feature. 11 | 12 | 13 | 14 | */ 15 | 16 | #ifndef __ECS_API_H__ 17 | #define __ECS_API_H__ 18 | #pragma once 19 | 20 | #define ENITY_LUT_GROW 1024 21 | 22 | #define ENITY_T_CHUNK_SIZE 512 23 | 24 | #define COMPONENT_LUT_GROW 1024 25 | 26 | #define COMPONENT_T_CHUNK_SIZE 512 27 | 28 | // 4MB 29 | #define ECS_EVENT_MEMORY_BUFFER_SIZE 4194304 30 | 31 | // 8MB 32 | #define ECS_SYSTEM_MEMORY_BUFFER_SIZE 8388608 33 | 34 | 35 | #include "Platform.h" 36 | #include "Log/Logger.h" 37 | 38 | namespace ECS 39 | { 40 | namespace Log { 41 | 42 | namespace Internal 43 | { 44 | #if !ECS_DISABLE_LOGGING 45 | 46 | class LoggerManager; 47 | extern LoggerManager* ECSLoggerManager; 48 | 49 | ///------------------------------------------------------------------------------------------------- 50 | /// Fn: ECS_API Log::Logger* GetLogger(const char* logger); 51 | /// 52 | /// Summary: Returns a log4cpp managed logger instance. 53 | /// 54 | /// Author: Tobias Stein 55 | /// 56 | /// Date: 23/09/2017 57 | /// 58 | /// Parameters: 59 | /// logger - The logger. 60 | /// 61 | /// Returns: Null if it fails, else the logger. 62 | ///------------------------------------------------------------------------------------------------- 63 | 64 | ECS_API Log::Logger* GetLogger(const char* logger); 65 | #endif 66 | } 67 | } 68 | 69 | namespace Memory 70 | { 71 | namespace Internal 72 | { 73 | class MemoryManager; 74 | extern MemoryManager* ECSMemoryManager; 75 | } 76 | } 77 | 78 | namespace Event 79 | { 80 | class EventHandler; 81 | } 82 | 83 | 84 | class EntityManager; 85 | class SystemManager; 86 | class ComponentManager; 87 | 88 | 89 | 90 | namespace Memory 91 | { 92 | ///------------------------------------------------------------------------------------------------- 93 | /// Class: GlobalMemoryUser 94 | /// 95 | /// Summary: Any class that wants to use the global memory must derive from this class. 96 | /// 97 | /// Author: Tobias Stein 98 | /// 99 | /// Date: 9/09/2017 100 | ///------------------------------------------------------------------------------------------------- 101 | 102 | class ECS_API GlobalMemoryUser 103 | { 104 | private: 105 | 106 | Internal::MemoryManager* ECS_MEMORY_MANAGER; 107 | 108 | public: 109 | 110 | GlobalMemoryUser(); 111 | virtual ~GlobalMemoryUser(); 112 | 113 | inline const void* Allocate(size_t memSize, const char* user = nullptr); 114 | inline void Free(void* pMem); 115 | }; 116 | 117 | } // namespace ECS::Memory 118 | 119 | 120 | 121 | class ECSEngine; 122 | 123 | ECS_API extern ECSEngine* ECS_Engine; 124 | 125 | ECS_API void Initialize(); 126 | ECS_API void Terminate(); 127 | 128 | } // namespace ECS 129 | 130 | #endif // __ECS_API_H__ -------------------------------------------------------------------------------- /EntityComponentSystem/include/ECS/Component.h: -------------------------------------------------------------------------------- 1 | /* 2 | Author : Tobias Stein 3 | Date : 2nd July, 2016 4 | File : Component.h 5 | 6 | Base component class which provides a unique id. 7 | 8 | All Rights Reserved. (c) Copyright 2016. 9 | */ 10 | 11 | #ifndef __COMPONENT_H__ 12 | #define __COMPONENT_H__ 13 | 14 | #include "API.h" 15 | 16 | #include "IComponent.h" 17 | #include "util/FamilyTypeID.h" 18 | 19 | namespace ECS 20 | { 21 | template 22 | class Component : public IComponent 23 | { 24 | 25 | public: 26 | 27 | static const ComponentTypeId STATIC_COMPONENT_TYPE_ID; 28 | 29 | Component() 30 | {} 31 | 32 | virtual ~Component() 33 | {} 34 | 35 | inline ComponentTypeId GetStaticComponentTypeID() const 36 | { 37 | return STATIC_COMPONENT_TYPE_ID; 38 | } 39 | }; 40 | 41 | // This private member only exists to force the compiler to create an instance of Component T, 42 | // which will set its unique identifier. 43 | template 44 | const ComponentTypeId Component::STATIC_COMPONENT_TYPE_ID = util::Internal::FamilyTypeID::Get(); 45 | } 46 | 47 | #endif // __COMPONENT_H__ -------------------------------------------------------------------------------- /EntityComponentSystem/include/ECS/ECS.h: -------------------------------------------------------------------------------- 1 | /* 2 | Author : Tobias Stein 3 | Date : 30th August, 2017 4 | File : SystemManager.h 5 | 6 | Entity Component System API. 7 | 8 | All Rights Reserved. (c) Copyright 2016 - 2017. 9 | */ 10 | 11 | #pragma once 12 | 13 | 14 | #include "API.h" 15 | 16 | #include "Engine.h" 17 | 18 | #include "Entity.h" 19 | #include "Component.h" 20 | #include "System.h" 21 | 22 | #include "EntityManager.h" 23 | #include "ComponentManager.h" 24 | #include "SystemManager.h" 25 | 26 | #include "Event/Event.h" 27 | #include "Event/IEventListener.h" 28 | 29 | namespace ECS { 30 | 31 | } // namespace ECS -------------------------------------------------------------------------------- /EntityComponentSystem/include/ECS/Engine.h: -------------------------------------------------------------------------------- 1 | ///------------------------------------------------------------------------------------------------- 2 | /// File: include\Engine.h. 3 | /// 4 | /// Summary: Declares the engine class. 5 | ///------------------------------------------------------------------------------------------------- 6 | 7 | #ifndef __ECS_ENGINE_H__ 8 | #define __ECS_ENGINE_H__ 9 | 10 | #include "API.h" 11 | 12 | #include "Event/EventHandler.h" 13 | #include "Event/EventDelegate.h" 14 | 15 | namespace ECS 16 | { 17 | namespace util 18 | { 19 | class Timer; 20 | } 21 | 22 | namespace Event 23 | { 24 | class IEvent; 25 | class IEventListener; 26 | class EventHandler; 27 | } 28 | 29 | class EntityManager; 30 | class SystemManager; 31 | class ComponentManager; 32 | 33 | 34 | 35 | class ECS_API ECSEngine 36 | { 37 | friend class IEntity; 38 | friend class IComponent; 39 | friend class ISystem; 40 | 41 | friend class Event::IEvent; 42 | 43 | friend class Event::IEventListener; 44 | 45 | friend class EntityManager; 46 | 47 | private: 48 | 49 | util::Timer* ECS_EngineTime; 50 | 51 | EntityManager* ECS_EntityManager; 52 | 53 | ComponentManager* ECS_ComponentManager; 54 | 55 | SystemManager* ECS_SystemManager; 56 | 57 | Event::EventHandler* ECS_EventHandler; 58 | 59 | 60 | ECSEngine(const ECSEngine&) = delete; 61 | ECSEngine& operator=(ECSEngine&) = delete; 62 | 63 | // Add event callback 64 | template 65 | inline void SubscribeEvent(Event::Internal::IEventDelegate* const eventDelegate) 66 | { 67 | ECS_EventHandler->AddEventCallback(eventDelegate); 68 | } 69 | 70 | // Remove event callback 71 | inline void UnsubscribeEvent(Event::Internal::IEventDelegate* eventDelegate); 72 | 73 | public: 74 | 75 | ECSEngine(); 76 | 77 | ~ECSEngine(); 78 | 79 | 80 | inline EntityManager* GetEntityManager() { return ECS_EntityManager; } 81 | 82 | inline ComponentManager* GetComponentManager() { return ECS_ComponentManager; } 83 | 84 | inline SystemManager* GetSystemManager() { return ECS_SystemManager; } 85 | 86 | ///------------------------------------------------------------------------------------------------- 87 | /// Fn: template void ECSEngine::SendEvent(ARGS&&... eventArgs) 88 | /// 89 | /// Summary: Broadcasts an event. 90 | /// 91 | /// Author: Tobias Stein 92 | /// 93 | /// Date: 3/10/2017 94 | /// 95 | /// Typeparams: 96 | /// E - Type of the e. 97 | /// ARGS - Type of the arguments. 98 | /// Parameters: 99 | /// eventArgs - Variable arguments providing [in,out] The event arguments. 100 | ///------------------------------------------------------------------------------------------------- 101 | 102 | template 103 | void SendEvent(ARGS&&... eventArgs) 104 | { 105 | ECS_EventHandler->Send(std::forward(eventArgs)...); 106 | } 107 | 108 | ///------------------------------------------------------------------------------------------------- 109 | /// Fn: void ECSEngine::Update(f32 tick_ms); 110 | /// 111 | /// Summary: Updates the entire ECS with a given delta time in milliseconds. 112 | /// 113 | /// Author: Tobias Stein 114 | /// 115 | /// Date: 3/10/2017 116 | /// 117 | /// Parameters: 118 | /// tick_ms - The tick in milliseconds. 119 | ///------------------------------------------------------------------------------------------------- 120 | 121 | void Update(f32 tick_ms); 122 | }; 123 | 124 | } // namespace ECS 125 | 126 | #endif // __ECS_ENGINE_H__ -------------------------------------------------------------------------------- /EntityComponentSystem/include/ECS/Entity.h: -------------------------------------------------------------------------------- 1 | /* 2 | Author : Tobias Stein 3 | Date : 3rd July, 2016 4 | File : Entity.h 5 | 6 | Enity class. 7 | 8 | All Rights Reserved. (c) Copyright 2016. 9 | */ 10 | 11 | #ifndef __ENTITY_H__ 12 | #define __ENTITY_H__ 13 | 14 | 15 | #include "IEntity.h" 16 | 17 | namespace ECS { 18 | 19 | ///------------------------------------------------------------------------------------------------- 20 | /// Class: Entity 21 | /// 22 | /// Summary: CRTP class. Any entity object should derive form the Entity class and passes itself 23 | /// as template parameter to the Entity class. 24 | /// 25 | /// Author: Tobias Stein 26 | /// 27 | /// Date: 30/09/2017 28 | /// 29 | /// Typeparams: 30 | /// E - Type of the e. 31 | ///------------------------------------------------------------------------------------------------- 32 | 33 | template 34 | class Entity : public IEntity 35 | { 36 | // Entity destruction always happens through EntityManager !!! 37 | void operator delete(void*) = delete; 38 | void operator delete[](void*) = delete; 39 | 40 | public: 41 | 42 | static const EntityTypeId STATIC_ENTITY_TYPE_ID; 43 | 44 | public: 45 | 46 | virtual const EntityTypeId GetStaticEntityTypeID() const override { return STATIC_ENTITY_TYPE_ID; } 47 | 48 | Entity() 49 | {} 50 | 51 | virtual ~Entity() 52 | {} 53 | }; 54 | 55 | // set unique type id for this Entity 56 | template 57 | const EntityTypeId Entity::STATIC_ENTITY_TYPE_ID = util::Internal::FamilyTypeID::Get(); 58 | } 59 | 60 | #endif // __ENTITY_H__ -------------------------------------------------------------------------------- /EntityComponentSystem/include/ECS/Event/Event.h: -------------------------------------------------------------------------------- 1 | /* 2 | Author : Tobias Stein 3 | Date : 6th July, 2016 4 | File : Event.h 5 | 6 | Event class. 7 | 8 | All Rights Reserved. (c) Copyright 2016. 9 | */ 10 | 11 | #ifndef __EVENT_H__ 12 | #define __EVENT_H__ 13 | 14 | #include "Event/IEvent.h" 15 | 16 | #include "util/FamilyTypeID.h" 17 | 18 | namespace ECS { namespace Event { 19 | 20 | template 21 | class Event : public IEvent 22 | { 23 | public: 24 | 25 | // note: wont be part of stored event memory DATA 26 | static const EventTypeId STATIC_EVENT_TYPE_ID; 27 | 28 | Event() : IEvent(STATIC_EVENT_TYPE_ID) 29 | {} 30 | 31 | }; // class Event 32 | 33 | template 34 | const EventTypeId Event::STATIC_EVENT_TYPE_ID { typeid(T).hash_code() }; 35 | 36 | }} // namespace ECS::Event 37 | 38 | #endif // __EVENT_H__ -------------------------------------------------------------------------------- /EntityComponentSystem/include/ECS/Event/EventDelegate.h: -------------------------------------------------------------------------------- 1 | /* 2 | Author : Tobias Stein 3 | Date : 26th July, 2016 4 | File : EventDelegate.h 5 | 6 | A delegate to forward events to specific handler methdos. 7 | 8 | All Rights Reserved. (c) Copyright 2016. 9 | */ 10 | 11 | #ifndef __EVENT_DELEGATE_H__ 12 | #define __EVENT_DELEGATE_H__ 13 | 14 | #include "Platform.h" 15 | 16 | namespace ECS { namespace Event { 17 | 18 | class IEvent; 19 | 20 | namespace Internal 21 | { 22 | using EventDelegateId = size_t; 23 | 24 | 25 | class IEventDelegate 26 | { 27 | public: 28 | 29 | virtual inline void invoke(const IEvent* const e) = 0; 30 | 31 | virtual inline EventDelegateId GetDelegateId() const = 0; 32 | 33 | virtual inline u64 GetStaticEventTypeId() const = 0; 34 | 35 | virtual bool operator==(const IEventDelegate* other) const = 0; 36 | 37 | virtual IEventDelegate* clone() = 0; 38 | 39 | }; // class IEventDelegate 40 | 41 | template 42 | class EventDelegate : public IEventDelegate 43 | { 44 | typedef void(Class::*Callback)(const EventType* const); 45 | 46 | Class* m_Receiver; 47 | Callback m_Callback; 48 | 49 | public: 50 | 51 | EventDelegate(Class* receiver, Callback& callbackFunction) : 52 | m_Receiver(receiver), 53 | m_Callback(callbackFunction) 54 | {} 55 | 56 | virtual IEventDelegate* clone() override 57 | { 58 | return new EventDelegate(this->m_Receiver, this->m_Callback); 59 | } 60 | 61 | virtual inline void invoke(const IEvent* const e) override 62 | { 63 | (m_Receiver->*m_Callback)(reinterpret_cast(e)); 64 | } 65 | 66 | virtual inline EventDelegateId GetDelegateId() const override 67 | { 68 | static const EventDelegateId DELEGATE_ID { typeid(Class).hash_code() ^ typeid(Callback).hash_code() }; 69 | return DELEGATE_ID; 70 | } 71 | 72 | 73 | virtual inline u64 GetStaticEventTypeId() const override 74 | { 75 | static const u64 SEID { EventType::STATIC_EVENT_TYPE_ID }; 76 | return SEID; 77 | } 78 | 79 | virtual bool operator==(const IEventDelegate* other) const override 80 | { 81 | if (this->GetDelegateId() != other->GetDelegateId()) 82 | return false; 83 | 84 | EventDelegate* delegate = (EventDelegate*)other; 85 | if (other == nullptr) 86 | return false; 87 | 88 | return ((this->m_Callback == delegate->m_Callback) && (this->m_Receiver == delegate->m_Receiver)); 89 | } 90 | 91 | }; // class EventDelegate 92 | 93 | } 94 | }} // namespace ECS::Event::Internal 95 | 96 | #endif // __EVENT_DELEGATE_H__ -------------------------------------------------------------------------------- /EntityComponentSystem/include/ECS/Event/EventDispatcher.h: -------------------------------------------------------------------------------- 1 | /* 2 | Author : Tobias Stein 3 | Date : 10th July, 2016 4 | File : EventDispatcher.h 5 | 6 | Un/Registers subscribers for events and dispatches forwards incoming events. 7 | 8 | All Rights Reserved. (c) Copyright 2016. 9 | */ 10 | 11 | #ifndef __EVENT_DISPATCHER_H__ 12 | #define __EVENT_DISPATCHER_H__ 13 | 14 | #include "API.h" 15 | #include "IEventDispatcher.h" 16 | 17 | namespace ECS { namespace Event { namespace Internal { 18 | 19 | template 20 | class EventDispatcher : public IEventDispatcher 21 | { 22 | DECLARE_STATIC_LOGGER 23 | 24 | using EventDelegateList = std::list; 25 | 26 | //using PendingAddDelegates = std::list; 27 | using PendingRemoveDelegates = std::list; 28 | 29 | //PendingAddDelegates m_PendingAddDelegates; 30 | PendingRemoveDelegates m_PendingRemoveDelegates; 31 | 32 | EventDelegateList m_EventCallbacks; 33 | 34 | bool m_Locked; 35 | 36 | public: 37 | 38 | // never use! 39 | EventDispatcher() : 40 | m_Locked(false) 41 | {} 42 | 43 | virtual ~EventDispatcher() 44 | { 45 | //this->m_PendingAddDelegates.clear(); 46 | this->m_PendingRemoveDelegates.clear(); 47 | this->m_EventCallbacks.clear(); 48 | } 49 | 50 | // send event to all listener 51 | inline void Dispatch(IEvent* event) override 52 | { 53 | this->m_Locked = true; 54 | { 55 | LogTrace("Dispatch event %s", typeid(T).name()); 56 | 57 | // remove pending delegates 58 | if (this->m_PendingRemoveDelegates.empty() == false) 59 | { 60 | for (auto EC : this->m_PendingRemoveDelegates) 61 | { 62 | auto result = std::find_if(this->m_EventCallbacks.begin(), this->m_EventCallbacks.end(), 63 | [&](const IEventDelegate* other) 64 | { 65 | return other->operator==(EC); 66 | }); 67 | 68 | if (result != this->m_EventCallbacks.end()) 69 | { 70 | IEventDelegate* ptrMem = (IEventDelegate*)(*result); 71 | 72 | this->m_EventCallbacks.erase(result); 73 | 74 | delete ptrMem; 75 | ptrMem = nullptr; 76 | } 77 | } 78 | this->m_PendingRemoveDelegates.clear(); 79 | } 80 | 81 | for (auto EC : this->m_EventCallbacks) 82 | { 83 | assert(EC != nullptr && "Invalid event callback."); 84 | EC->invoke(event); 85 | } 86 | } 87 | this->m_Locked = false; 88 | } 89 | 90 | virtual void AddEventCallback(IEventDelegate* const eventDelegate) override 91 | { 92 | // if delegate wasn't deleted since last update, that is, delegate is still in pending list, 93 | // remove it from pending list 94 | auto result = std::find_if(this->m_PendingRemoveDelegates.begin(), this->m_PendingRemoveDelegates.end(), 95 | [&](const IEventDelegate* other) 96 | { 97 | return other->operator==(eventDelegate); 98 | }); 99 | 100 | if (result != this->m_PendingRemoveDelegates.end()) 101 | { 102 | this->m_PendingRemoveDelegates.erase(result); 103 | return; 104 | } 105 | 106 | this->m_EventCallbacks.push_back(eventDelegate); 107 | } 108 | 109 | virtual void RemoveEventCallback(IEventDelegate* eventDelegate) override 110 | { 111 | if (this->m_Locked == false) 112 | { 113 | auto result = std::find_if(this->m_EventCallbacks.begin(), this->m_EventCallbacks.end(), 114 | [&](const IEventDelegate* other) 115 | { 116 | return other->operator==(eventDelegate); 117 | }); 118 | 119 | if (result != this->m_EventCallbacks.end()) 120 | { 121 | IEventDelegate* ptrMem = (IEventDelegate*)(*result); 122 | 123 | this->m_EventCallbacks.erase(result); 124 | 125 | delete ptrMem; 126 | ptrMem = nullptr; 127 | } 128 | } 129 | else 130 | { 131 | auto result = std::find_if(this->m_EventCallbacks.begin(), this->m_EventCallbacks.end(), 132 | [&](const IEventDelegate* other) 133 | { 134 | return other->operator==(eventDelegate); 135 | }); 136 | 137 | assert(result != this->m_EventCallbacks.end() && ""); 138 | this->m_PendingRemoveDelegates.push_back((*result)); 139 | } 140 | } 141 | 142 | virtual inline size_t GetEventCallbackCount() const override { return this->m_EventCallbacks.size(); } 143 | }; 144 | 145 | DEFINE_STATIC_LOGGER_TEMPLATE(EventDispatcher, T, "EventDispatcher") 146 | 147 | }}} // namespace ECS::Event::Internal 148 | 149 | #endif // __EVENT_DISPATCHER_H__ -------------------------------------------------------------------------------- /EntityComponentSystem/include/ECS/Event/EventHandler.h: -------------------------------------------------------------------------------- 1 | /* 2 | Author : Tobias Stein 3 | Date : 9th July, 2016 4 | File : EventHandler.h 5 | 6 | EventHandler class. 7 | 8 | All Rights Reserved. (c) Copyright 2016. 9 | */ 10 | 11 | #ifndef __EVENT_HANDLER_H__ 12 | #define __EVENT_HANDLER_H__ 13 | 14 | 15 | #include "API.h" 16 | 17 | #include "Memory/Allocator/LinearAllocator.h" 18 | 19 | #include "IEvent.h" 20 | #include "EventDispatcher.h" 21 | 22 | namespace ECS { namespace Event { 23 | 24 | class ECS_API EventHandler : Memory::GlobalMemoryUser 25 | { 26 | // allow IEventListener access private methods for Add/Remove callbacks 27 | friend class ECSEngine; 28 | 29 | 30 | using EventDispatcherMap = std::unordered_map; 31 | 32 | using EventStorage = std::vector; 33 | 34 | using EventMemoryAllocator = Memory::Allocator::LinearAllocator; 35 | 36 | DECLARE_LOGGER 37 | 38 | private: 39 | 40 | EventHandler(const EventHandler&); 41 | EventHandler& operator=(EventHandler&); 42 | 43 | EventDispatcherMap m_EventDispatcherMap; 44 | 45 | 46 | EventMemoryAllocator* m_EventMemoryAllocator; 47 | 48 | // Holds a list of all sent events since last EventHandler::DispatchEvents() call 49 | EventStorage m_EventStorage; 50 | 51 | 52 | // Add event callback 53 | template 54 | inline void AddEventCallback(Internal::IEventDelegate* const eventDelegate) 55 | { 56 | EventTypeId ETID = E::STATIC_EVENT_TYPE_ID; 57 | 58 | EventDispatcherMap::const_iterator iter = this->m_EventDispatcherMap.find(ETID); 59 | if (iter == this->m_EventDispatcherMap.end()) 60 | { 61 | std::pair kvp(ETID, new Internal::EventDispatcher()); 62 | 63 | kvp.second->AddEventCallback(eventDelegate); 64 | 65 | this->m_EventDispatcherMap.insert(kvp); 66 | } 67 | else 68 | { 69 | this->m_EventDispatcherMap[ETID]->AddEventCallback(eventDelegate); 70 | } 71 | 72 | } 73 | 74 | // Remove event callback 75 | inline void RemoveEventCallback(Internal::IEventDelegate* eventDelegate) 76 | { 77 | auto typeId = eventDelegate->GetStaticEventTypeId(); 78 | EventDispatcherMap::const_iterator iter = this->m_EventDispatcherMap.find(typeId); 79 | if (iter != this->m_EventDispatcherMap.end()) 80 | { 81 | this->m_EventDispatcherMap[typeId]->RemoveEventCallback(eventDelegate); 82 | } 83 | } 84 | 85 | 86 | 87 | public: 88 | 89 | EventHandler(); 90 | ~EventHandler(); 91 | 92 | // clear buffer, that is, simply reset index buffer 93 | inline void ClearEventBuffer() 94 | { 95 | this->m_EventMemoryAllocator->clear(); 96 | this->m_EventStorage.clear(); 97 | } 98 | 99 | inline void ClearEventDispatcher() 100 | { 101 | this->m_EventDispatcherMap.clear(); 102 | } 103 | 104 | template 105 | void Send(ARGS&&... eventArgs) 106 | { 107 | // check if type of object is trivially copyable 108 | static_assert(std::is_trivially_copyable::value, "Event is not trivially copyable."); 109 | 110 | 111 | // allocate memory to store event data 112 | void* pMem = this->m_EventMemoryAllocator->allocate(sizeof(E), alignof(E)); 113 | 114 | // add new event to buffer and event storage 115 | if (pMem != nullptr) 116 | { 117 | this->m_EventStorage.push_back(new (pMem)E(std::forward(eventArgs)...)); 118 | 119 | LogTrace("\'%s\' event buffered.", typeid(E).name()); 120 | } 121 | else 122 | { 123 | LogWarning("Event buffer is full! Cut off new incoming events !!!"); 124 | } 125 | } 126 | 127 | // dispatches all stores events and clears buffer 128 | void DispatchEvents() 129 | { 130 | size_t lastIndex = this->m_EventStorage.size(); 131 | size_t thisIndex = 0; 132 | 133 | while (thisIndex < lastIndex) 134 | { 135 | auto event = this->m_EventStorage[thisIndex++]; 136 | if (event == nullptr) 137 | { 138 | LogError("Skip corrupted event.", event->GetEventTypeID()); 139 | continue; 140 | } 141 | 142 | auto it = this->m_EventDispatcherMap.find(event->GetEventTypeID()); 143 | if (it == this->m_EventDispatcherMap.end()) 144 | continue; 145 | 146 | it->second->Dispatch(event); 147 | 148 | // update last index, after dispatch operation there could be new events 149 | lastIndex = this->m_EventStorage.size(); 150 | } 151 | 152 | // reset 153 | ClearEventBuffer(); 154 | } 155 | }; 156 | 157 | }} // namespace ECS::Event 158 | 159 | #endif // __EVENT_HANDLER_H__ -------------------------------------------------------------------------------- /EntityComponentSystem/include/ECS/Event/IEvent.h: -------------------------------------------------------------------------------- 1 | /* 2 | Author : Tobias Stein 3 | Date : 6th July, 2016 4 | File : IEvent.h 5 | 6 | Base event class. 7 | 8 | All Rights Reserved. (c) Copyright 2016. 9 | */ 10 | 11 | #ifndef __I_EVENT_H__ 12 | #define __I_EVENT_H__ 13 | 14 | #include "API.h" 15 | 16 | namespace ECS { namespace Event { 17 | 18 | using EventTypeId = TypeID; 19 | using EventTimestamp = TimeStamp; 20 | 21 | static const EventTypeId INVALID_EVENTTYPE = INVALID_TYPE_ID; 22 | 23 | 24 | class ECS_API IEvent 25 | { 26 | private: 27 | 28 | EventTypeId m_TypeId; 29 | EventTimestamp m_TimeCreated; 30 | 31 | public: 32 | 33 | IEvent(EventTypeId typeId); 34 | 35 | // ACCESSOR 36 | inline const EventTypeId GetEventTypeID() const { return this->m_TypeId; } 37 | inline const EventTimestamp GetTimeCreated() const { return this->m_TimeCreated; } 38 | 39 | }; // class IEvent 40 | 41 | }} // namespace ECS::Event 42 | 43 | #endif // __I_EVENT_H__ -------------------------------------------------------------------------------- /EntityComponentSystem/include/ECS/Event/IEventDispatcher.h: -------------------------------------------------------------------------------- 1 | /* 2 | Author : Tobias Stein 3 | Date : 12th July, 2016 4 | File : EventDispatcher.h 5 | 6 | Event dispatcher interface. 7 | 8 | All Rights Reserved. (c) Copyright 2016. 9 | */ 10 | 11 | #ifndef __I_EVENT_DISPATCHER_H__ 12 | #define __I_EVENT_DISPATCHER_H__ 13 | 14 | #include 15 | 16 | #include "EventDelegate.h" 17 | 18 | namespace ECS { namespace Event { 19 | 20 | // forward declaration 21 | class IEvent; 22 | 23 | namespace Internal 24 | { 25 | class IEventDispatcher 26 | { 27 | public: 28 | 29 | virtual ~IEventDispatcher() 30 | {} 31 | 32 | virtual void Dispatch(IEvent* event) = 0; 33 | 34 | virtual void AddEventCallback(IEventDelegate* const eventDelegate) = 0; 35 | 36 | virtual void RemoveEventCallback(IEventDelegate* eventDelegate) = 0; 37 | 38 | virtual inline size_t GetEventCallbackCount() const = 0; 39 | }; 40 | 41 | } // namespace Internal 42 | 43 | }} // namespace ECS::Event 44 | 45 | #endif // __I_EVENT_DISPATCHER_H__ -------------------------------------------------------------------------------- /EntityComponentSystem/include/ECS/Event/IEventListener.h: -------------------------------------------------------------------------------- 1 | /* 2 | Author : Tobias Stein 3 | Date : 11th July, 2016 4 | File : IEventListener.h 5 | 6 | IEventListener interface allows a class to listen to events. 7 | 8 | All Rights Reserved. (c) Copyright 2016. 9 | */ 10 | 11 | #ifndef __I_EVENT_LISTENER_H__ 12 | #define __I_EVENT_LISTENER_H__ 13 | 14 | #include "API.h" 15 | 16 | #include "EventDelegate.h" 17 | 18 | namespace ECS 19 | { 20 | namespace Event 21 | { 22 | ///------------------------------------------------------------------------------------------------- 23 | /// Class: ECS_API 24 | /// 25 | /// Summary: Allows a deriving class to participate in eventing. 26 | /// 27 | /// Author: Tobias Stein 28 | /// 29 | /// Date: 24/09/2017 30 | ///------------------------------------------------------------------------------------------------- 31 | 32 | class ECS_API IEventListener 33 | { 34 | using RegisteredCallbacks = std::list; 35 | RegisteredCallbacks m_RegisteredCallbacks; 36 | 37 | public: 38 | 39 | IEventListener(); 40 | virtual ~IEventListener(); 41 | 42 | ///------------------------------------------------------------------------------------------------- 43 | /// Fn: template inline void IEventListener::RegisterEventCallback(void(C::*Callback)(const E* const)) 44 | /// 45 | /// Summary: Registers the event callback described by Callback. 46 | /// 47 | /// Author: Tobias Stein 48 | /// 49 | /// Date: 24/09/2017 50 | /// 51 | /// Typeparams: 52 | /// E - Type of the e. 53 | /// C - Type of the c. 54 | /// Parameters: 55 | /// Callback - [in,out] If non-null, the callback. 56 | ///------------------------------------------------------------------------------------------------- 57 | 58 | template 59 | inline void RegisterEventCallback(void(C::*Callback)(const E* const)) 60 | { 61 | 62 | Internal::IEventDelegate* eventDelegate = new Internal::EventDelegate(static_cast(this), Callback); 63 | 64 | m_RegisteredCallbacks.push_back(eventDelegate); 65 | ECS_Engine->SubscribeEvent(eventDelegate); 66 | } 67 | 68 | ///------------------------------------------------------------------------------------------------- 69 | /// Fn: template inline void IEventListener::UnregisterEventCallback(void(C::*Callback)(const E* const)) 70 | /// 71 | /// Summary: Unregisters the event callback described by Callback. 72 | /// 73 | /// Author: Tobias Stein 74 | /// 75 | /// Date: 24/09/2017 76 | /// 77 | /// Typeparams: 78 | /// E - Type of the e. 79 | /// C - Type of the c. 80 | /// Parameters: 81 | /// Callback - [in,out] If non-null, the callback. 82 | ///------------------------------------------------------------------------------------------------- 83 | 84 | template 85 | inline void UnregisterEventCallback(void(C::*Callback)(const E* const)) 86 | { 87 | Internal::EventDelegate delegate(static_cast(this), Callback); 88 | 89 | for (auto cb : this->m_RegisteredCallbacks) 90 | { 91 | if (cb->GetDelegateId() == delegate.GetDelegateId()) 92 | { 93 | this->m_RegisteredCallbacks.remove_if( 94 | [&](const Internal::IEventDelegate* other) 95 | { 96 | return other->operator==(cb); 97 | } 98 | ); 99 | 100 | ECS_Engine->UnsubscribeEvent(&delegate); 101 | break; 102 | } 103 | } 104 | } 105 | 106 | void UnregisterAllEventCallbacks(); 107 | }; 108 | 109 | } // namespace Event 110 | } // namespace ECS 111 | 112 | #endif // __I_EVENT_LISTENER_H__ -------------------------------------------------------------------------------- /EntityComponentSystem/include/ECS/IComponent.h: -------------------------------------------------------------------------------- 1 | /* 2 | Author : Tobias Stein 3 | Date : 3rd July, 2016 4 | File : IComponent.h 5 | 6 | Interface class for component class 7 | 8 | All Rights Reserved. (c) Copyright 2016. 9 | */ 10 | 11 | #ifndef __I_COMPONENT_H__ 12 | #define __I_COMPONENT_H__ 13 | 14 | #include "IEntity.h" 15 | 16 | namespace ECS 17 | { 18 | using ComponentId = ObjectID; 19 | using ComponentTypeId = TypeID; 20 | 21 | static const ComponentId INVALID_COMPONENT_ID = INVALID_OBJECT_ID; 22 | 23 | template 24 | class Component; 25 | 26 | class ECS_API IComponent 27 | { 28 | friend class ComponentManager; 29 | 30 | protected: 31 | 32 | ComponentId m_HashValue; 33 | 34 | ComponentId m_ComponentID; 35 | 36 | EntityId m_Owner; 37 | 38 | bool m_Enabled; 39 | 40 | public: 41 | 42 | IComponent(); 43 | 44 | virtual ~IComponent(); 45 | 46 | 47 | // COMPARE 48 | inline const bool operator==(const IComponent& other) const { return m_HashValue == other.m_HashValue; } 49 | inline const bool operator!=(const IComponent& other) const { return m_HashValue == other.m_HashValue; } 50 | 51 | 52 | // ACCESSOR 53 | 54 | inline const ComponentId GetComponentId() const { return this->m_ComponentID; } 55 | 56 | inline const EntityId GetOwner() const { return this->m_Owner; } 57 | 58 | inline void SetActive(bool state) { this->m_Enabled = state; } 59 | inline bool IsActive() const { return this->m_Enabled; } 60 | }; 61 | } 62 | 63 | #endif // __I_COMPONENT_H__ -------------------------------------------------------------------------------- /EntityComponentSystem/include/ECS/IEntity.h: -------------------------------------------------------------------------------- 1 | ///------------------------------------------------------------------------------------------------- 2 | /// File: include\IEntity.h. 3 | /// 4 | /// Summary: Base entity class containing no morte than entity id and state falgs. 5 | ///------------------------------------------------------------------------------------------------- 6 | 7 | #ifndef __I_ENTITY_H__ 8 | #define __I_ENTITY_H__ 9 | 10 | #pragma once 11 | 12 | #include "API.h" 13 | #include "util/Handle.h" 14 | 15 | namespace ECS 16 | { 17 | using EntityTypeId = TypeID; 18 | 19 | using EntityId = util::Handle64; 20 | 21 | static const EntityId INVALID_ENTITY_ID = util::Handle64::INVALID_HANDLE; 22 | 23 | class ECS_API IEntity 24 | { 25 | friend class EntityManager; 26 | 27 | private: 28 | 29 | // set on create; in EntityManager 30 | ComponentManager* m_ComponentManagerInstance; 31 | 32 | protected: 33 | 34 | DECLARE_STATIC_LOGGER 35 | 36 | 37 | 38 | // set on create; in EntityManager 39 | EntityId m_EntityID; 40 | 41 | // if false, entity won't be updated 42 | bool m_Active; 43 | 44 | public: 45 | 46 | IEntity(); 47 | virtual ~IEntity(); 48 | 49 | template 50 | T* GetComponent() const 51 | { 52 | return this->m_ComponentManagerInstance->GetComponent(this->m_EntityID); 53 | } 54 | 55 | template 56 | T* AddComponent(P&&... param) 57 | { 58 | return this->m_ComponentManagerInstance->AddComponent(this->m_EntityID, std::forward

(param)...); 59 | } 60 | 61 | template 62 | void RemoveComponent() 63 | { 64 | this->m_ComponentManagerInstance->RemoveComponent(this->m_EntityID); 65 | } 66 | 67 | // COMPARE ENTITIES 68 | 69 | inline bool operator==(const IEntity& rhs) const { return this->m_EntityID == rhs.m_EntityID; } 70 | inline bool operator!=(const IEntity& rhs) const { return this->m_EntityID != rhs.m_EntityID; } 71 | inline bool operator==(const IEntity* rhs) const { return this->m_EntityID == rhs->m_EntityID; } 72 | inline bool operator!=(const IEntity* rhs) const { return this->m_EntityID != rhs->m_EntityID; } 73 | 74 | // ACCESORS 75 | virtual const EntityTypeId GetStaticEntityTypeID() const = 0; 76 | 77 | inline const EntityId GetEntityID() const { return this->m_EntityID; } 78 | 79 | void SetActive(bool active); 80 | 81 | inline bool IsActive() const { return this->m_Active; } 82 | 83 | virtual void OnEnable() {} 84 | virtual void OnDisable() {} 85 | }; 86 | 87 | } // namespace ECS 88 | 89 | #endif // __I_ENTITY_H__ -------------------------------------------------------------------------------- /EntityComponentSystem/include/ECS/ISystem.h: -------------------------------------------------------------------------------- 1 | /* 2 | Author : Tobias Stein 3 | Date : 4th July, 2016 4 | File : ISystem.h 5 | 6 | Interface class for system class 7 | 8 | All Rights Reserved. (c) Copyright 2016. 9 | */ 10 | 11 | #ifndef __I_SYSTEM_H__ 12 | #define __I_SYSTEM_H__ 13 | 14 | #include "API.h" 15 | 16 | namespace ECS 17 | { 18 | template 19 | class System; 20 | 21 | using SystemTypeId = TypeID; 22 | 23 | using SystemPriority = u16; 24 | 25 | 26 | static const SystemTypeId INVALID_SYSTEMID = INVALID_TYPE_ID; 27 | 28 | 29 | 30 | static const SystemPriority LOWEST_SYSTEM_PRIORITY = std::numeric_limits::min(); 31 | 32 | static const SystemPriority VERY_LOW_SYSTEM_PRIORITY = 99; 33 | static const SystemPriority LOW_SYSTEM_PRIORITY = 100; 34 | 35 | static const SystemPriority NORMAL_SYSTEM_PRIORITY = 200; 36 | 37 | static const SystemPriority MEDIUM_SYSTEM_PRIORITY = 300; 38 | 39 | static const SystemPriority HIGH_SYSTEM_PRIORITY = 400; 40 | static const SystemPriority VERY_HIGH_SYSTEM_PRIORITY = 401; 41 | 42 | static const SystemPriority HIGHEST_SYSTEM_PRIORITY = std::numeric_limits::max(); 43 | 44 | 45 | class ECS_API ISystem 46 | { 47 | friend class SystemManager; 48 | 49 | private: 50 | 51 | /// Summary: Duration since last system update in milliseconds. 52 | f32 m_TimeSinceLastUpdate; 53 | 54 | SystemPriority m_Priority; 55 | 56 | /// Summary: The system update interval. 57 | /// A negative value means system should update each time the engine receives an update. 58 | f32 m_UpdateInterval; 59 | 60 | u8 m_Enabled : 1; 61 | u8 m_NeedsUpdate : 1; 62 | u8 m_Reserved : 6; 63 | 64 | protected: 65 | 66 | ISystem(SystemPriority priority = NORMAL_SYSTEM_PRIORITY, f32 updateInterval_ms = -1.0f); 67 | 68 | public: 69 | 70 | virtual ~ISystem(); 71 | 72 | virtual inline const SystemTypeId GetStaticSystemTypeID() const = 0; 73 | virtual inline const char* GetSystemTypeName() const = 0; 74 | 75 | virtual void PreUpdate(f32 dt) = 0; 76 | virtual void Update(f32 dt) = 0; 77 | virtual void PostUpdate(f32 dt) = 0; 78 | }; 79 | } 80 | 81 | #endif // __I_SYSTEM_H__ -------------------------------------------------------------------------------- /EntityComponentSystem/include/ECS/Log/Logger.h: -------------------------------------------------------------------------------- 1 | /* 2 | Author : Tobias Stein 3 | Date : 11th September, 2016 4 | File : Logger.h 5 | 6 | Class that manages the logging. 7 | 8 | All Rights Reserved. (c) Copyright 2016. 9 | */ 10 | 11 | #ifndef __LOGGER_H__ 12 | #define __LOGGER_H__ 13 | 14 | #include "Platform.h" 15 | 16 | #include "log4cplus/logger.h" 17 | #include "log4cplus/loggingmacros.h" 18 | 19 | #if !ECS_DISABLE_LOGGING 20 | 21 | namespace ECS { namespace Log { 22 | 23 | class ECS_API Logger 24 | { 25 | Logger(const Logger&) = delete; 26 | Logger& operator=(Logger&) = delete; 27 | 28 | log4cplus::Logger m_logger; 29 | 30 | 31 | public: 32 | 33 | explicit Logger(log4cplus::Logger& logger); 34 | 35 | ~Logger(); 36 | 37 | // trace 38 | template 39 | inline void LogTrace(const char* fmt, Args... args) 40 | { 41 | LOG4CPLUS_TRACE_FMT(this->m_logger, (const log4cplus::tchar*)fmt, std::forward(args)...); 42 | } 43 | 44 | // debug 45 | template 46 | inline void LogDebug(const char* fmt, Args... args) 47 | { 48 | LOG4CPLUS_DEBUG_FMT(this->m_logger, fmt, std::forward(args)...); 49 | } 50 | 51 | // info 52 | template 53 | inline void LogInfo(const char* fmt, Args... args) 54 | { 55 | LOG4CPLUS_INFO_FMT(this->m_logger, fmt, std::forward(args)...); 56 | } 57 | 58 | // warn 59 | template 60 | inline void LogWarning(const char* fmt, Args... args) 61 | { 62 | LOG4CPLUS_WARN_FMT(this->m_logger, fmt, std::forward(args)...); 63 | } 64 | 65 | // error 66 | template 67 | inline void LogError(const char* fmt, Args... args) 68 | { 69 | LOG4CPLUS_ERROR_FMT(this->m_logger, fmt, std::forward(args)...); 70 | } 71 | 72 | // fatal 73 | template 74 | inline void LogFatal(const char* fmt, Args... args) 75 | { 76 | LOG4CPLUS_FATAL_FMT(this->m_logger, fmt, std::forward(args)...); 77 | } 78 | 79 | }; // class Logger 80 | 81 | 82 | }} // namespace ECS::Log 83 | 84 | #endif // !ECS_DISABLE_LOGGING 85 | 86 | #include "Log/LoggerMacro.h" 87 | 88 | #endif // __LOGGER_H__ 89 | -------------------------------------------------------------------------------- /EntityComponentSystem/include/ECS/Log/LoggerMacro.h: -------------------------------------------------------------------------------- 1 | ///------------------------------------------------------------------------------------------------- 2 | /// File: include\Log\LoggerMacro.h. 3 | /// 4 | /// Summary: Declares some macros to simply logging. 5 | ///------------------------------------------------------------------------------------------------- 6 | 7 | 8 | #ifndef __LOGGER_MACRO_H__ 9 | #define __LOGGER_MACRO_H__ 10 | 11 | //#define ECS_DISABLE_LOGGING 1 12 | 13 | #if !ECS_DISABLE_LOGGING 14 | #define DECLARE_LOGGER Log::Logger* LOGGER; 15 | #define DECLARE_STATIC_LOGGER static Log::Logger* LOGGER; 16 | 17 | #define DEFINE_LOGGER(name) LOGGER = ECS::Log::Internal::GetLogger(name); 18 | #define DEFINE_STATIC_LOGGER(clazz, name) Log::Logger* ##clazz::LOGGER = ECS::Log::Internal::GetLogger(name); 19 | #define DEFINE_STATIC_LOGGER_TEMPLATE(clazz, T, name) template Log::Logger* clazz::LOGGER = ECS::Log::Internal::GetLogger(name); 20 | 21 | 22 | #define LogTrace(format, ...) LOGGER->LogTrace(format, __VA_ARGS__); 23 | #define LogDebug(format, ...) LOGGER->LogDebug(format, __VA_ARGS__); 24 | #define LogInfo(format, ...) LOGGER->LogInfo(format, __VA_ARGS__); 25 | #define LogWarning(format, ...) LOGGER->LogWarning(format, __VA_ARGS__); 26 | #define LogError(format, ...) LOGGER->LogError(format, __VA_ARGS__); 27 | #define LogFatal(format, ...) LOGGER->LogFatal(format, __VA_ARGS__); 28 | #else 29 | 30 | #define DECLARE_LOGGER 31 | #define DECLARE_STATIC_LOGGER 32 | 33 | #define DEFINE_LOGGER(name) 34 | #define DEFINE_STATIC_LOGGER(class, name) 35 | #define DEFINE_STATIC_LOGGER_TEMPLATE(class, T, name) 36 | 37 | #define LogTrace(format, ...) 38 | #define LogDebug(format, ...) 39 | #define LogInfo(format, ...) 40 | #define LogWarning(format, ...) 41 | #define LogError(format, ...) 42 | #define LogFatal(format, ...) 43 | #endif 44 | 45 | #endif // __LOGGER_MACRO_H__ -------------------------------------------------------------------------------- /EntityComponentSystem/include/ECS/Log/LoggerManager.h: -------------------------------------------------------------------------------- 1 | ///------------------------------------------------------------------------------------------------- 2 | /// File: include\Log\LoggerManager.h. 3 | /// 4 | /// Summary: Declares the logger manager class. 5 | 6 | #pragma once 7 | 8 | #if !ECS_DISABLE_LOGGING 9 | 10 | #ifndef __LOGGER_MANAGER_H__ 11 | #define __LOGGER_MANAGER_H__ 12 | 13 | 14 | #include "Platform.h" 15 | 16 | // Log4cplus logger support 17 | #include "log4cplus/logger.h" 18 | 19 | namespace ECS { namespace Log { 20 | 21 | class Logger; 22 | 23 | namespace Internal { 24 | 25 | 26 | 27 | class LoggerManager 28 | { 29 | using LoggerCache = std::unordered_map; 30 | 31 | static constexpr const char* LOG_FILE_NAME = "ECS.log"; 32 | static constexpr const char* DEFAULT_LOGGER = "ECS"; 33 | static constexpr const char* LOG_PATTERN = "%d{%H:%M:%S,%q} [%t] %-5p %c{1} %x- %m%n"; 34 | 35 | // This class is not inteeded to be initialized 36 | LoggerManager(const LoggerManager&) = delete; 37 | LoggerManager& operator=(LoggerManager&) = delete; 38 | 39 | // root logger 40 | log4cplus::Logger m_RootLogger; 41 | 42 | 43 | /// Summary: Holds all acquired logger 44 | LoggerCache m_Cache; 45 | 46 | public: 47 | 48 | LoggerManager(); 49 | ~LoggerManager(); 50 | 51 | 52 | Logger* GetLogger(const char* logger = DEFAULT_LOGGER); 53 | 54 | }; // class LoggerManager 55 | 56 | }}} // namespace ECS::Log::Internal 57 | 58 | 59 | #endif // __LOGGER_MANAGER_H__ 60 | #endif // !ECS_DISABLE_LOGGING -------------------------------------------------------------------------------- /EntityComponentSystem/include/ECS/Memory/Allocator/IAllocator.h: -------------------------------------------------------------------------------- 1 | /* 2 | Author : Tobias Stein 3 | Date : 9th July, 2016 4 | File : IAllocator.h 5 | 6 | Base allocator class. 7 | 8 | All Rights Reserved. (c) Copyright 2016. 9 | */ 10 | 11 | #ifndef __I_ALLOC_H__ 12 | #define __I_ALLOC_H__ 13 | 14 | #include "API.h" 15 | 16 | namespace ECS { namespace Memory { namespace Allocator { 17 | 18 | 19 | // returns address aligned 20 | static inline void* AlignForward(void* address, u8 alignment) 21 | { 22 | return (void*)((reinterpret_cast(address)+static_cast(alignment - 1)) & static_cast(~(alignment - 1))); 23 | } 24 | 25 | // returns the number of bytes needed to align the address 26 | static inline u8 GetAdjustment(const void* address, u8 alignment) 27 | { 28 | u8 adjustment = alignment - (reinterpret_cast(address)& static_cast(alignment - 1)); 29 | 30 | return adjustment == alignment ? 0 : adjustment; 31 | } 32 | 33 | static inline u8 GetAdjustment(const void* address, u8 alignment, u8 extra) 34 | { 35 | u8 adjustment = GetAdjustment(address, alignment); 36 | 37 | u8 neededSpace = extra; 38 | 39 | if (adjustment < neededSpace) 40 | { 41 | neededSpace -= adjustment; 42 | 43 | //Increase adjustment to fit header 44 | adjustment += alignment * (neededSpace / alignment); 45 | 46 | if (neededSpace % alignment > 0) 47 | adjustment += alignment; 48 | } 49 | 50 | return adjustment; 51 | } 52 | 53 | 54 | class ECS_API IAllocator 55 | { 56 | protected: 57 | 58 | const size_t m_MemorySize; 59 | const void* m_MemoryFirstAddress; 60 | 61 | size_t m_MemoryUsed; 62 | u64 m_MemoryAllocations; 63 | 64 | public: 65 | 66 | IAllocator(const size_t memSize, const void* mem); 67 | virtual ~IAllocator(); 68 | 69 | virtual void* allocate(size_t size, u8 alignment) = 0; 70 | virtual void free(void* p) = 0; 71 | virtual void clear() = 0; 72 | 73 | // ACCESSOR 74 | inline size_t GetMemorySize() const 75 | { 76 | return this->m_MemorySize; 77 | } 78 | 79 | inline const void* GetMemoryAddress0() const 80 | { 81 | return this->m_MemoryFirstAddress; 82 | } 83 | 84 | inline size_t GetUsedMemory() const 85 | { 86 | return this->m_MemoryUsed; 87 | } 88 | 89 | inline u64 GetAllocationCount() const 90 | { 91 | return this->m_MemoryAllocations; 92 | } 93 | 94 | }; 95 | 96 | }}} // ECS::Memory::Allocator 97 | 98 | #endif // __I_ALLOC_H__ -------------------------------------------------------------------------------- /EntityComponentSystem/include/ECS/Memory/Allocator/LinearAllocator.h: -------------------------------------------------------------------------------- 1 | /* 2 | Author : Tobias Stein 3 | Date : 22nd October, 2016 4 | File : LinearAllocator.h 5 | 6 | Linear allocator. 7 | 8 | All Rights Reserved. (c) Copyright 2016. 9 | */ 10 | 11 | #ifndef __LINEAR_ALLOC_H__ 12 | #define __LINEAR_ALLOC_H__ 13 | 14 | #include "Memory/Allocator/IAllocator.h" 15 | 16 | namespace ECS { namespace Memory { namespace Allocator { 17 | 18 | /* 19 | Allocates memory in a linear way. 20 | 21 | first 2 3 4 22 | allocatation alloaction 23 | v v v v 24 | |=================|=====|==|======| .... | 25 | ^ ^ 26 | Initialial Last possible 27 | memory memory address 28 | address (mem + memSize) 29 | (mem) 30 | 31 | 32 | memory only can be freed by clearing all allocations 33 | */ 34 | class ECS_API LinearAllocator : public IAllocator 35 | { 36 | public: 37 | 38 | LinearAllocator(size_t memSize, const void* mem); 39 | 40 | virtual ~LinearAllocator(); 41 | 42 | virtual void* allocate(size_t size, u8 alignment) override; 43 | virtual void free(void* p) override; 44 | virtual void clear() override; 45 | 46 | }; // class LineaerAllocator 47 | 48 | } } } // namespace ECS::Memory::Allocator 49 | 50 | #endif // __LINEAR_ALLOC_H__ -------------------------------------------------------------------------------- /EntityComponentSystem/include/ECS/Memory/Allocator/PoolAllocator.h: -------------------------------------------------------------------------------- 1 | /* 2 | Author : Tobias Stein 3 | Date : 22nd October, 2016 4 | File : PoolAllocator.h 5 | 6 | Pool allocator. 7 | 8 | All Rights Reserved. (c) Copyright 2016. 9 | */ 10 | 11 | #ifndef __POOL_ALLOC_H__ 12 | #define __POOL_ALLOC_H__ 13 | 14 | 15 | #include "Memory/Allocator/IAllocator.h" 16 | 17 | namespace ECS { namespace Memory { namespace Allocator { 18 | 19 | class ECS_API PoolAllocator : public IAllocator 20 | { 21 | private: 22 | 23 | const size_t OBJECT_SIZE; 24 | const u8 OBJECT_ALIGNMENT; 25 | 26 | void** freeList; 27 | 28 | public: 29 | 30 | PoolAllocator::PoolAllocator(size_t memSize, const void* mem, size_t objectSize, u8 objectAlignment); 31 | 32 | virtual ~PoolAllocator(); 33 | 34 | virtual void* allocate(size_t size, u8 alignment) override; 35 | virtual void free(void* p) override; 36 | virtual void clear() override; 37 | 38 | }; // class StackAllocator 39 | 40 | }}} // namespace ECS::Memory::Allocator 41 | 42 | #endif // __POOL_ALLOC_H__ -------------------------------------------------------------------------------- /EntityComponentSystem/include/ECS/Memory/Allocator/StackAllocator.h: -------------------------------------------------------------------------------- 1 | /* 2 | Author : Tobias Stein 3 | Date : 22nd October, 2016 4 | File : StackAllocator.h 5 | 6 | Stack allocator. 7 | 8 | All Rights Reserved. (c) Copyright 2016. 9 | */ 10 | 11 | #ifndef __STACK_ALLOC_H__ 12 | #define __STACK_ALLOC_H__ 13 | 14 | #include "Memory/Allocator/IAllocator.h" 15 | 16 | namespace ECS { namespace Memory { namespace Allocator { 17 | 18 | /* 19 | */ 20 | class ECS_API StackAllocator : public IAllocator 21 | { 22 | private: 23 | 24 | struct AllocMetaInfo 25 | { 26 | u8 adjustment; 27 | }; 28 | 29 | public: 30 | 31 | StackAllocator(size_t memSize, const void* mem); 32 | 33 | virtual ~StackAllocator(); 34 | 35 | virtual void* allocate(size_t size, u8 alignment) override; 36 | virtual void free(void* p) override; 37 | virtual void clear() override; 38 | 39 | }; // class StackAllocator 40 | 41 | } } } // namespace ECS::Memory::Allocator 42 | 43 | #endif // __STACK_ALLOC_H__ -------------------------------------------------------------------------------- /EntityComponentSystem/include/ECS/Memory/ECSMM.h: -------------------------------------------------------------------------------- 1 | /* 2 | Author : Tobias Stein 3 | Date : 6th September, 2017 4 | File : ECSMM.h 5 | 6 | Internal used memory manager. 7 | 8 | All Rights Reserved. (c) Copyright 2016 - 2017. 9 | */ 10 | 11 | #ifndef __ECSSMM_H__ 12 | #define __ECSSMM_H__ 13 | 14 | #pragma once 15 | 16 | #define ECS_GLOBAL_MEMORY_CAPACITY 134217728 // 128 MB 17 | 18 | #include "API.h" 19 | 20 | #include "Memory/Allocator/StackAllocator.h" 21 | 22 | namespace ECS { namespace Memory { namespace Internal { 23 | 24 | class Allocator::StackAllocator; 25 | 26 | class MemoryManager 27 | { 28 | friend class GlobalMemoryUser; 29 | 30 | using StackAllocator = Allocator::StackAllocator; 31 | 32 | DECLARE_LOGGER 33 | 34 | public: 35 | 36 | static constexpr size_t MEMORY_CAPACITY = ECS_GLOBAL_MEMORY_CAPACITY; 37 | 38 | private: 39 | 40 | // Pointer to global allocated memory 41 | void* m_GlobalMemory; 42 | 43 | // Allocator used to manager memory allocation from global memory 44 | StackAllocator* m_MemoryAllocator; 45 | 46 | std::vector> m_PendingMemory; 47 | 48 | std::list m_FreedMemory; 49 | 50 | MemoryManager(const MemoryManager&) = delete; 51 | MemoryManager& operator=(MemoryManager&) = delete; 52 | 53 | public: 54 | 55 | MemoryManager(); 56 | ~MemoryManager(); 57 | 58 | 59 | inline void* Allocate(size_t memSize, const char* user = nullptr) 60 | { 61 | LogDebug("%s allocated %d bytes of global memory.", user != nullptr ? user : "Unknown", memSize); 62 | void* pMemory = m_MemoryAllocator->allocate(memSize, alignof(u8)); 63 | 64 | this->m_PendingMemory.push_back(std::pair(user, pMemory)); 65 | 66 | return pMemory; 67 | } 68 | 69 | inline void Free(void* pMem) 70 | { 71 | if (pMem == this->m_PendingMemory.back().second) 72 | { 73 | this->m_MemoryAllocator->free(pMem); 74 | this->m_PendingMemory.pop_back(); 75 | 76 | bool bCheck = true; 77 | while(bCheck == true) 78 | { 79 | bCheck = false; 80 | 81 | // do not report already freed memory blocks. 82 | for (auto it : this->m_FreedMemory) 83 | { 84 | if (it == this->m_PendingMemory.back().second) 85 | { 86 | this->m_MemoryAllocator->free(pMem); 87 | this->m_PendingMemory.pop_back(); 88 | this->m_FreedMemory.remove(it); 89 | 90 | bCheck = true; 91 | break; 92 | } 93 | } 94 | }; 95 | 96 | } 97 | else 98 | { 99 | this->m_FreedMemory.push_back(pMem); 100 | } 101 | } 102 | 103 | void CheckMemoryLeaks(); 104 | 105 | }; // class MemoryManager 106 | 107 | }}} // namespace ECS::Memory::Internal 108 | 109 | #endif // __ECSSMM_H__ -------------------------------------------------------------------------------- /EntityComponentSystem/include/ECS/Platform.h: -------------------------------------------------------------------------------- 1 | ///------------------------------------------------------------------------------------------------- 2 | /// File: include\Platform.h. 3 | /// 4 | /// Summary: Declares the platform specifics. 5 | 6 | #pragma once 7 | 8 | #ifndef __PLATFORM_H__ 9 | #define __PLATFORM_H__ 10 | 11 | 12 | #ifdef ECS_EXPORT 13 | #define ECS_API __declspec(dllexport) 14 | #else 15 | #define ECS_API __declspec(dllimport) 16 | #endif 17 | 18 | 19 | // Check if using 64-Bit architecture 20 | #if (defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__) || defined(_M_AMD64) || defined(_M_ARM64) || defined(_M_X64)) 21 | #define ECS_64BIT 1 22 | 23 | // Check if using 32-Bit architecture 24 | #elif (defined(_WIN32) && !defined(_WIN64)) || defined(_M_IX86) 25 | #define ECS_32BIT 1 26 | #endif 27 | 28 | 29 | 30 | // Platform includes 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | 43 | #include 44 | #include 45 | 46 | #include 47 | #include 48 | 49 | #include 50 | #include 51 | 52 | #include 53 | 54 | namespace ECS 55 | { 56 | 57 | // signed integer type 58 | using i8 = int8_t; 59 | using i16 = int16_t; 60 | using i32 = int32_t; 61 | 62 | #ifdef ECS_64BIT 63 | using i64 = int64_t; 64 | #else 65 | using i64 = int32_t; 66 | #endif 67 | 68 | // unsigned integer type 69 | using u8 = uint8_t; 70 | using u16 = uint16_t; 71 | using u32 = uint32_t; 72 | #ifdef ECS_64BIT 73 | using u64 = uint64_t; 74 | #else 75 | using u64 = uint32_t; 76 | #endif 77 | 78 | // floating point 79 | using f32 = float_t; 80 | using f64 = double_t; 81 | 82 | // pointer 83 | using iptr = intptr_t; 84 | using uptr = uintptr_t; 85 | 86 | using ObjectID = size_t; 87 | using TypeID = size_t; 88 | 89 | static const ObjectID INVALID_OBJECT_ID = std::numeric_limits::max(); 90 | static const TypeID INVALID_TYPE_ID = std::numeric_limits::max(); 91 | 92 | 93 | union TimeStamp 94 | { 95 | f32 asFloat; 96 | u32 asUInt; 97 | 98 | TimeStamp() : asUInt(0U) 99 | {} 100 | 101 | TimeStamp(f32 floatValue) : asFloat(floatValue) 102 | {} 103 | 104 | operator u32() const { return this->asUInt; } 105 | 106 | inline const bool operator==(const TimeStamp& other) const { return this->asUInt == other.asUInt; } 107 | inline const bool operator!=(const TimeStamp& other) const { return this->asUInt != other.asUInt; } 108 | 109 | inline const bool operator<(const TimeStamp& other) const { return this->asFloat < other.asFloat; } 110 | inline const bool operator>(const TimeStamp& other) const { return this->asFloat > other.asFloat; } 111 | 112 | }; // union TimeStamp 113 | 114 | } // namespace ECS 115 | 116 | 117 | #endif // __PLATFORM_H__ -------------------------------------------------------------------------------- /EntityComponentSystem/include/ECS/System.h: -------------------------------------------------------------------------------- 1 | /* 2 | Author : Tobias Stein 3 | Date : 4th July, 2016 4 | File : System.h 5 | 6 | System base class. 7 | 8 | All Rights Reserved. (c) Copyright 2016. 9 | */ 10 | 11 | #ifndef __SYSTEM_H__ 12 | #define __SYSTEM_H__ 13 | 14 | #include "API.h" 15 | 16 | #include "ISystem.h" 17 | #include "util/FamilyTypeID.h" 18 | 19 | 20 | namespace ECS 21 | { 22 | template 23 | class System : public ISystem 24 | { 25 | friend class SystemManager; 26 | 27 | private: 28 | 29 | SystemManager* m_SystemManagerInstance; 30 | 31 | protected: 32 | 33 | DECLARE_LOGGER 34 | 35 | public: 36 | 37 | static const SystemTypeId STATIC_SYSTEM_TYPE_ID; 38 | 39 | protected: 40 | 41 | System() 42 | { 43 | DEFINE_LOGGER(typeid(T).name()) 44 | LogInfo("System %s created.", typeid(T).name()); 45 | } 46 | 47 | public: 48 | 49 | virtual ~System() 50 | { 51 | LogInfo("System %s released.", typeid(T).name()); 52 | } 53 | 54 | virtual inline const SystemTypeId GetStaticSystemTypeID() const 55 | { 56 | return STATIC_SYSTEM_TYPE_ID; 57 | } 58 | 59 | virtual inline const char* GetSystemTypeName() const override 60 | { 61 | static const char* SYSTEM_TYPE_NAME { typeid(T).name() }; 62 | return SYSTEM_TYPE_NAME; 63 | } 64 | 65 | ///------------------------------------------------------------------------------------------------- 66 | /// Fn: template void System::AddDependencies(Dependencies&&... dependencies) 67 | /// 68 | /// Summary: Adds a new dependencies for this system. 69 | /// 70 | /// Author: Tobias Stein 71 | /// 72 | /// Date: 28/09/2017 73 | /// 74 | /// Typeparams: 75 | /// Dependencies - Type of the dependencies. 76 | /// Parameters: 77 | /// dependencies - Variable arguments providing [in,out] The dependencies. 78 | ///------------------------------------------------------------------------------------------------- 79 | 80 | template 81 | void AddDependencies(Dependencies&&... dependencies) 82 | { 83 | this->m_SystemManagerInstance->AddSystemDependency(this, std::forward(dependencies)...); 84 | } 85 | 86 | virtual void PreUpdate(f32 dt) override 87 | {} 88 | 89 | virtual void Update(f32 dt) override 90 | {} 91 | 92 | virtual void PostUpdate(f32 dt) override 93 | {} 94 | 95 | }; // class System 96 | 97 | template 98 | const SystemTypeId System::STATIC_SYSTEM_TYPE_ID = util::Internal::FamilyTypeID::Get(); 99 | 100 | } // namespace ECS 101 | 102 | #endif // __SYSTEM_H__ -------------------------------------------------------------------------------- /EntityComponentSystem/include/ECS/util/FamilyTypeID.h: -------------------------------------------------------------------------------- 1 | /* 2 | Author : Tobias Stein 3 | Date : 8th October, 2016 4 | File : CountByType.h 5 | 6 | A static counter that increments thee count for a specific type. 7 | 8 | All Rights Reserved. (c) Copyright 2016. 9 | */ 10 | 11 | #ifndef __FAMILY_TYPE_ID_H__ 12 | #define __FAMILY_TYPE_ID_H__ 13 | 14 | 15 | #include "API.h" 16 | 17 | namespace ECS { namespace util { namespace Internal { 18 | 19 | template 20 | class ECS_API FamilyTypeID 21 | { 22 | static TypeID s_count; 23 | 24 | public: 25 | 26 | template 27 | static const TypeID Get() 28 | { 29 | static const TypeID STATIC_TYPE_ID { s_count++ }; 30 | return STATIC_TYPE_ID; 31 | } 32 | 33 | static const TypeID Get() 34 | { 35 | return s_count; 36 | } 37 | }; 38 | 39 | }}} // namespace ECS::util::Internal 40 | 41 | #endif // __FAMILY_TYPE_ID_H__ 42 | -------------------------------------------------------------------------------- /EntityComponentSystem/include/ECS/util/Timer.h: -------------------------------------------------------------------------------- 1 | ///------------------------------------------------------------------------------------------------- 2 | /// File: include\util\Timer.h. 3 | /// 4 | /// Summary: Declares the Timer class. 5 | ///------------------------------------------------------------------------------------------------- 6 | 7 | #ifndef __TIMER_H___ 8 | #define __TIMER_H___ 9 | 10 | #include "API.h" 11 | 12 | namespace ECS { namespace util { 13 | 14 | class ECS_API Timer 15 | { 16 | using Elapsed = std::chrono::duration; 17 | 18 | private: 19 | 20 | Elapsed m_Elapsed; 21 | 22 | public: 23 | 24 | Timer(); 25 | ~Timer(); 26 | 27 | ///------------------------------------------------------------------------------------------------- 28 | /// Fn: void Timer::Tick(DurationRep ms); 29 | /// 30 | /// Summary: Advances timer by adding elapsed milliseconds. 31 | /// 32 | /// Author: Tobias Stein 33 | /// 34 | /// Date: 3/10/2017 35 | /// 36 | /// Parameters: 37 | /// ms - milliseconds (can be fractions). 38 | ///------------------------------------------------------------------------------------------------- 39 | 40 | void Tick(f32 ms); 41 | 42 | ///------------------------------------------------------------------------------------------------- 43 | /// Fn: void Timer::Reset(); 44 | /// 45 | /// Summary: Resets this timer to zero. 46 | /// 47 | /// Author: Tobias Stein 48 | /// 49 | /// Date: 3/10/2017 50 | ///------------------------------------------------------------------------------------------------- 51 | 52 | void Reset(); 53 | 54 | ///------------------------------------------------------------------------------------------------- 55 | /// Fn: inline TimeStamp Timer::GetTimeStamp() const 56 | /// 57 | /// Summary: Gets a TimeStamp from current timer value. 58 | /// 59 | /// Author: Tobias Stein 60 | /// 61 | /// Date: 3/10/2017 62 | /// 63 | /// Returns: The time stamp. 64 | ///------------------------------------------------------------------------------------------------- 65 | 66 | inline TimeStamp GetTimeStamp() const 67 | { 68 | return TimeStamp(this->m_Elapsed.count()); 69 | } 70 | 71 | }; // class Timer 72 | 73 | }} // namespace ECS::util 74 | 75 | #endif // __TIMER_H___ 76 | 77 | -------------------------------------------------------------------------------- /EntityComponentSystem/src/API.cpp: -------------------------------------------------------------------------------- 1 | ///------------------------------------------------------------------------------------------------- 2 | /// File: src\API.cpp. 3 | /// 4 | /// Summary: Implements the API. 5 | 6 | 7 | #include "API.h" 8 | 9 | #include "Log/LoggerManager.h" 10 | #include "Memory/ECSMM.h" 11 | 12 | #include "Engine.h" 13 | 14 | namespace ECS 15 | { 16 | namespace Log { 17 | 18 | namespace Internal { 19 | 20 | #if !ECS_DISABLE_LOGGING 21 | 22 | LoggerManager* ECSLoggerManager = new LoggerManager(); 23 | 24 | Log::Logger* GetLogger(const char* logger) 25 | { 26 | return ECSLoggerManager->GetLogger(logger); 27 | } 28 | #endif 29 | } 30 | 31 | } // namespace Log 32 | 33 | 34 | namespace Memory { 35 | 36 | namespace Internal { 37 | 38 | MemoryManager* ECSMemoryManager = new Memory::Internal::MemoryManager(); 39 | } 40 | 41 | 42 | GlobalMemoryUser::GlobalMemoryUser() : ECS_MEMORY_MANAGER(Internal::ECSMemoryManager) 43 | {} 44 | 45 | GlobalMemoryUser::~GlobalMemoryUser() 46 | {} 47 | 48 | inline const void* GlobalMemoryUser::Allocate(size_t memSize, const char* user) 49 | { 50 | return ECS_MEMORY_MANAGER->Allocate(memSize, user); 51 | } 52 | 53 | inline void GlobalMemoryUser::Free(void* pMem) 54 | { 55 | ECS_MEMORY_MANAGER->Free(pMem); 56 | } 57 | 58 | } // namespace Memory 59 | 60 | ECSEngine* ECS_Engine = nullptr;// new ECSEngine(); 61 | 62 | void Initialize() 63 | { 64 | if(ECS_Engine == nullptr) 65 | ECS_Engine = new ECSEngine(); 66 | } 67 | 68 | void Terminate() 69 | { 70 | if (ECS_Engine != nullptr) 71 | { 72 | delete ECS_Engine; 73 | ECS_Engine = nullptr; 74 | } 75 | 76 | // check for memory leaks 77 | Memory::Internal::ECSMemoryManager->CheckMemoryLeaks(); 78 | } 79 | } // namespace ECS -------------------------------------------------------------------------------- /EntityComponentSystem/src/ComponentManager.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Author : Tobias Stein 3 | Date : 7th September, 2017 4 | File : ComponentManager.cpp 5 | 6 | Manages all component container. 7 | 8 | All Rights Reserved. (c) Copyright 2016. 9 | */ 10 | 11 | 12 | #include "ComponentManager.h" 13 | 14 | namespace ECS { 15 | 16 | ComponentManager::ComponentManager() 17 | { 18 | DEFINE_LOGGER("ComponentManager") 19 | LogInfo("Initialize ComponentManager!"); 20 | 21 | const size_t NUM_COMPONENTS { util::Internal::FamilyTypeID::Get() }; 22 | 23 | this->m_EntityComponentMap.resize(ENITY_LUT_GROW); 24 | for (auto i = 0; i < ENITY_LUT_GROW; ++i) 25 | this->m_EntityComponentMap[i].resize(NUM_COMPONENTS, INVALID_COMPONENT_ID); 26 | } 27 | 28 | ComponentManager::~ComponentManager() 29 | { 30 | for (auto cc : this->m_ComponentContainerRegistry) 31 | { 32 | LogDebug("Releasing remaining entities of type '%s' ...", cc.second->GetComponentContainerTypeName()); 33 | delete cc.second; 34 | cc.second = nullptr; 35 | } 36 | 37 | LogInfo("Release ComponentManager!"); 38 | } 39 | 40 | ComponentId ComponentManager::AqcuireComponentId(IComponent* component) 41 | { 42 | int i = 0; 43 | for (; i < this->m_ComponentLUT.size(); ++i) 44 | { 45 | if (this->m_ComponentLUT[i] == nullptr) 46 | { 47 | this->m_ComponentLUT[i] = component; 48 | return i; 49 | } 50 | } 51 | 52 | // increase component LUT size 53 | this->m_ComponentLUT.resize(this->m_ComponentLUT.size() + COMPONENT_LUT_GROW, nullptr); 54 | 55 | this->m_ComponentLUT[i] = component; 56 | return i; 57 | } 58 | 59 | void ComponentManager::ReleaseComponentId(ComponentId id) 60 | { 61 | assert((id != INVALID_COMPONENT_ID && id < this->m_ComponentLUT.size()) && "Invalid component id"); 62 | this->m_ComponentLUT[id] = nullptr; 63 | } 64 | 65 | void ComponentManager::MapEntityComponent(EntityId entityId, ComponentId componentId, ComponentTypeId componentTypeId) 66 | { 67 | static const size_t NUM_COMPONENTS { util::Internal::FamilyTypeID::Get() }; 68 | 69 | if ((this->m_EntityComponentMap.size() - 1) < entityId.index) 70 | { 71 | size_t oldSize = this->m_EntityComponentMap.size(); 72 | 73 | // we scale this map size along the entity lookup table size 74 | size_t newSize = oldSize + ENITY_LUT_GROW; 75 | 76 | this->m_EntityComponentMap.resize(newSize); 77 | 78 | for (auto i = oldSize; i < newSize; ++i) 79 | this->m_EntityComponentMap[i].resize(NUM_COMPONENTS, INVALID_COMPONENT_ID); 80 | } 81 | 82 | // create mapping 83 | this->m_EntityComponentMap[entityId.index][componentTypeId] = componentId; 84 | } 85 | 86 | void ComponentManager::UnmapEntityComponent(EntityId entityId, ComponentId componentId, ComponentTypeId componentTypeId) 87 | { 88 | assert(this->m_EntityComponentMap[entityId.index][componentTypeId] == componentId && "FATAL: Entity Component ID mapping corruption!"); 89 | 90 | // free mapping 91 | this->m_EntityComponentMap[entityId.index][componentTypeId] = INVALID_COMPONENT_ID; 92 | 93 | // free component id 94 | this->ReleaseComponentId(componentId); 95 | } 96 | 97 | } // namespace ECS -------------------------------------------------------------------------------- /EntityComponentSystem/src/Engine.cpp: -------------------------------------------------------------------------------- 1 | ///------------------------------------------------------------------------------------------------- 2 | /// File: src\Engine.cpp. 3 | /// 4 | /// Summary: Implements the engine class. 5 | ///------------------------------------------------------------------------------------------------- 6 | 7 | 8 | #include "Engine.h" 9 | 10 | #include "Event/EventHandler.h" 11 | 12 | #include "EntityManager.h" 13 | #include "ComponentManager.h" 14 | #include "SystemManager.h" 15 | 16 | #include "util/Timer.h" 17 | 18 | namespace ECS 19 | { 20 | 21 | ECSEngine::ECSEngine() 22 | { 23 | ECS_EngineTime = new util::Timer(); 24 | ECS_EventHandler = new Event::EventHandler(); 25 | ECS_SystemManager = new SystemManager(); 26 | ECS_ComponentManager = new ComponentManager(); 27 | ECS_EntityManager = new EntityManager(this->ECS_ComponentManager); 28 | } 29 | 30 | ECSEngine::~ECSEngine() 31 | { 32 | delete ECS_EntityManager; 33 | ECS_EntityManager = nullptr; 34 | 35 | delete ECS_ComponentManager; 36 | ECS_ComponentManager = nullptr; 37 | 38 | delete ECS_SystemManager; 39 | ECS_SystemManager = nullptr; 40 | 41 | delete ECS_EventHandler; 42 | ECS_EventHandler = nullptr; 43 | } 44 | 45 | void ECSEngine::Update(f32 tick_ms) 46 | { 47 | // Advance engine time 48 | ECS_EngineTime->Tick(tick_ms); 49 | 50 | // Update all running systems 51 | ECS_SystemManager->Update(tick_ms); 52 | ECS_EventHandler->DispatchEvents(); 53 | 54 | // Finalize pending destroyed entities 55 | ECS_EntityManager->RemoveDestroyedEntities(); 56 | ECS_EventHandler->DispatchEvents(); 57 | } 58 | 59 | void ECSEngine::UnsubscribeEvent(Event::Internal::IEventDelegate* eventDelegate) 60 | { 61 | ECS_EventHandler->RemoveEventCallback(eventDelegate); 62 | } 63 | 64 | } // namespace ECS -------------------------------------------------------------------------------- /EntityComponentSystem/src/EntityManager.cpp: -------------------------------------------------------------------------------- 1 | ///------------------------------------------------------------------------------------------------- 2 | /// File: src\EntityManager.cpp. 3 | /// 4 | /// Summary: Implements the entity manager class. 5 | ///------------------------------------------------------------------------------------------------- 6 | 7 | 8 | #include "EntityManager.h" 9 | 10 | namespace ECS 11 | { 12 | EntityManager::EntityManager(ComponentManager* componentManagerInstance) : 13 | m_PendingDestroyedEntities(1024), 14 | m_NumPendingDestroyedEntities(0), 15 | m_ComponentManagerInstance(componentManagerInstance) 16 | { 17 | DEFINE_LOGGER("EntityManager") 18 | LogInfo("Initialize EntityManager!") 19 | } 20 | 21 | EntityManager::~EntityManager() 22 | { 23 | for (auto ec : this->m_EntityRegistry) 24 | { 25 | LogDebug("Releasing remaining entities of type '%s' ...", ec.second->GetEntityContainerTypeName()); 26 | delete ec.second; 27 | ec.second = nullptr; 28 | } 29 | 30 | LogInfo("Release EntityManager!") 31 | } 32 | 33 | EntityId EntityManager::AqcuireEntityId(IEntity* entity) 34 | { 35 | return this->m_EntityHandleTable.AqcuireHandle(entity); 36 | } 37 | 38 | void EntityManager::ReleaseEntityId(EntityId id) 39 | { 40 | this->m_EntityHandleTable.ReleaseHandle(id); 41 | } 42 | 43 | void EntityManager::RemoveDestroyedEntities() 44 | { 45 | for (size_t i = 0; i < this->m_NumPendingDestroyedEntities; ++i) 46 | { 47 | EntityId entityId = this->m_PendingDestroyedEntities[i]; 48 | 49 | IEntity* entity = this->m_EntityHandleTable[entityId]; 50 | 51 | const EntityTypeId ETID = entity->GetStaticEntityTypeID(); 52 | 53 | // get appropriate entity container and destroy entity 54 | auto it = this->m_EntityRegistry.find(ETID); 55 | if (it != this->m_EntityRegistry.end()) 56 | { 57 | // release entity's components 58 | this->m_ComponentManagerInstance->RemoveAllComponents(entityId); 59 | 60 | it->second->DestroyEntity(entity); 61 | } 62 | 63 | // free entity id 64 | this->ReleaseEntityId(entityId); 65 | } 66 | 67 | this->m_NumPendingDestroyedEntities = 0; 68 | } 69 | 70 | } // namespace ECS -------------------------------------------------------------------------------- /EntityComponentSystem/src/Event/EventHandler.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Author : Tobias Stein 3 | Date : 9th July, 2016 4 | File : EventHandler.cpp 5 | 6 | EventHandler class. 7 | 8 | All Rights Reserved. (c) Copyright 2016. 9 | */ 10 | 11 | #include "Event/EventHandler.h" 12 | 13 | namespace ECS { namespace Event { 14 | 15 | EventHandler::EventHandler() 16 | { 17 | DEFINE_LOGGER("EventHandler") 18 | LogInfo("Initialize EventHandler!"); 19 | 20 | // allocate memory from global memory manager 21 | this->m_EventMemoryAllocator = new EventMemoryAllocator(ECS_EVENT_MEMORY_BUFFER_SIZE, Allocate(ECS_EVENT_MEMORY_BUFFER_SIZE, "EventHandler")); 22 | 23 | this->m_EventStorage.reserve(1024); 24 | } 25 | 26 | EventHandler::~EventHandler() 27 | { 28 | for (EventHandler::EventDispatcherMap::iterator it = this->m_EventDispatcherMap.begin(); it != this->m_EventDispatcherMap.end(); ++it) 29 | { 30 | delete (*it).second; 31 | (*it).second = nullptr; 32 | } 33 | 34 | this->m_EventDispatcherMap.clear(); 35 | 36 | // Release allocated memory 37 | Free((void*)this->m_EventMemoryAllocator->GetMemoryAddress0()); 38 | 39 | delete this->m_EventMemoryAllocator; 40 | this->m_EventMemoryAllocator = nullptr; 41 | 42 | LogInfo("Relealse EventHandler!"); 43 | } 44 | 45 | }} // namespace ECS::Event -------------------------------------------------------------------------------- /EntityComponentSystem/src/Event/IEvent.cpp: -------------------------------------------------------------------------------- 1 | ///------------------------------------------------------------------------------------------------- 2 | /// File: src\Event\IEvent.cpp. 3 | /// 4 | /// Summary: Declares the IEvent interface. 5 | ///------------------------------------------------------------------------------------------------- 6 | 7 | 8 | #include "Event/IEvent.h" 9 | 10 | #include "Engine.h" 11 | #include "util/Timer.h" 12 | 13 | namespace ECS { namespace Event { 14 | 15 | IEvent::IEvent(EventTypeId typeId) : 16 | m_TypeId(typeId) 17 | { 18 | assert(ECS_Engine != nullptr && "ECS engine not initialized!"); 19 | this->m_TimeCreated = ECS_Engine->ECS_EngineTime->GetTimeStamp(); 20 | } 21 | 22 | }} // namespace ECS::Event 23 | -------------------------------------------------------------------------------- /EntityComponentSystem/src/Event/IEventListener.cpp: -------------------------------------------------------------------------------- 1 | ///------------------------------------------------------------------------------------------------- 2 | /// File: src\Event\IEventListener.cpp. 3 | /// 4 | /// Summary: Declares the IEventListener interface. 5 | ///------------------------------------------------------------------------------------------------- 6 | 7 | #include "Event/IEventListener.h" 8 | 9 | #include "Engine.h" 10 | 11 | namespace ECS { namespace Event { 12 | 13 | IEventListener::IEventListener() 14 | {} 15 | 16 | IEventListener::~IEventListener() 17 | { 18 | // unsubcribe from all subscribed events 19 | UnregisterAllEventCallbacks(); 20 | } 21 | 22 | void IEventListener::UnregisterAllEventCallbacks() 23 | { 24 | // unsubcribe from all subscribed events 25 | for (auto cb : this->m_RegisteredCallbacks) 26 | { 27 | ECS_Engine->UnsubscribeEvent(cb); 28 | } 29 | 30 | this->m_RegisteredCallbacks.clear(); 31 | } 32 | 33 | }} // namespace ECS::Event 34 | -------------------------------------------------------------------------------- /EntityComponentSystem/src/IComponent.cpp: -------------------------------------------------------------------------------- 1 | ///------------------------------------------------------------------------------------------------- 2 | /// File: src\IComponent.cpp. 3 | /// 4 | /// Summary: Declares the IComponent interface. 5 | ///------------------------------------------------------------------------------------------------- 6 | 7 | #include "IComponent.h" 8 | 9 | namespace ECS 10 | { 11 | IComponent::IComponent() : 12 | m_Owner(INVALID_ENTITY_ID), 13 | m_Enabled(true) 14 | {} 15 | 16 | IComponent::~IComponent() 17 | {} 18 | 19 | } // namespace ECS -------------------------------------------------------------------------------- /EntityComponentSystem/src/IEntity.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Author : Tobias Stein 3 | Date : 3rd July, 2016 4 | File : Entity.cpp 5 | 6 | Entity class. 7 | 8 | All Rights Reserved. (c) Copyright 2016. 9 | */ 10 | 11 | #include "IEntity.h" 12 | 13 | namespace ECS 14 | { 15 | DEFINE_STATIC_LOGGER(IEntity, "Entity") 16 | 17 | IEntity::IEntity() : 18 | m_Active(true) 19 | {} 20 | 21 | IEntity::~IEntity() 22 | {} 23 | 24 | void IEntity::SetActive(bool active) 25 | { 26 | if (this->m_Active == active) 27 | return; 28 | 29 | if (active == false) 30 | { 31 | this->OnDisable(); 32 | } 33 | else 34 | { 35 | this->OnEnable(); 36 | } 37 | 38 | this->m_Active = active; 39 | } 40 | } -------------------------------------------------------------------------------- /EntityComponentSystem/src/ISystem.cpp: -------------------------------------------------------------------------------- 1 | ///------------------------------------------------------------------------------------------------- 2 | /// File: src\ISystem.cpp. 3 | /// 4 | /// Summary: Declares the ISystem interface. 5 | ///------------------------------------------------------------------------------------------------- 6 | 7 | #include "ISystem.h" 8 | 9 | namespace ECS 10 | { 11 | 12 | ISystem::ISystem(SystemPriority priority, f32 updateInterval_ms) : 13 | m_Priority(priority), 14 | m_UpdateInterval(updateInterval_ms), 15 | m_Enabled(true) 16 | {} 17 | 18 | ISystem::~ISystem() 19 | {} 20 | 21 | } // namespace ECS -------------------------------------------------------------------------------- /EntityComponentSystem/src/Log/Logger.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Author : Tobias Stein 3 | Date : 11th September, 2016 4 | File : Logger.cpp 5 | 6 | Class that manages the logging. 7 | 8 | All Rights Reserved. (c) Copyright 2016. 9 | */ 10 | 11 | #if !ECS_DISABLE_LOGGING 12 | 13 | #include "Log/Logger.h" 14 | 15 | namespace ECS { namespace Log { 16 | 17 | Logger::Logger(log4cplus::Logger& logger) : 18 | m_logger(logger) 19 | {} 20 | 21 | Logger::~Logger() 22 | {} 23 | 24 | }} // namespace ECS::Log 25 | 26 | #endif // !ECS_DISABLE_LOGGING -------------------------------------------------------------------------------- /EntityComponentSystem/src/Log/LoggerManager.cpp: -------------------------------------------------------------------------------- 1 | ///------------------------------------------------------------------------------------------------- 2 | /// File: src\Log\LoggerManager.cpp. 3 | /// 4 | /// Summary: Implements the logger manager class. 5 | 6 | #if !ECS_DISABLE_LOGGING 7 | 8 | #include "Log/LoggerManager.h" 9 | #include "Log/Logger.h" 10 | 11 | #include "log4cplus/layout.h" 12 | #include "log4cplus/ConsoleAppender.h" 13 | #include "log4cplus/FileAppender.h" 14 | 15 | namespace ECS { namespace Log { namespace Internal { 16 | 17 | LoggerManager::LoggerManager() 18 | { 19 | log4cplus::initialize(); 20 | 21 | // create a conversion pattern 22 | const log4cplus::tstring PATTERN = LOG4CPLUS_TEXT(LOG_PATTERN); 23 | 24 | // create console log output 25 | log4cplus::SharedAppenderPtr consoleApp(new log4cplus::ConsoleAppender()); 26 | consoleApp->setLayout(std::auto_ptr(new log4cplus::PatternLayout(PATTERN))); 27 | 28 | // create log file output 29 | log4cplus::SharedAppenderPtr fileApp(new log4cplus::FileAppender(LOG4CPLUS_TEXT(LOG_FILE_NAME))); 30 | fileApp->setLayout(std::auto_ptr(new log4cplus::PatternLayout(PATTERN))); 31 | 32 | // get root logger 33 | this->m_RootLogger = log4cplus::Logger::getRoot(); 34 | 35 | // set root log level 36 | this->m_RootLogger.setLogLevel(log4cplus::ALL_LOG_LEVEL); 37 | 38 | // add appenders 39 | this->m_RootLogger.addAppender(consoleApp); 40 | this->m_RootLogger.addAppender(fileApp); 41 | } 42 | 43 | LoggerManager::~LoggerManager() 44 | { 45 | // cleanup logger 46 | for (auto& it : this->m_Cache) 47 | { 48 | delete it.second; 49 | it.second = nullptr; 50 | } 51 | 52 | log4cplus::Logger::getRoot().shutdown(); 53 | log4cplus::threadCleanup(); 54 | } 55 | 56 | Logger* LoggerManager::GetLogger(const char* name) 57 | { 58 | auto it = this->m_Cache.find(name); 59 | if (it == this->m_Cache.end()) 60 | { 61 | this->m_Cache.insert(std::make_pair(name, new Logger(this->m_RootLogger.getInstance(name)))); 62 | } 63 | 64 | return this->m_Cache[name]; 65 | } 66 | 67 | }}} // namespace ECS::Log::Internal 68 | 69 | #endif // !ECS_DISABLE_LOGGING -------------------------------------------------------------------------------- /EntityComponentSystem/src/Memory/Allocator/IAllocator.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Author : Tobias Stein 3 | Date : 9th July, 2016 4 | File : IAllocator.cpp 5 | 6 | Base allocator class. 7 | 8 | All Rights Reserved. (c) Copyright 2016. 9 | */ 10 | 11 | #include "Memory/Allocator/IAllocator.h" 12 | 13 | namespace ECS { namespace Memory { namespace Allocator { 14 | 15 | IAllocator::IAllocator(const size_t memSize, const void* mem) : 16 | m_MemorySize(memSize), 17 | m_MemoryFirstAddress(mem), 18 | m_MemoryUsed(0), 19 | m_MemoryAllocations(0) 20 | {} 21 | 22 | IAllocator::~IAllocator() 23 | {} 24 | 25 | }}} // ECS::Memory::Allocator -------------------------------------------------------------------------------- /EntityComponentSystem/src/Memory/Allocator/LinearAllocator.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Author : Tobias Stein 3 | Date : 22nd October, 2016 4 | File : LinearAllocator.cpp 5 | 6 | Linear allocator. 7 | 8 | All Rights Reserved. (c) Copyright 2016. 9 | */ 10 | 11 | #include "Memory/Allocator/LinearAllocator.h" 12 | 13 | 14 | namespace ECS { namespace Memory { namespace Allocator { 15 | 16 | LinearAllocator::LinearAllocator(size_t memSize, const void* mem) : 17 | IAllocator(memSize, mem) 18 | {} 19 | 20 | LinearAllocator::~LinearAllocator() 21 | { 22 | this->clear(); 23 | } 24 | 25 | void* LinearAllocator::allocate(size_t memSize, u8 alignment) 26 | { 27 | assert(memSize > 0 && "allocate called with memSize = 0."); 28 | 29 | union 30 | { 31 | void* asVoidPtr; 32 | uptr asUptr; 33 | }; 34 | 35 | asVoidPtr = (void*)this->m_MemoryFirstAddress; 36 | 37 | // current address 38 | asUptr += this->m_MemoryUsed; 39 | 40 | // get adjustment to align address 41 | u8 adjustment = GetAdjustment(asVoidPtr, alignment); 42 | 43 | // check if there is enough memory available 44 | if (this->m_MemoryUsed + memSize + adjustment > this->m_MemorySize) 45 | { 46 | // not enough memory 47 | return nullptr; 48 | } 49 | 50 | // determine aligned memory address 51 | asUptr += adjustment; 52 | 53 | // update book keeping 54 | this->m_MemoryUsed += memSize + adjustment; 55 | this->m_MemoryAllocations++; 56 | 57 | // return aligned memory address 58 | return asVoidPtr; 59 | } 60 | 61 | void LinearAllocator::free(void* mem) 62 | { 63 | assert(false && "Lineaer allocators do not support free operations. Use clear instead."); 64 | } 65 | 66 | void LinearAllocator::clear() 67 | { 68 | // simply reset memory 69 | this->m_MemoryUsed = 0; 70 | this->m_MemoryAllocations = 0; 71 | } 72 | 73 | } } } // namespace ECS::Memory::Allocator -------------------------------------------------------------------------------- /EntityComponentSystem/src/Memory/Allocator/PoolAllocator.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Author : Tobias Stein 3 | Date : 22nd October, 2016 4 | File : PoolAllocator.cpp 5 | 6 | Pool allocator. 7 | 8 | All Rights Reserved. (c) Copyright 2016. 9 | */ 10 | 11 | #include "Memory/Allocator/PoolAllocator.h" 12 | 13 | namespace ECS { namespace Memory { namespace Allocator { 14 | 15 | PoolAllocator::PoolAllocator(size_t memSize, const void* mem, size_t objectSize, u8 objectAlignment) : 16 | IAllocator(memSize, mem), 17 | OBJECT_SIZE(objectSize), 18 | OBJECT_ALIGNMENT(objectAlignment) 19 | { 20 | this->clear(); 21 | } 22 | 23 | PoolAllocator::~PoolAllocator() 24 | { 25 | this->freeList = nullptr; 26 | } 27 | 28 | 29 | void* PoolAllocator::allocate(size_t memSize, u8 alignment) 30 | { 31 | assert(memSize > 0 && "allocate called with memSize = 0."); 32 | assert(memSize == this->OBJECT_SIZE && alignment == this->OBJECT_ALIGNMENT); 33 | 34 | if (this->freeList == nullptr) 35 | return nullptr; 36 | 37 | // get free slot 38 | void* p = this->freeList; 39 | 40 | // point to next free slot 41 | this->freeList = (void**)(*this->freeList); 42 | 43 | this->m_MemoryUsed += this->OBJECT_SIZE; 44 | this->m_MemoryAllocations++; 45 | 46 | return p; 47 | } 48 | 49 | 50 | void PoolAllocator::free(void* mem) 51 | { 52 | // put this slot back to free list 53 | *((void**)mem) = this->freeList; 54 | 55 | this->freeList = (void**)mem; 56 | 57 | this->m_MemoryUsed -= this->OBJECT_SIZE; 58 | this->m_MemoryAllocations--; 59 | } 60 | 61 | 62 | void PoolAllocator::clear() 63 | { 64 | u8 adjustment = GetAdjustment(this->m_MemoryFirstAddress, this->OBJECT_ALIGNMENT); 65 | 66 | size_t numObjects = (size_t)floor((this->m_MemorySize - adjustment) / this->OBJECT_SIZE); 67 | 68 | union 69 | { 70 | void* asVoidPtr; 71 | uptr asUptr; 72 | }; 73 | 74 | asVoidPtr = (void*)this->m_MemoryFirstAddress; 75 | 76 | // align start address 77 | asUptr += adjustment; 78 | 79 | this->freeList = (void**)asVoidPtr; 80 | 81 | void** p = this->freeList; 82 | 83 | for (int i = 0; i < (numObjects - 1); ++i) 84 | { 85 | *p = (void*)((uptr)p + this->OBJECT_SIZE); 86 | 87 | p = (void**)*p; 88 | } 89 | 90 | *p = nullptr; 91 | } 92 | 93 | }}} // namespace ECS::Memory::Allocator -------------------------------------------------------------------------------- /EntityComponentSystem/src/Memory/Allocator/StackAllocator.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Author : Tobias Stein 3 | Date : 22nd October, 2016 4 | File : StackAllocator.cpp 5 | 6 | Pool allocator. 7 | 8 | All Rights Reserved. (c) Copyright 2016. 9 | */ 10 | 11 | #include "Memory/Allocator/StackAllocator.h" 12 | 13 | namespace ECS { namespace Memory { namespace Allocator { 14 | 15 | StackAllocator::StackAllocator(size_t memSize, const void* mem) : 16 | IAllocator(memSize, mem) 17 | {} 18 | 19 | StackAllocator::~StackAllocator() 20 | { 21 | this->clear(); 22 | } 23 | 24 | void* StackAllocator::allocate(size_t memSize, u8 alignment) 25 | { 26 | assert(memSize > 0 && "allocate called with memSize = 0."); 27 | 28 | union 29 | { 30 | void* asVoidPtr; 31 | uptr asUptr; 32 | AllocMetaInfo* asMeta; 33 | }; 34 | 35 | asVoidPtr = (void*)this->m_MemoryFirstAddress; 36 | 37 | // current address 38 | asUptr += this->m_MemoryUsed; 39 | 40 | u8 adjustment = GetAdjustment(asVoidPtr, alignment, sizeof(AllocMetaInfo)); 41 | 42 | // check if there is enough memory available 43 | if (this->m_MemoryUsed + memSize + adjustment > this->m_MemorySize) 44 | { 45 | // not enough memory 46 | return nullptr; 47 | } 48 | 49 | // store alignment in allocation meta info 50 | asMeta->adjustment = adjustment; 51 | 52 | // determine aligned memory address 53 | asUptr += adjustment; 54 | 55 | // update book keeping 56 | this->m_MemoryUsed += memSize + adjustment; 57 | this->m_MemoryAllocations++; 58 | 59 | // return aligned memory address 60 | return asVoidPtr; 61 | } 62 | 63 | void StackAllocator::free(void* mem) 64 | { 65 | union 66 | { 67 | void* asVoidPtr; 68 | uptr asUptr; 69 | AllocMetaInfo* asMeta; 70 | }; 71 | 72 | asVoidPtr = mem; 73 | 74 | // get meta info 75 | asUptr -= sizeof(AllocMetaInfo); 76 | 77 | // free used memory 78 | this->m_MemoryUsed -= ((uptr)this->m_MemoryFirstAddress + this->m_MemoryUsed) - ((uptr)mem + asMeta->adjustment); 79 | 80 | // decrement allocation count 81 | this->m_MemoryAllocations--; 82 | } 83 | 84 | void StackAllocator::clear() 85 | { 86 | // simply reset memory 87 | this->m_MemoryUsed = 0; 88 | this->m_MemoryAllocations = 0; 89 | } 90 | 91 | } } } // namespace ECS::Memory::Allocator -------------------------------------------------------------------------------- /EntityComponentSystem/src/Memory/ECSMM.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Author : Tobias Stein 3 | Date : 6th September, 2017 4 | File : ECSMM.cpp 5 | 6 | Internal used memory manager. 7 | 8 | All Rights Reserved. (c) Copyright 2016 - 2017. 9 | */ 10 | 11 | #include "Memory/ECSMM.h" 12 | 13 | namespace ECS { namespace Memory { namespace Internal { 14 | 15 | 16 | MemoryManager::MemoryManager() 17 | { 18 | DEFINE_LOGGER("MemoryManager") 19 | LogInfo("Initialize MemoryManager!"); 20 | 21 | // allocate global memory 22 | this->m_GlobalMemory = malloc(MemoryManager::MEMORY_CAPACITY); 23 | if (this->m_GlobalMemory != nullptr) 24 | { 25 | LogInfo("%d bytes of memory allocated.", MemoryManager::MEMORY_CAPACITY); 26 | } 27 | else 28 | { 29 | LogFatal("Failed to allocate %d bytes of memory!", MemoryManager::MEMORY_CAPACITY); 30 | assert(this->m_GlobalMemory != nullptr && "Failed to allocate global memory."); 31 | } 32 | 33 | // create allocator 34 | this->m_MemoryAllocator = new StackAllocator(MemoryManager::MEMORY_CAPACITY, this->m_GlobalMemory); 35 | assert(this->m_MemoryAllocator != nullptr && "Failed to create memory allocator!"); 36 | 37 | this->m_PendingMemory.clear(); 38 | this->m_FreedMemory.clear(); 39 | } 40 | 41 | MemoryManager::~MemoryManager() 42 | { 43 | LogInfo("Releasing MemoryManager!"); 44 | 45 | this->m_MemoryAllocator->clear(); 46 | 47 | delete this->m_MemoryAllocator; 48 | this->m_MemoryAllocator = nullptr; 49 | 50 | free(this->m_GlobalMemory); 51 | this->m_GlobalMemory = nullptr; 52 | } 53 | 54 | void MemoryManager::CheckMemoryLeaks() 55 | { 56 | assert(!(this->m_FreedMemory.size() > 0 && this->m_PendingMemory.size() == 0) && "Implementation failure!"); 57 | 58 | if (this->m_PendingMemory.size() > 0) 59 | { 60 | LogFatal("!!! M E M O R Y L E A K D E T E C T E D !!!") 61 | LogFatal("!!! M E M O R Y L E A K D E T E C T E D !!!") 62 | LogFatal("!!! M E M O R Y L E A K D E T E C T E D !!!") 63 | 64 | for (auto i : this->m_PendingMemory) 65 | { 66 | bool isFreed = false; 67 | 68 | for (auto j : this->m_FreedMemory) 69 | { 70 | if (i.second == j) 71 | { 72 | isFreed = true; 73 | break; 74 | } 75 | } 76 | 77 | if (isFreed == false) 78 | { 79 | LogFatal("\'%s\' memory user didn't release allocated memory %p!", i.first, i.second) 80 | } 81 | } 82 | } 83 | else 84 | { 85 | LogInfo("No memory leaks detected.") 86 | } 87 | } 88 | 89 | }}} // namespace ECS::Memory::Internal 90 | -------------------------------------------------------------------------------- /EntityComponentSystem/src/util/FamilyTypeID.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Author : Tobias Stein 3 | Date : 3rd September, 2017 4 | File : FamilyTypeID.h 5 | 6 | A static counter that increments thee count for a specific type. 7 | 8 | All Rights Reserved. (c) Copyright 2016 - 2017. 9 | */ 10 | 11 | #include "util/FamilyTypeID.h" 12 | 13 | namespace ECS 14 | { 15 | class IEntity; 16 | class IComponent; 17 | class ISystem; 18 | 19 | namespace util { namespace Internal { 20 | 21 | u64 FamilyTypeID::s_count = 0u; 22 | u64 FamilyTypeID::s_count = 0u; 23 | u64 FamilyTypeID::s_count = 0u; 24 | 25 | template class FamilyTypeID; 26 | template class FamilyTypeID; 27 | template class FamilyTypeID; 28 | }} 29 | 30 | } // namespace ECS::util::Internal -------------------------------------------------------------------------------- /EntityComponentSystem/src/util/Timer.cpp: -------------------------------------------------------------------------------- 1 | ///------------------------------------------------------------------------------------------------- 2 | /// File: src\util\Timer.cpp. 3 | /// 4 | /// Summary: Implements the timer class. 5 | ///------------------------------------------------------------------------------------------------- 6 | 7 | #include "util/Timer.h" 8 | 9 | namespace ECS { namespace util { 10 | 11 | Timer::Timer() : 12 | m_Elapsed(0) 13 | {} 14 | 15 | Timer::~Timer() 16 | {} 17 | 18 | void Timer::Tick(float ms) 19 | { 20 | this->m_Elapsed += std::chrono::duration>(ms); 21 | } 22 | 23 | void Timer::Reset() 24 | { 25 | this->m_Elapsed = Elapsed::zero(); 26 | } 27 | 28 | }} // namespace ECS::util -------------------------------------------------------------------------------- /ThirdParty/log4cplus-1.2.1-rc2/include/log4cplus/asyncappender.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4cplus 3 | // File: asyncappender.h 4 | // Created: 1/2009 5 | // Author: Vaclav Haisman 6 | // 7 | // 8 | // Copyright (C) 2009-2015, Vaclav Haisman. All rights reserved. 9 | // 10 | // Redistribution and use in source and binary forms, with or without modifica- 11 | // tion, are permitted provided that the following conditions are met: 12 | // 13 | // 1. Redistributions of source code must retain the above copyright notice, 14 | // this list of conditions and the following disclaimer. 15 | // 16 | // 2. Redistributions in binary form must reproduce the above copyright notice, 17 | // this list of conditions and the following disclaimer in the documentation 18 | // and/or other materials provided with the distribution. 19 | // 20 | // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 21 | // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 22 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 23 | // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- 25 | // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 26 | // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 27 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | 32 | // 33 | 34 | /** @file */ 35 | 36 | #ifndef LOG4CPLUS_ASYNCAPPENDER_H 37 | #define LOG4CPLUS_ASYNCAPPENDER_H 38 | 39 | #include 40 | 41 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 42 | #pragma once 43 | #endif 44 | 45 | #ifndef LOG4CPLUS_SINGLE_THREADED 46 | 47 | #include 48 | #include 49 | #include 50 | #include 51 | 52 | 53 | namespace log4cplus 54 | { 55 | 56 | 57 | class LOG4CPLUS_EXPORT AsyncAppender 58 | : public Appender 59 | , public helpers::AppenderAttachableImpl 60 | { 61 | public: 62 | AsyncAppender (SharedAppenderPtr const & app, unsigned max_len); 63 | AsyncAppender (helpers::Properties const &); 64 | virtual ~AsyncAppender (); 65 | 66 | virtual void close (); 67 | 68 | protected: 69 | virtual void append (spi::InternalLoggingEvent const &); 70 | 71 | void init_queue_thread (unsigned); 72 | 73 | thread::AbstractThreadPtr queue_thread; 74 | thread::QueuePtr queue; 75 | 76 | private: 77 | AsyncAppender (AsyncAppender const &); 78 | AsyncAppender & operator = (AsyncAppender const &); 79 | }; 80 | 81 | 82 | typedef helpers::SharedObjectPtr AsyncAppenderPtr; 83 | 84 | 85 | } // namespace log4cplus 86 | 87 | 88 | #endif // LOG4CPLUS_SINGLE_THREADED 89 | 90 | #endif // LOG4CPLUS_ASYNCAPPENDER_H 91 | -------------------------------------------------------------------------------- /ThirdParty/log4cplus-1.2.1-rc2/include/log4cplus/clfsappender.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4cplus 3 | // File: clfsappender.h 4 | // Created: 5/2012 5 | // Author: Vaclav Zeman 6 | // 7 | // 8 | // Copyright (C) 2012-2015, Vaclav Zeman. All rights reserved. 9 | // 10 | // Redistribution and use in source and binary forms, with or without modifica- 11 | // tion, are permitted provided that the following conditions are met: 12 | // 13 | // 1. Redistributions of source code must retain the above copyright notice, 14 | // this list of conditions and the following disclaimer. 15 | // 16 | // 2. Redistributions in binary form must reproduce the above copyright notice, 17 | // this list of conditions and the following disclaimer in the documentation 18 | // and/or other materials provided with the distribution. 19 | // 20 | // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 21 | // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 22 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 23 | // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- 25 | // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 26 | // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 27 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | 32 | // 33 | 34 | /** @file */ 35 | 36 | #ifndef LOG4CPLUS_CLFSAPPENDER_H 37 | #define LOG4CPLUS_CLFSAPPENDER_H 38 | 39 | #include 40 | 41 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 42 | #pragma once 43 | #endif 44 | 45 | #include 46 | 47 | 48 | #if defined (LOG4CPLUS_CLFSAPPENDER_BUILD_DLL) 49 | # if defined (INSIDE_LOG4CPLUS_CLFSAPPENDER) 50 | # define LOG4CPLUS_CLFSAPPENDER_EXPORT __declspec(dllexport) 51 | # else 52 | # define LOG4CPLUS_CLFSAPPENDER_EXPORT __declspec(dllimport) 53 | # endif 54 | #else 55 | # define LOG4CPLUS_CLFSAPPENDER_EXPORT 56 | #endif 57 | 58 | 59 | namespace log4cplus 60 | { 61 | 62 | 63 | class LOG4CPLUS_CLFSAPPENDER_EXPORT CLFSAppender 64 | : public Appender 65 | { 66 | public: 67 | CLFSAppender (tstring const & logname, unsigned long logsize, 68 | unsigned long buffersize); 69 | explicit CLFSAppender (helpers::Properties const &); 70 | virtual ~CLFSAppender (); 71 | 72 | virtual void close (); 73 | 74 | static void registerAppender (); 75 | 76 | protected: 77 | virtual void append (spi::InternalLoggingEvent const &); 78 | 79 | void init (tstring const & logname, unsigned long logsize, 80 | unsigned long buffersize); 81 | 82 | struct Data; 83 | 84 | Data * data; 85 | 86 | private: 87 | CLFSAppender (CLFSAppender const &); 88 | CLFSAppender & operator = (CLFSAppender const &); 89 | }; 90 | 91 | 92 | typedef helpers::SharedObjectPtr CLFSAppenderPtr; 93 | 94 | 95 | } // namespace log4cplus 96 | 97 | 98 | #endif // LOG4CPLUS_CLFSAPPENDER_H 99 | -------------------------------------------------------------------------------- /ThirdParty/log4cplus-1.2.1-rc2/include/log4cplus/clogger.h: -------------------------------------------------------------------------------- 1 | // -*- C -*- 2 | /** 3 | * Module: Log4CPLUS 4 | * File: clogger.h 5 | * Created: 01/2011 6 | * Author: Jens Rehsack 7 | * 8 | * 9 | * Copyright 2011-2015 Jens Rehsack & Tad E. Smith 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | */ 23 | 24 | /** @file 25 | * This header defines the C API for log4cplus and the logging macros. */ 26 | 27 | #ifndef LOG4CPLUS_CLOGGERHEADER_ 28 | #define LOG4CPLUS_CLOGGERHEADER_ 29 | 30 | #include 31 | 32 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 33 | #pragma once 34 | #endif 35 | 36 | 37 | #ifdef __cplusplus 38 | extern "C" 39 | { 40 | #endif 41 | 42 | // TODO UNICDE capable 43 | 44 | typedef void *logger_t; 45 | typedef int loglevel_t; 46 | 47 | #define L4CP_OFF_LOG_LEVEL 60000 48 | #define L4CP_FATAL_LOG_LEVEL 50000 49 | #define L4CP_ERROR_LOG_LEVEL 40000 50 | #define L4CP_WARN_LOG_LEVEL 30000 51 | #define L4CP_INFO_LOG_LEVEL 20000 52 | #define L4CP_DEBUG_LOG_LEVEL 10000 53 | #define L4CP_TRACE_LOG_LEVEL 0 54 | #define L4CP_ALL_LOG_LEVEL TRACE_LOG_LEVEL 55 | #define L4CP_NOT_SET_LOG_LEVEL -1 56 | 57 | #ifdef UNICODE 58 | # define LOG4CPLUS_TEXT2(STRING) L##STRING 59 | typedef wchar_t log4cplus_char_t; 60 | #else 61 | # define LOG4CPLUS_TEXT2(STRING) STRING 62 | typedef char log4cplus_char_t; 63 | #endif // UNICODE 64 | #define LOG4CPLUS_TEXT(STRING) LOG4CPLUS_TEXT2(STRING) 65 | 66 | LOG4CPLUS_EXPORT int log4cplus_file_configure(const log4cplus_char_t *pathname); 67 | LOG4CPLUS_EXPORT int log4cplus_str_configure(const log4cplus_char_t *config); 68 | LOG4CPLUS_EXPORT int log4cplus_basic_configure(void); 69 | LOG4CPLUS_EXPORT void log4cplus_shutdown(void); 70 | 71 | LOG4CPLUS_EXPORT int log4cplus_logger_exists(const log4cplus_char_t *name); 72 | LOG4CPLUS_EXPORT int log4cplus_logger_is_enabled_for( 73 | const log4cplus_char_t *name, loglevel_t ll); 74 | LOG4CPLUS_EXPORT int log4cplus_logger_log(const log4cplus_char_t *name, 75 | loglevel_t ll, const log4cplus_char_t *msgfmt, ...) 76 | LOG4CPLUS_FORMAT_ATTRIBUTE (__printf__, 3, 4); 77 | LOG4CPLUS_EXPORT int log4cplus_logger_force_log(const log4cplus_char_t *name, 78 | loglevel_t ll, const log4cplus_char_t *msgfmt, ...) 79 | LOG4CPLUS_FORMAT_ATTRIBUTE (__printf__, 3, 4); 80 | 81 | #ifdef __cplusplus 82 | } 83 | #endif 84 | 85 | #endif /*?LOG4CPLUS_CLOGGERHEADER_*/ 86 | -------------------------------------------------------------------------------- /ThirdParty/log4cplus-1.2.1-rc2/include/log4cplus/config/macosx.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: config-macosx.h 4 | // Created: 7/2003 5 | // Author: Christopher R. Bailey 6 | // 7 | // 8 | // Copyright 2003-2015 Christopher R. Bailey 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_CONFIG_MACOSX_HEADER_ 25 | #define LOG4CPLUS_CONFIG_MACOSX_HEADER_ 26 | 27 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 28 | #pragma once 29 | #endif 30 | 31 | #if (defined(__APPLE__) || (defined(__MWERKS__) && defined(__MACOS__))) 32 | 33 | #define LOG4CPLUS_HAVE_GETTIMEOFDAY 1 34 | #define socklen_t int 35 | 36 | #endif // MACOSX 37 | #endif // LOG4CPLUS_CONFIG_MACOSX_HEADER_ 38 | -------------------------------------------------------------------------------- /ThirdParty/log4cplus-1.2.1-rc2/include/log4cplus/config/windowsh-inc.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: windowsh-inc.h 4 | // Created: 4/2010 5 | // Author: Vaclav Zeman 6 | // 7 | // 8 | // Copyright (C) 2010-2015, Vaclav Zeman. All rights reserved. 9 | // 10 | // Redistribution and use in source and binary forms, with or without modifica- 11 | // tion, are permitted provided that the following conditions are met: 12 | // 13 | // 1. Redistributions of source code must retain the above copyright notice, 14 | // this list of conditions and the following disclaimer. 15 | // 16 | // 2. Redistributions in binary form must reproduce the above copyright notice, 17 | // this list of conditions and the following disclaimer in the documentation 18 | // and/or other materials provided with the distribution. 19 | // 20 | // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 21 | // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 22 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 23 | // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- 25 | // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 26 | // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 27 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // NOTE: This file is a fragment intentionally left without include guards. 32 | 33 | #if defined (_WIN32) 34 | #undef WIN32_LEAN_AND_MEAN 35 | #define WIN32_LEAN_AND_MEAN 36 | 37 | #undef NOGDICAPMASKS 38 | #define NOGDICAPMASKS 39 | 40 | #undef NOVIRTUALKEYCODES 41 | #define NOVIRTUALKEYCODES 42 | 43 | #undef NOWINMESSAGES 44 | #define NOWINMESSAGES 45 | 46 | #undef NOWINSTYLES 47 | #define NOWINSTYLES 48 | 49 | #undef NOSYSMETRICS 50 | #define NOSYSMETRICS 51 | 52 | #undef NOMENUS 53 | #define NOMENUS 54 | 55 | #undef NOICONS 56 | #define NOICONS 57 | 58 | #undef NOKEYSTATES 59 | #define NOKEYSTATES 60 | 61 | #undef NOSYSCOMMANDS 62 | #define NOSYSCOMMANDS 63 | 64 | #undef NORASTEROPS 65 | #define NORASTEROPS 66 | 67 | #undef NOSHOWWINDOW 68 | #define NOSHOWWINDOW 69 | 70 | #undef NOATOM 71 | #define NOATOM 72 | 73 | #undef NOCLIPBOARD 74 | #define NOCLIPBOARD 75 | 76 | #undef NOCOLOR 77 | #define NOCOLOR 78 | 79 | #undef NOCTLMGR 80 | #define NOCTLMGR 81 | 82 | #undef NODRAWTEXT 83 | #define NODRAWTEXT 84 | 85 | #undef NOGDI 86 | #define NOGDI 87 | 88 | #undef NOKERNEL 89 | #define NOKERNEL 90 | 91 | #undef NOUSER 92 | #define NOUSER 93 | 94 | #undef NONLS 95 | #define NONLS 96 | 97 | #undef NOMB 98 | #define NOMB 99 | 100 | #undef NOMEMMGR 101 | #define NOMEMMGR 102 | 103 | #undef NOMETAFILE 104 | #define NOMETAFILE 105 | 106 | #undef NOMINMAX 107 | #define NOMINMAX 108 | 109 | #undef NOMSG 110 | #define NOMSG 111 | 112 | #undef NOOPENFILE 113 | #define NOOPENFILE 114 | 115 | #undef NOSCROLL 116 | #define NOSCROLL 117 | 118 | #undef NOSERVICE 119 | #define NOSERVICE 120 | 121 | #undef NOSOUND 122 | #define NOSOUND 123 | 124 | #undef NOTEXTMETRIC 125 | #define NOTEXTMETRIC 126 | 127 | #undef NOWH 128 | #define NOWH 129 | 130 | #undef NOWINOFFSETS 131 | #define NOWINOFFSETS 132 | 133 | #undef NOCOMM 134 | #define NOCOMM 135 | 136 | #undef NOKANJI 137 | #define NOKANJI 138 | 139 | #undef NOHELP 140 | #define NOHELP 141 | 142 | #undef NOPROFILER 143 | #define NOPROFILER 144 | 145 | #undef NODEFERWINDOWPOS 146 | #define NODEFERWINDOWPOS 147 | 148 | #undef NOMCX 149 | #define NOMCX 150 | 151 | #include 152 | #include 153 | #include 154 | #if defined (LOG4CPLUS_HAVE_INTRIN_H) 155 | #include 156 | #endif 157 | #endif 158 | 159 | // NOTE: This file is a fragment intentionally left without include guards. 160 | -------------------------------------------------------------------------------- /ThirdParty/log4cplus-1.2.1-rc2/include/log4cplus/consoleappender.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: consoleappender.h 4 | // Created: 6/2001 5 | // Author: Tad E. Smith 6 | // 7 | // 8 | // Copyright 2001-2015 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_CONSOLE_APPENDER_HEADER_ 25 | #define LOG4CPLUS_CONSOLE_APPENDER_HEADER_ 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | #include 34 | 35 | namespace log4cplus { 36 | /** 37 | * ConsoleAppender appends log events to std::cout or 38 | * std::cerr using a layout specified by the 39 | * user. The default target is std::cout. 40 | * 41 | *

Properties

42 | *
43 | *
logToStdErr
44 | *
When it is set true, the output stream will be 45 | * std::cerr instead of std::cout.
46 | * 47 | *
ImmediateFlush
48 | *
When it is set true, output stream will be flushed after 49 | * each appended event.
50 | * 51 | *
52 | * \sa Appender 53 | */ 54 | class LOG4CPLUS_EXPORT ConsoleAppender : public Appender { 55 | public: 56 | // Ctors 57 | ConsoleAppender(bool logToStdErr = false, bool immediateFlush = false); 58 | ConsoleAppender(const log4cplus::helpers::Properties & properties); 59 | 60 | // Dtor 61 | ~ConsoleAppender(); 62 | 63 | // Methods 64 | virtual void close(); 65 | 66 | //! This mutex is used by ConsoleAppender and helpers::LogLog 67 | //! classes to synchronize output to console. 68 | static log4cplus::thread::Mutex const & getOutputMutex(); 69 | 70 | protected: 71 | virtual void append(const spi::InternalLoggingEvent& event); 72 | 73 | // Data 74 | bool logToStdErr; 75 | /** 76 | * Immediate flush means that the underlying output stream 77 | * will be flushed at the end of each append operation. 78 | */ 79 | bool immediateFlush; 80 | }; 81 | 82 | } // end namespace log4cplus 83 | 84 | #endif // LOG4CPLUS_CONSOLE_APPENDER_HEADER_ 85 | 86 | -------------------------------------------------------------------------------- /ThirdParty/log4cplus-1.2.1-rc2/include/log4cplus/fstreams.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: fstreams.h 4 | // Created: 4/2003 5 | // Author: Tad E. Smith 6 | // 7 | // 8 | // Copyright 2003-2015 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_FSTREAMS_HEADER_ 25 | #define LOG4CPLUS_FSTREAMS_HEADER_ 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | #include 34 | #include 35 | 36 | 37 | namespace log4cplus 38 | { 39 | 40 | 41 | typedef std::basic_ofstream tofstream; 42 | typedef std::basic_ifstream tifstream; 43 | 44 | //! \def LOG4CPLUS_FSTREAM_PREFERED_FILE_NAME(X) 45 | //! \brief Expands into expression that picks the right type for 46 | //! std::fstream file name parameter. 47 | #if defined (LOG4CPLUS_FSTREAM_ACCEPTS_WCHAR_T) && defined (UNICODE) 48 | # define LOG4CPLUS_FSTREAM_PREFERED_FILE_NAME(X) (X) 49 | #else 50 | # define LOG4CPLUS_FSTREAM_PREFERED_FILE_NAME(X) (LOG4CPLUS_TSTRING_TO_STRING(X)) 51 | #endif 52 | 53 | 54 | } 55 | 56 | #endif // LOG4CPLUS_FSTREAMS_HEADER_ 57 | -------------------------------------------------------------------------------- /ThirdParty/log4cplus-1.2.1-rc2/include/log4cplus/helpers/appenderattachableimpl.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: appenderattachableimpl.h 4 | // Created: 6/2001 5 | // Author: Tad E. Smith 6 | // 7 | // 8 | // Copyright 2001-2015 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_HELPERS_APPENDER_ATTACHABLE_IMPL_HEADER_ 25 | #define LOG4CPLUS_HELPERS_APPENDER_ATTACHABLE_IMPL_HEADER_ 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | #include 39 | #include 40 | 41 | 42 | namespace log4cplus { 43 | namespace helpers { 44 | 45 | /** 46 | * This Interface is for attaching Appenders to objects. 47 | */ 48 | class LOG4CPLUS_EXPORT AppenderAttachableImpl 49 | : public log4cplus::spi::AppenderAttachable 50 | { 51 | public: 52 | // Data 53 | thread::Mutex appender_list_mutex; 54 | 55 | // Ctors 56 | AppenderAttachableImpl(); 57 | 58 | // Dtor 59 | virtual ~AppenderAttachableImpl(); 60 | 61 | // Methods 62 | /** 63 | * Add an appender. If the appender is already in the list in 64 | * won't be added again. 65 | */ 66 | virtual void addAppender(SharedAppenderPtr newAppender); 67 | 68 | /** 69 | * Get all previously added appenders as an vectory. 70 | */ 71 | virtual SharedAppenderPtrList getAllAppenders(); 72 | 73 | /** 74 | * Look for an attached appender named as name. 75 | * 76 | * Return the appender with that name if in the list. Return null 77 | * otherwise. 78 | */ 79 | virtual SharedAppenderPtr getAppender(const log4cplus::tstring& name); 80 | 81 | /** 82 | * Remove all previously added appenders. 83 | */ 84 | virtual void removeAllAppenders(); 85 | 86 | /** 87 | * Remove the appender passed as parameter from the list of appenders. 88 | */ 89 | virtual void removeAppender(SharedAppenderPtr appender); 90 | 91 | /** 92 | * Remove the appender with the name passed as parameter from the 93 | * list of appenders. 94 | */ 95 | virtual void removeAppender(const log4cplus::tstring& name); 96 | 97 | /** 98 | * Call the doAppend method on all attached appenders. 99 | */ 100 | int appendLoopOnAppenders(const spi::InternalLoggingEvent& event) const; 101 | 102 | protected: 103 | // Types 104 | typedef std::vector ListType; 105 | 106 | // Data 107 | /** Array of appenders. */ 108 | ListType appenderList; 109 | 110 | private: 111 | AppenderAttachableImpl(AppenderAttachableImpl const &); 112 | AppenderAttachableImpl & operator = (AppenderAttachableImpl const &); 113 | }; // end class AppenderAttachableImpl 114 | 115 | } // end namespace helpers 116 | } // end namespace log4cplus 117 | 118 | #endif // LOG4CPLUS_HELPERS_APPENDER_ATTACHABLE_IMPL_HEADER_ 119 | 120 | -------------------------------------------------------------------------------- /ThirdParty/log4cplus-1.2.1-rc2/include/log4cplus/helpers/connectorthread.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Copyright (C) 2013-2015, Vaclav Zeman. All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without modifica- 5 | // tion, are permitted provided that the following conditions are met: 6 | // 7 | // 1. Redistributions of source code must retain the above copyright notice, 8 | // this list of conditions and the following disclaimer. 9 | // 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 14 | // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 15 | // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 17 | // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 18 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- 19 | // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 20 | // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 21 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | 25 | #ifndef LOG4CPLUS_HELPERS_CONNECTORTHREAD_H 26 | #define LOG4CPLUS_HELPERS_CONNECTORTHREAD_H 27 | 28 | #include 29 | 30 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 31 | #pragma once 32 | #endif 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | 39 | #if ! defined (LOG4CPLUS_SINGLE_THREADED) 40 | 41 | namespace log4cplus { namespace helpers { 42 | 43 | 44 | class LOG4CPLUS_EXPORT ConnectorThread; 45 | 46 | //! Interface implemented by users of ConnectorThread. 47 | class LOG4CPLUS_EXPORT IConnectorThreadClient 48 | { 49 | protected: 50 | virtual ~IConnectorThreadClient (); 51 | 52 | //! \return Mutex for synchronization between ConnectorThread and 53 | //! its client object. This is usually SharedObject::access_mutex. 54 | virtual thread::Mutex const & ctcGetAccessMutex () const = 0; 55 | 56 | //! \return Socket variable in ConnectorThread client to maintain. 57 | virtual helpers::Socket & ctcGetSocket () = 0; 58 | 59 | //! \return ConnectorThread client's function returning connected 60 | //! socket. 61 | virtual helpers::Socket ctcConnect () = 0; 62 | 63 | //! Sets connected flag to true in ConnectorThread's client. 64 | virtual void ctcSetConnected () = 0; 65 | 66 | friend class LOG4CPLUS_EXPORT ConnectorThread; 67 | }; 68 | 69 | 70 | //! This class is used by SocketAppender and (remote) SysLogAppender 71 | //! to provide asynchronous re-connection. 72 | class LOG4CPLUS_EXPORT ConnectorThread 73 | : public thread::AbstractThread 74 | { 75 | public: 76 | //! \param client reference to ConnectorThread's client object 77 | ConnectorThread (IConnectorThreadClient & client); 78 | virtual ~ConnectorThread (); 79 | 80 | virtual void run(); 81 | 82 | //! Call this function to terminate ConnectorThread. The function 83 | //! sets `exit_flag` and then triggers `trigger_ev` to wake up the 84 | //! ConnectorThread. 85 | void terminate (); 86 | 87 | //! This function triggers (`trigger_ev`) connection check and 88 | //! attempt to re-connect a broken connection, when necessary. 89 | void trigger (); 90 | 91 | protected: 92 | //! reference to ConnectorThread's client 93 | IConnectorThreadClient & ctc; 94 | 95 | //! This event is the re-connection trigger. 96 | thread::ManualResetEvent trigger_ev; 97 | 98 | //! When this variable set to true when ConnectorThread is signaled to 99 | bool exit_flag; 100 | }; 101 | 102 | 103 | } } // namespace log4cplus { namespace helpers { 104 | 105 | #endif // ! defined (LOG4CPLUS_SINGLE_THREADED) 106 | 107 | #endif // LOG4CPLUS_HELPERS_CONNECTORTHREAD_H 108 | -------------------------------------------------------------------------------- /ThirdParty/log4cplus-1.2.1-rc2/include/log4cplus/helpers/fileinfo.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // 3 | // Copyright (C) 2012-2015, Vaclav Zeman. All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without modifica- 6 | // tion, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 11 | // 2. Redistributions in binary form must reproduce the above copyright notice, 12 | // this list of conditions and the following disclaimer in the documentation 13 | // and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 16 | // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 17 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 18 | // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 19 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- 20 | // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 21 | // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 22 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | #if ! defined (LOG4CPLUS_HELPERS_FILEINFO_H) 27 | #define LOG4CPLUS_HELPERS_FILEINFO_H 28 | 29 | #include 30 | 31 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 32 | #pragma once 33 | #endif 34 | 35 | #include 36 | #ifdef LOG4CPLUS_HAVE_SYS_TYPES_H 37 | #include 38 | #endif 39 | 40 | 41 | namespace log4cplus { namespace helpers { 42 | 43 | //! FileInfo structure is OS independent abstraction of the 44 | //! stat() function. 45 | struct LOG4CPLUS_EXPORT FileInfo 46 | { 47 | helpers::Time mtime; 48 | bool is_link; 49 | off_t size; 50 | }; 51 | 52 | 53 | //! OS independent abstraction of stat() function. 54 | LOG4CPLUS_EXPORT int getFileInfo (FileInfo * fi, tstring const & name); 55 | 56 | 57 | } } // namespace log4cplus { namespace helpers { 58 | 59 | #endif // LOG4CPLUS_HELPERS_FILEINFO_H 60 | -------------------------------------------------------------------------------- /ThirdParty/log4cplus-1.2.1-rc2/include/log4cplus/helpers/lockfile.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // 3 | // Copyright (C) 2012-2015, Vaclav Zeman. All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without modifica- 6 | // tion, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 11 | // 2. Redistributions in binary form must reproduce the above copyright notice, 12 | // this list of conditions and the following disclaimer in the documentation 13 | // and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 16 | // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 17 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 18 | // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 19 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- 20 | // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 21 | // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 22 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | #if ! defined (LOG4CPLUS_HELPERS_LOCKFILE_H) 27 | #define LOG4CPLUS_HELPERS_LOCKFILE_H 28 | 29 | #include 30 | 31 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 32 | #pragma once 33 | #endif 34 | 35 | #include 36 | #include 37 | 38 | 39 | namespace log4cplus { namespace helpers { 40 | 41 | 42 | class LOG4CPLUS_EXPORT LockFile 43 | { 44 | public: 45 | LockFile (tstring const & lock_file, bool create_dirs = false); 46 | ~LockFile (); 47 | 48 | void lock () const; 49 | void unlock () const; 50 | 51 | private: 52 | void open (int) const; 53 | void close () const; 54 | 55 | struct Impl; 56 | 57 | tstring lock_file_name; 58 | Impl * data; 59 | bool create_dirs; 60 | }; 61 | 62 | 63 | typedef log4cplus::thread::SyncGuard LockFileGuard; 64 | 65 | 66 | } } // namespace log4cplus { namespace helpers { 67 | 68 | 69 | #endif // LOG4CPLUS_HELPERS_LOCKFILE_H 70 | -------------------------------------------------------------------------------- /ThirdParty/log4cplus-1.2.1-rc2/include/log4cplus/helpers/logloguser.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: logloguser.h 4 | // Created: 6/2003 5 | // Author: Tad E. Smith 6 | // 7 | // 8 | // Copyright 2003-2015 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_HELPERS_LOGLOG_USER 25 | #define LOG4CPLUS_HELPERS_LOGLOG_USER 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | 34 | namespace log4cplus { 35 | namespace helpers { 36 | // forward declarations 37 | class LogLog; 38 | 39 | /** 40 | * This class used to simplify the use of the LogLog class. Any class 41 | * that uses the LogLog class should extend this class and retrieve 42 | * their reference to LogLog using the method provided. 43 | */ 44 | class LOG4CPLUS_EXPORT LogLogUser 45 | { 46 | public: 47 | // ctor and dtor 48 | LogLogUser(); 49 | LogLogUser(const LogLogUser&); 50 | virtual ~LogLogUser(); 51 | 52 | // public methods 53 | LogLog& getLogLog() const; 54 | 55 | // operators 56 | LogLogUser& operator=(const LogLogUser& rhs); 57 | }; 58 | 59 | } // end namespace helpers 60 | } // end namespace log4cplus 61 | 62 | 63 | #endif // LOG4CPLUS_HELPERS_LOGLOG_USER 64 | 65 | -------------------------------------------------------------------------------- /ThirdParty/log4cplus-1.2.1-rc2/include/log4cplus/helpers/sleep.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: sleep.h 4 | // Created: 5/2003 5 | // Author: Tad E. Smith 6 | // 7 | // 8 | // Copyright 2003-2015 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_HELPERS_SLEEP_HEADER_ 25 | #define LOG4CPLUS_HELPERS_SLEEP_HEADER_ 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | 34 | namespace log4cplus { 35 | namespace helpers { 36 | LOG4CPLUS_EXPORT void sleep(unsigned long secs, 37 | unsigned long nanosecs = 0); 38 | LOG4CPLUS_EXPORT void sleepmillis(unsigned long millis); 39 | } // end namespace helpers 40 | } // end namespace log4cplus 41 | 42 | #endif // LOG4CPLUS_HELPERS_SLEEP_HEADER_ 43 | 44 | -------------------------------------------------------------------------------- /ThirdParty/log4cplus-1.2.1-rc2/include/log4cplus/helpers/snprintf.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Copyright (C) 2010-2015, Vaclav Zeman. All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without modifica- 5 | // tion, are permitted provided that the following conditions are met: 6 | // 7 | // 1. Redistributions of source code must retain the above copyright notice, 8 | // this list of conditions and the following disclaimer. 9 | // 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 14 | // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 15 | // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 17 | // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 18 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- 19 | // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 20 | // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 21 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | 25 | #ifndef LOG4CPLUS_HELPERS_SNPRINTF_H 26 | #define LOG4CPLUS_HELPERS_SNPRINTF_H 27 | 28 | #include 29 | 30 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 31 | #pragma once 32 | #endif 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | 39 | namespace log4cplus { namespace helpers { 40 | 41 | 42 | class LOG4CPLUS_EXPORT snprintf_buf 43 | { 44 | public: 45 | snprintf_buf (); 46 | 47 | tchar const * print (tchar const * fmt, ...) 48 | LOG4CPLUS_FORMAT_ATTRIBUTE (__printf__, 2, 3); 49 | 50 | int print_va_list (tchar const * & str, tchar const * fmt, std::va_list) 51 | LOG4CPLUS_FORMAT_ATTRIBUTE (__printf__, 3, 0); 52 | 53 | private: 54 | std::vector buf; 55 | }; 56 | 57 | 58 | } } // namespace log4cplus { namespace helpers 59 | 60 | 61 | 62 | #endif // LOG4CPLUS_HELPERS_SNPRINTF_H 63 | -------------------------------------------------------------------------------- /ThirdParty/log4cplus-1.2.1-rc2/include/log4cplus/helpers/socket.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: socket.h 4 | // Created: 4/2003 5 | // Author: Tad E. Smith 6 | // 7 | // 8 | // Copyright 2003-2015 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_HELPERS_SOCKET_HEADER_ 25 | #define LOG4CPLUS_HELPERS_SOCKET_HEADER_ 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | #include 34 | #include 35 | 36 | 37 | namespace log4cplus { 38 | namespace helpers { 39 | 40 | enum SocketState { ok, 41 | not_opened, 42 | bad_address, 43 | connection_failed, 44 | broken_pipe, 45 | invalid_access_mode, 46 | message_truncated, 47 | accept_interrupted 48 | }; 49 | 50 | typedef std::ptrdiff_t SOCKET_TYPE; 51 | 52 | extern LOG4CPLUS_EXPORT SOCKET_TYPE const INVALID_SOCKET_VALUE; 53 | 54 | class LOG4CPLUS_EXPORT AbstractSocket { 55 | public: 56 | // ctor and dtor 57 | AbstractSocket(); 58 | AbstractSocket(SOCKET_TYPE sock, SocketState state, int err); 59 | AbstractSocket(const AbstractSocket&); 60 | virtual ~AbstractSocket() = 0; 61 | 62 | // methods 63 | /// Close socket 64 | virtual void close(); 65 | virtual bool isOpen() const; 66 | virtual void shutdown(); 67 | AbstractSocket& operator=(const AbstractSocket& rhs); 68 | 69 | protected: 70 | // Methods 71 | virtual void copy(const AbstractSocket& rhs); 72 | 73 | // Data 74 | SOCKET_TYPE sock; 75 | SocketState state; 76 | int err; 77 | }; 78 | 79 | 80 | 81 | /** 82 | * This class implements client sockets (also called just "sockets"). 83 | * A socket is an endpoint for communication between two machines. 84 | */ 85 | class LOG4CPLUS_EXPORT Socket : public AbstractSocket { 86 | public: 87 | // ctor and dtor 88 | Socket(); 89 | Socket(SOCKET_TYPE sock, SocketState state, int err); 90 | Socket(const tstring& address, unsigned short port, bool udp = false); 91 | virtual ~Socket(); 92 | 93 | // methods 94 | virtual bool read(SocketBuffer& buffer); 95 | virtual bool write(const SocketBuffer& buffer); 96 | virtual bool write(const std::string & buffer); 97 | }; 98 | 99 | 100 | 101 | /** 102 | * This class implements server sockets. A server socket waits for 103 | * requests to come in over the network. It performs some operation 104 | * based on that request, and then possibly returns a result to the 105 | * requester. 106 | */ 107 | class LOG4CPLUS_EXPORT ServerSocket : public AbstractSocket { 108 | public: 109 | // ctor and dtor 110 | ServerSocket(unsigned short port); 111 | virtual ~ServerSocket(); 112 | 113 | Socket accept(); 114 | void interruptAccept (); 115 | 116 | protected: 117 | std::ptrdiff_t interruptHandles[2]; 118 | }; 119 | 120 | 121 | LOG4CPLUS_EXPORT SOCKET_TYPE openSocket(unsigned short port, SocketState& state); 122 | LOG4CPLUS_EXPORT SOCKET_TYPE connectSocket(const log4cplus::tstring& hostn, 123 | unsigned short port, bool udp, 124 | SocketState& state); 125 | LOG4CPLUS_EXPORT SOCKET_TYPE acceptSocket(SOCKET_TYPE sock, SocketState& state); 126 | LOG4CPLUS_EXPORT int closeSocket(SOCKET_TYPE sock); 127 | LOG4CPLUS_EXPORT int shutdownSocket(SOCKET_TYPE sock); 128 | 129 | LOG4CPLUS_EXPORT long read(SOCKET_TYPE sock, SocketBuffer& buffer); 130 | LOG4CPLUS_EXPORT long write(SOCKET_TYPE sock, 131 | const SocketBuffer& buffer); 132 | LOG4CPLUS_EXPORT long write(SOCKET_TYPE sock, 133 | const std::string & buffer); 134 | 135 | LOG4CPLUS_EXPORT tstring getHostname (bool fqdn); 136 | LOG4CPLUS_EXPORT int setTCPNoDelay (SOCKET_TYPE, bool); 137 | 138 | } // end namespace helpers 139 | } // end namespace log4cplus 140 | 141 | #endif // LOG4CPLUS_HELPERS_SOCKET_HEADER_ 142 | -------------------------------------------------------------------------------- /ThirdParty/log4cplus-1.2.1-rc2/include/log4cplus/helpers/socketbuffer.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: socketbuffer.h 4 | // Created: 5/2003 5 | // Author: Tad E. Smith 6 | // 7 | // 8 | // Copyright 2003-2015 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_HELPERS_SOCKET_BUFFER_HEADER_ 25 | #define LOG4CPLUS_HELPERS_SOCKET_BUFFER_HEADER_ 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | #include 34 | 35 | 36 | namespace log4cplus { 37 | namespace helpers { 38 | 39 | /** 40 | * 41 | */ 42 | class LOG4CPLUS_EXPORT SocketBuffer 43 | { 44 | public: 45 | explicit SocketBuffer(std::size_t max); 46 | virtual ~SocketBuffer(); 47 | 48 | char *getBuffer() const { return buffer; } 49 | std::size_t getMaxSize() const { return maxsize; } 50 | std::size_t getSize() const { return size; } 51 | void setSize(std::size_t s) { size = s; } 52 | std::size_t getPos() const { return pos; } 53 | 54 | unsigned char readByte(); 55 | unsigned short readShort(); 56 | unsigned int readInt(); 57 | tstring readString(unsigned char sizeOfChar); 58 | 59 | void appendByte(unsigned char val); 60 | void appendShort(unsigned short val); 61 | void appendInt(unsigned int val); 62 | void appendString(const tstring& str); 63 | void appendBuffer(const SocketBuffer& buffer); 64 | 65 | private: 66 | // Data 67 | std::size_t maxsize; 68 | std::size_t size; 69 | std::size_t pos; 70 | char *buffer; 71 | 72 | SocketBuffer(SocketBuffer const & rhs); 73 | SocketBuffer& operator= (SocketBuffer const& rhs); 74 | }; 75 | 76 | } // end namespace helpers 77 | } // end namespace log4cplus 78 | 79 | #endif // LOG4CPLUS_HELPERS_SOCKET_HEADER_ 80 | -------------------------------------------------------------------------------- /ThirdParty/log4cplus-1.2.1-rc2/include/log4cplus/helpers/thread-config.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: thread-config.h 4 | // Created: 4/2003 5 | // Author: Tad E. Smith 6 | // 7 | // 8 | // Copyright 2003-2015 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | /** @file */ 22 | 23 | #ifndef LOG4CPLUS_HELPERS_THREAD_CONFIG_HEADER_ 24 | #define LOG4CPLUS_HELPERS_THREAD_CONFIG_HEADER_ 25 | 26 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 27 | #pragma once 28 | #endif 29 | 30 | #if defined (LOG4CPLUS_USE_PTHREADS) 31 | # if defined (__APPLE__) 32 | # define LOG4CPLUS_USE_NAMED_POSIX_SEMAPHORE 33 | # endif 34 | 35 | #elif defined(LOG4CPLUS_USE_WIN32_THREADS) 36 | # if defined (_WIN32_WINNT) && _WIN32_WINNT >= 0x0600 37 | # define LOG4CPLUS_USE_SRW_LOCK 38 | # else 39 | # define LOG4CPLUS_POOR_MANS_SHAREDMUTEX 40 | # endif 41 | # undef LOG4CPLUS_HAVE_TLS_SUPPORT 42 | # undef LOG4CPLUS_THREAD_LOCAL_VAR 43 | # if defined (_MSC_VER) && _WIN32_WINNT >= 0x0600 44 | // The __declspec(thread) functionality is not compatible with LoadLibrary(). 45 | // For more information why see and "Windows and TLS" note in README. 46 | // . 47 | # define LOG4CPLUS_HAVE_TLS_SUPPORT 1 48 | # define LOG4CPLUS_THREAD_LOCAL_VAR __declspec(thread) 49 | # endif 50 | 51 | #elif defined(LOG4CPLUS_SINGLE_THREADED) 52 | # undef LOG4CPLUS_HAVE_TLS_SUPPORT 53 | # undef LOG4CPLUS_THREAD_LOCAL_VAR 54 | 55 | #else 56 | # error "You Must define a Threading model" 57 | 58 | #endif 59 | 60 | 61 | #endif // LOG4CPLUS_HELPERS_THREAD_CONFIG_HEADER_ 62 | -------------------------------------------------------------------------------- /ThirdParty/log4cplus-1.2.1-rc2/include/log4cplus/hierarchylocker.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: hierarchylocker.h 4 | // Created: 8/2003 5 | // Author: Tad E. Smith 6 | // 7 | // 8 | // Copyright 2003-2015 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_HIERARCHY_LOCKER_HEADER_ 25 | #define LOG4CPLUS_HIERARCHY_LOCKER_HEADER_ 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | 38 | namespace log4cplus 39 | { 40 | 41 | class Hierarchy; 42 | 43 | 44 | /** 45 | * This is used to lock a Hierarchy. The dtor unlocks the Hierarchy. 46 | */ 47 | class LOG4CPLUS_EXPORT HierarchyLocker { 48 | public: 49 | // ctor & dtor 50 | HierarchyLocker(Hierarchy& h); 51 | ~HierarchyLocker() LOG4CPLUS_NOEXCEPT_FALSE; 52 | 53 | /** 54 | * Calls the resetConfiguration() method on the locked Hierarchy. 55 | */ 56 | void resetConfiguration(); 57 | 58 | /** 59 | * Calls the getInstance() method on the locked Hierarchy. 60 | */ 61 | Logger getInstance(const log4cplus::tstring& name); 62 | 63 | /** 64 | * Calls the getInstance() method on the locked Hierarchy. 65 | */ 66 | Logger getInstance(const log4cplus::tstring& name, spi::LoggerFactory& factory); 67 | 68 | void addAppender(Logger &logger, log4cplus::SharedAppenderPtr& appender); 69 | 70 | private: 71 | // Data 72 | Hierarchy& h; 73 | log4cplus::thread::MutexGuard hierarchyLocker; 74 | LoggerList loggerList; 75 | }; 76 | 77 | } // end namespace log4cplus 78 | 79 | #endif // LOG4CPLUS_HIERARCHY_LOCKER_HEADER_ 80 | -------------------------------------------------------------------------------- /ThirdParty/log4cplus-1.2.1-rc2/include/log4cplus/internal/cygwin-win32.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: cygwin-win32.h 4 | // Created: 7/2011 5 | // Author: Vaclav Zeman 6 | // 7 | // Copyright (C) 2011-2015, Vaclav Zeman. All rights reserved. 8 | // 9 | // Redistribution and use in source and binary forms, with or without modifica- 10 | // tion, are permitted provided that the following conditions are met: 11 | // 12 | // 1. Redistributions of source code must retain the above copyright notice, 13 | // this list of conditions and the following disclaimer. 14 | // 15 | // 2. Redistributions in binary form must reproduce the above copyright notice, 16 | // this list of conditions and the following disclaimer in the documentation 17 | // and/or other materials provided with the distribution. 18 | // 19 | // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 20 | // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 21 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 23 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- 24 | // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 25 | // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #if ! defined (LOG4CPLUS_CONFIG_CYGWIN_WIN32_H) 31 | #define LOG4CPLUS_CONFIG_CYGWIN_WIN32_H 32 | 33 | #include 34 | 35 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 36 | #pragma once 37 | #endif 38 | 39 | #if defined (__CYGWIN__) 40 | 41 | #if ! defined (INSIDE_LOG4CPLUS) 42 | # error "This header must not be be used outside log4cplus' implementation files." 43 | #endif 44 | 45 | 46 | namespace log4cplus { namespace cygwin { 47 | 48 | unsigned long get_current_win32_thread_id (); 49 | void output_debug_stringW (wchar_t const *); 50 | 51 | } } // namespace log4cplus { namespace cygwin { 52 | 53 | 54 | #endif // defined (__CYGWIN__) 55 | #endif // LOG4CPLUS_CONFIG_CYGWIN_WIN32_H 56 | -------------------------------------------------------------------------------- /ThirdParty/log4cplus-1.2.1-rc2/include/log4cplus/internal/env.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: env.h 4 | // Created: 7/2010 5 | // Author: Vaclav Haisman 6 | // 7 | // 8 | // Copyright (C) 2010-2015, Vaclav Haisman. All rights reserved. 9 | // 10 | // Redistribution and use in source and binary forms, with or without modifica- 11 | // tion, are permitted provided that the following conditions are met: 12 | // 13 | // 1. Redistributions of source code must retain the above copyright notice, 14 | // this list of conditions and the following disclaimer. 15 | // 16 | // 2. Redistributions in binary form must reproduce the above copyright notice, 17 | // this list of conditions and the following disclaimer in the documentation 18 | // and/or other materials provided with the distribution. 19 | // 20 | // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 21 | // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 22 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 23 | // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- 25 | // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 26 | // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 27 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | #ifndef LOG4CPLUS_INTERNAL_ENV_H 32 | #define LOG4CPLUS_INTERNAL_ENV_H 33 | 34 | #include 35 | 36 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 37 | #pragma once 38 | #endif 39 | 40 | #include 41 | #include 42 | 43 | #if defined (_WIN32) 44 | #include 45 | #endif 46 | #ifdef LOG4CPLUS_HAVE_SYS_TYPES_H 47 | #include 48 | #endif 49 | #ifdef LOG4CPLUS_HAVE_UNISTD_H 50 | #include 51 | #endif 52 | 53 | 54 | namespace log4cplus { namespace internal { 55 | 56 | 57 | //! Get environment variable value. 58 | bool get_env_var (tstring & value, tstring const & name); 59 | 60 | //! Parse a string as a boolean value. 61 | bool parse_bool (bool & val, tstring const & str); 62 | 63 | //! Parse a path into path components. 64 | bool split_path (std::vector & components, std::size_t & special, 65 | tstring const & path); 66 | 67 | //! Makes directories leading to file. 68 | void make_dirs (tstring const & file_path); 69 | 70 | inline 71 | #if defined (_WIN32) 72 | DWORD 73 | get_process_id () 74 | { 75 | return GetCurrentProcessId (); 76 | } 77 | 78 | #elif defined (LOG4CPLUS_HAVE_GETPID) 79 | pid_t 80 | get_process_id () 81 | { 82 | return getpid (); 83 | } 84 | 85 | #else 86 | int 87 | get_process_id () 88 | { 89 | return 0; 90 | } 91 | 92 | #endif 93 | 94 | 95 | } } // namespace log4cplus { namespace internal { 96 | 97 | 98 | #endif // LOG4CPLUS_INTERNAL_ENV_H 99 | -------------------------------------------------------------------------------- /ThirdParty/log4cplus-1.2.1-rc2/include/log4cplus/log4judpappender.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: LOG4CPLUS 3 | // File: log4judpappender.h 4 | // Created: 7/2012 5 | // Author: Siva Chandran P 6 | // 7 | // 8 | // Copyright 2012-2015 Siva Chandran P 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_LOG4J_UDP_APPENDER_HEADER_ 25 | #define LOG4CPLUS_LOG4J_UDP_APPENDER_HEADER_ 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | namespace log4cplus { 32 | 33 | /** 34 | * Sends log events as Log4j XML to a remote a log server. 35 | * 36 | * The Log4jUdpAppender has the following properties: 37 | * 38 | *
    39 | *
  • Remote logging is non-intrusive as far as the log event 40 | * is concerned. In other words, the event will be logged with 41 | * the same time stamp, NDC, location info as if it were logged 42 | * locally by the client.
  • 43 | * 44 | *
  • Remote logging uses the UDP protocol.
  • 45 | *
46 | * 47 | *

Properties

48 | *
49 | *
host
50 | *
Remote host name to connect and send events to.
51 | * 52 | *
port
53 | *
Port on remote host to send events to.
54 | * 55 | *
56 | */ 57 | class LOG4CPLUS_EXPORT Log4jUdpAppender : public Appender { 58 | public: 59 | // Ctors 60 | Log4jUdpAppender(const log4cplus::tstring& host, int port); 61 | Log4jUdpAppender(const log4cplus::helpers::Properties & properties); 62 | 63 | // Dtor 64 | ~Log4jUdpAppender(); 65 | 66 | // Methods 67 | virtual void close(); 68 | 69 | protected: 70 | void openSocket(); 71 | virtual void append(const spi::InternalLoggingEvent& event); 72 | 73 | // Data 74 | log4cplus::helpers::Socket socket; 75 | log4cplus::tstring host; 76 | int port; 77 | 78 | private: 79 | // Disallow copying of instances of this class 80 | Log4jUdpAppender(const Log4jUdpAppender&); 81 | Log4jUdpAppender& operator=(const Log4jUdpAppender&); 82 | }; 83 | } // end namespace log4cplus 84 | 85 | #endif // LOG4CPLUS_LOG4J_UDP_APPENDER_HEADER_ 86 | 87 | -------------------------------------------------------------------------------- /ThirdParty/log4cplus-1.2.1-rc2/include/log4cplus/mdc.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Copyright (C) 2010-2015, Vaclav Haisman. All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without modifica- 5 | // tion, are permitted provided that the following conditions are met: 6 | // 7 | // 1. Redistributions of source code must retain the above copyright notice, 8 | // this list of conditions and the following disclaimer. 9 | // 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 14 | // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 15 | // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 17 | // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 18 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- 19 | // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 20 | // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 21 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | 25 | #ifndef LOG4CPLUS_MDC_H_HEADER 26 | #define LOG4CPLUS_MDC_H_HEADER 27 | 28 | #include 29 | 30 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 31 | #pragma once 32 | #endif 33 | 34 | #include 35 | 36 | #include 37 | 38 | 39 | namespace log4cplus 40 | { 41 | 42 | 43 | typedef std::map MappedDiagnosticContextMap; 44 | 45 | 46 | class LOG4CPLUS_EXPORT MDC 47 | { 48 | public: 49 | /** 50 | * Clear any nested diagnostic information if any. This method is 51 | * useful in cases where the same thread can be potentially used 52 | * over and over in different unrelated contexts. 53 | */ 54 | void clear(); 55 | 56 | void put (tstring const & key, tstring const & value); 57 | bool get (tstring * value, tstring const & key) const; 58 | void remove (tstring const & key); 59 | 60 | MappedDiagnosticContextMap const & getContext () const; 61 | 62 | // Public ctor and dtor but only to be used by internal::DefaultContext. 63 | MDC (); 64 | virtual ~MDC (); 65 | 66 | private: 67 | LOG4CPLUS_PRIVATE static MappedDiagnosticContextMap * getPtr (); 68 | }; 69 | 70 | 71 | LOG4CPLUS_EXPORT MDC & getMDC (); 72 | 73 | 74 | } // namespace log4cplus 75 | 76 | 77 | #endif // LOG4CPLUS_MDC_H_HEADER 78 | -------------------------------------------------------------------------------- /ThirdParty/log4cplus-1.2.1-rc2/include/log4cplus/msttsappender.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4cplus 3 | // File: msttsappender.h 4 | // Created: 10/2012 5 | // Author: Vaclav Zeman 6 | // 7 | // 8 | // Copyright (C) 2012-2015, Vaclav Zeman. All rights reserved. 9 | // 10 | // Redistribution and use in source and binary forms, with or without modifica- 11 | // tion, are permitted provided that the following conditions are met: 12 | // 13 | // 1. Redistributions of source code must retain the above copyright notice, 14 | // this list of conditions and the following disclaimer. 15 | // 16 | // 2. Redistributions in binary form must reproduce the above copyright notice, 17 | // this list of conditions and the following disclaimer in the documentation 18 | // and/or other materials provided with the distribution. 19 | // 20 | // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 21 | // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 22 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 23 | // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- 25 | // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 26 | // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 27 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | 32 | // 33 | 34 | /** @file */ 35 | 36 | #ifndef LOG4CPLUS_MSTTSAPPENDER_H 37 | #define LOG4CPLUS_MSTTSAPPENDER_H 38 | 39 | #include 40 | 41 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 42 | #pragma once 43 | #endif 44 | 45 | #include 46 | 47 | 48 | #if defined (_WIN32) 49 | #if defined (log4cplusqt4debugappender_EXPORTS) \ 50 | || defined (log4cplusqt4debugappenderU_EXPORTS) \ 51 | || defined (DLL_EXPORT) 52 | #undef LOG4CPLUS_MSTTSAPPENDER_BUILD_DLL 53 | #define LOG4CPLUS_MSTTSAPPENDER_BUILD_DLL 54 | #endif 55 | #if defined (LOG4CPLUS_MSTTSAPPENDER_BUILD_DLL) 56 | #if defined (INSIDE_LOG4CPLUS_MSTTSAPPENDER) 57 | #define LOG4CPLUS_MSTTSAPPENDER_EXPORT __declspec(dllexport) 58 | #else 59 | #define LOG4CPLUS_MSTTSAPPENDER_EXPORT __declspec(dllimport) 60 | #endif 61 | #else 62 | #define LOG4CPLUS_MSTTSAPPENDER_EXPORT 63 | #endif 64 | #else 65 | #if defined (INSIDE_LOG4CPLUS_MSTTSAPPENDER) 66 | #define LOG4CPLUS_MSTTSAPPENDER_EXPORT LOG4CPLUS_DECLSPEC_EXPORT 67 | #else 68 | #define LOG4CPLUS_MSTTSAPPENDER_EXPORT LOG4CPLUS_DECLSPEC_IMPORT 69 | #endif // defined (INSIDE_LOG4CPLUS_MSTTSAPPENDER) 70 | #endif // !_WIN32 71 | 72 | 73 | namespace log4cplus 74 | { 75 | 76 | 77 | class LOG4CPLUS_MSTTSAPPENDER_EXPORT MSTTSAppender 78 | : public Appender 79 | { 80 | public: 81 | MSTTSAppender (); 82 | explicit MSTTSAppender (helpers::Properties const &); 83 | virtual ~MSTTSAppender (); 84 | 85 | virtual void close (); 86 | 87 | static void registerAppender (); 88 | 89 | protected: 90 | virtual void append (spi::InternalLoggingEvent const &); 91 | 92 | struct Data; 93 | 94 | Data * data; 95 | 96 | private: 97 | LOG4CPLUS_PRIVATE void init (long const * rate = 0, 98 | unsigned long const * volume = 0, bool speak_punc = false, 99 | bool async = false); 100 | 101 | MSTTSAppender (MSTTSAppender const &); 102 | MSTTSAppender & operator = (MSTTSAppender const &); 103 | }; 104 | 105 | 106 | typedef helpers::SharedObjectPtr MSTTSAppenderPtr; 107 | 108 | 109 | } // namespace log4cplus 110 | 111 | 112 | #endif // LOG4CPLUS_MSTTSAPPENDER_H 113 | -------------------------------------------------------------------------------- /ThirdParty/log4cplus-1.2.1-rc2/include/log4cplus/nteventlogappender.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: nteventlogappender.h 4 | // Created: 4/2003 5 | // Author: Michael CATANZARITI 6 | // 7 | // Copyright 2003-2015 Michael CATANZARITI 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | 21 | /** @file */ 22 | 23 | #ifndef LOG4CPLUS_NT_EVENT_LOG_APPENDER_HEADER_ 24 | #define LOG4CPLUS_NT_EVENT_LOG_APPENDER_HEADER_ 25 | 26 | #include 27 | 28 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 29 | #pragma once 30 | #endif 31 | 32 | #if defined (LOG4CPLUS_HAVE_NT_EVENT_LOG) 33 | 34 | #include 35 | #include 36 | 37 | 38 | namespace log4cplus { 39 | 40 | /** 41 | * Appends log events to NT EventLog. 42 | */ 43 | class LOG4CPLUS_EXPORT NTEventLogAppender : public Appender { 44 | public: 45 | // ctors 46 | NTEventLogAppender(const log4cplus::tstring& server, 47 | const log4cplus::tstring& log, 48 | const log4cplus::tstring& source); 49 | NTEventLogAppender(const log4cplus::helpers::Properties & properties); 50 | 51 | // dtor 52 | virtual ~NTEventLogAppender(); 53 | 54 | // public Methods 55 | virtual void close(); 56 | 57 | protected: 58 | virtual void append(const spi::InternalLoggingEvent& event); 59 | virtual WORD getEventType(const spi::InternalLoggingEvent& event); 60 | virtual WORD getEventCategory(const spi::InternalLoggingEvent& event); 61 | void init(); 62 | 63 | /* 64 | * Add this source with appropriate configuration keys to the registry. 65 | */ 66 | void addRegistryInfo(); 67 | 68 | // Data 69 | log4cplus::tstring server; 70 | log4cplus::tstring log; 71 | log4cplus::tstring source; 72 | HANDLE hEventLog; 73 | SID* pCurrentUserSID; 74 | 75 | private: 76 | // Disallow copying of instances of this class 77 | NTEventLogAppender(const NTEventLogAppender&); 78 | NTEventLogAppender& operator=(const NTEventLogAppender&); 79 | }; 80 | 81 | } // end namespace log4cplus 82 | 83 | #endif // LOG4CPLUS_HAVE_NT_EVENT_LOG 84 | #endif //LOG4CPLUS_NT_EVENT_LOG_APPENDER_HEADER_ 85 | -------------------------------------------------------------------------------- /ThirdParty/log4cplus-1.2.1-rc2/include/log4cplus/nullappender.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: nullappender.h 4 | // Created: 6/2003 5 | // Author: Tad E. Smith 6 | // 7 | // 8 | // Copyright 2003-2015 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_NULL_APPENDER_HEADER_ 25 | #define LOG4CPLUS_NULL_APPENDER_HEADER_ 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | #include 34 | 35 | 36 | namespace log4cplus { 37 | 38 | /** 39 | * Appends log events to a file. 40 | */ 41 | class LOG4CPLUS_EXPORT NullAppender : public Appender { 42 | public: 43 | // Ctors 44 | NullAppender(); 45 | NullAppender(const log4cplus::helpers::Properties&); 46 | 47 | // Dtor 48 | virtual ~NullAppender(); 49 | 50 | // Methods 51 | virtual void close(); 52 | 53 | protected: 54 | virtual void append(const log4cplus::spi::InternalLoggingEvent& event); 55 | 56 | private: 57 | // Disallow copying of instances of this class 58 | NullAppender(const NullAppender&); 59 | NullAppender& operator=(const NullAppender&); 60 | }; 61 | 62 | } // end namespace log4cplus 63 | 64 | #endif // LOG4CPLUS_NULL_APPENDER_HEADER_ 65 | 66 | -------------------------------------------------------------------------------- /ThirdParty/log4cplus-1.2.1-rc2/include/log4cplus/qt4debugappender.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4cplus 3 | // File: qt4debugappender.h 4 | // Created: 5/2012 5 | // Author: Vaclav Zeman 6 | // 7 | // 8 | // Copyright (C) 2012-2015, Vaclav Zeman. All rights reserved. 9 | // 10 | // Redistribution and use in source and binary forms, with or without modifica- 11 | // tion, are permitted provided that the following conditions are met: 12 | // 13 | // 1. Redistributions of source code must retain the above copyright notice, 14 | // this list of conditions and the following disclaimer. 15 | // 16 | // 2. Redistributions in binary form must reproduce the above copyright notice, 17 | // this list of conditions and the following disclaimer in the documentation 18 | // and/or other materials provided with the distribution. 19 | // 20 | // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 21 | // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 22 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 23 | // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- 25 | // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 26 | // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 27 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | 32 | // 33 | 34 | /** @file */ 35 | 36 | #ifndef LOG4CPLUS_QT4DEBUGAPPENDER_H 37 | #define LOG4CPLUS_QT4DEBUGAPPENDER_H 38 | 39 | #include 40 | 41 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 42 | #pragma once 43 | #endif 44 | 45 | #include 46 | 47 | #if defined (_WIN32) 48 | #if defined (log4cplusqt4debugappender_EXPORTS) \ 49 | || defined (log4cplusqt4debugappenderU_EXPORTS) \ 50 | || defined (DLL_EXPORT) 51 | #undef LOG4CPLUS_QT4DEBUGAPPENDER_BUILD_DLL 52 | #define LOG4CPLUS_QT4DEBUGAPPENDER_BUILD_DLL 53 | #endif 54 | #if defined (LOG4CPLUS_QT4DEBUGAPPENDER_BUILD_DLL) 55 | #if defined (INSIDE_LOG4CPLUS_QT4DEBUGAPPENDER) 56 | #define LOG4CPLUS_QT4DEBUGAPPENDER_EXPORT __declspec(dllexport) 57 | #else 58 | #define LOG4CPLUS_QT4DEBUGAPPENDER_EXPORT __declspec(dllimport) 59 | #endif 60 | #else 61 | #define LOG4CPLUS_QT4DEBUGAPPENDER_EXPORT 62 | #endif 63 | #else 64 | #if defined (INSIDE_LOG4CPLUS_QT4DEBUGAPPENDER) 65 | #define LOG4CPLUS_QT4DEBUGAPPENDER_EXPORT LOG4CPLUS_DECLSPEC_EXPORT 66 | #else 67 | #define LOG4CPLUS_QT4DEBUGAPPENDER_EXPORT LOG4CPLUS_DECLSPEC_IMPORT 68 | #endif // defined (INSIDE_LOG4CPLUS_QT4DEBUGAPPENDER) 69 | #endif // !_WIN32 70 | 71 | 72 | namespace log4cplus 73 | { 74 | 75 | 76 | class LOG4CPLUS_QT4DEBUGAPPENDER_EXPORT Qt4DebugAppender 77 | : public Appender 78 | { 79 | public: 80 | Qt4DebugAppender (); 81 | explicit Qt4DebugAppender (helpers::Properties const &); 82 | virtual ~Qt4DebugAppender (); 83 | 84 | virtual void close (); 85 | 86 | static void registerAppender (); 87 | 88 | protected: 89 | virtual void append (spi::InternalLoggingEvent const &); 90 | 91 | private: 92 | Qt4DebugAppender (Qt4DebugAppender const &); 93 | Qt4DebugAppender & operator = (Qt4DebugAppender const &); 94 | }; 95 | 96 | 97 | typedef helpers::SharedObjectPtr Qt4DebugAppenderPtr; 98 | 99 | 100 | } // namespace log4cplus 101 | 102 | 103 | #endif // LOG4CPLUS_QT4DEBUGAPPENDER_H 104 | -------------------------------------------------------------------------------- /ThirdParty/log4cplus-1.2.1-rc2/include/log4cplus/qt5debugappender.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4cplus 3 | // File: qt5debugappender.h 4 | // Created: 4/2013 5 | // Author: Vaclav Zeman 6 | // 7 | // 8 | // Copyright (C) 2013-2015, Vaclav Zeman. All rights reserved. 9 | // 10 | // Redistribution and use in source and binary forms, with or without modifica- 11 | // tion, are permitted provided that the following conditions are met: 12 | // 13 | // 1. Redistributions of source code must retain the above copyright notice, 14 | // this list of conditions and the following disclaimer. 15 | // 16 | // 2. Redistributions in binary form must reproduce the above copyright notice, 17 | // this list of conditions and the following disclaimer in the documentation 18 | // and/or other materials provided with the distribution. 19 | // 20 | // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 21 | // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 22 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 23 | // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- 25 | // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 26 | // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 27 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | 32 | // 33 | 34 | /** @file */ 35 | 36 | #ifndef LOG4CPLUS_QT5DEBUGAPPENDER_H 37 | #define LOG4CPLUS_QT5DEBUGAPPENDER_H 38 | 39 | #include 40 | 41 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 42 | #pragma once 43 | #endif 44 | 45 | #include 46 | 47 | #if defined (_WIN32) 48 | #if defined (log4cplusqt5debugappender_EXPORTS) \ 49 | || defined (log4cplusqt5debugappenderU_EXPORTS) \ 50 | || defined (DLL_EXPORT) 51 | #undef LOG4CPLUS_QT5DEBUGAPPENDER_BUILD_DLL 52 | #define LOG4CPLUS_QT5DEBUGAPPENDER_BUILD_DLL 53 | #endif 54 | #if defined (LOG4CPLUS_QT5DEBUGAPPENDER_BUILD_DLL) 55 | #if defined (INSIDE_LOG4CPLUS_QT5DEBUGAPPENDER) 56 | #define LOG4CPLUS_QT5DEBUGAPPENDER_EXPORT __declspec(dllexport) 57 | #else 58 | #define LOG4CPLUS_QT5DEBUGAPPENDER_EXPORT __declspec(dllimport) 59 | #endif 60 | #else 61 | #define LOG4CPLUS_QT5DEBUGAPPENDER_EXPORT 62 | #endif 63 | #else 64 | #if defined (INSIDE_LOG4CPLUS_QT5DEBUGAPPENDER) 65 | #define LOG4CPLUS_QT5DEBUGAPPENDER_EXPORT LOG4CPLUS_DECLSPEC_EXPORT 66 | #else 67 | #define LOG4CPLUS_QT5DEBUGAPPENDER_EXPORT LOG4CPLUS_DECLSPEC_IMPORT 68 | #endif // defined (INSIDE_LOG4CPLUS_QT5DEBUGAPPENDER) 69 | #endif // !_WIN32 70 | 71 | 72 | namespace log4cplus 73 | { 74 | 75 | 76 | class LOG4CPLUS_QT5DEBUGAPPENDER_EXPORT Qt5DebugAppender 77 | : public Appender 78 | { 79 | public: 80 | Qt5DebugAppender (); 81 | explicit Qt5DebugAppender (helpers::Properties const &); 82 | virtual ~Qt5DebugAppender (); 83 | 84 | virtual void close (); 85 | 86 | static void registerAppender (); 87 | 88 | protected: 89 | virtual void append (spi::InternalLoggingEvent const &); 90 | 91 | private: 92 | Qt5DebugAppender (Qt5DebugAppender const &); 93 | Qt5DebugAppender & operator = (Qt5DebugAppender const &); 94 | }; 95 | 96 | 97 | typedef helpers::SharedObjectPtr Qt5DebugAppenderPtr; 98 | 99 | 100 | } // namespace log4cplus 101 | 102 | 103 | #endif // LOG4CPLUS_QT5DEBUGAPPENDER_H 104 | -------------------------------------------------------------------------------- /ThirdParty/log4cplus-1.2.1-rc2/include/log4cplus/spi/appenderattachable.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: appenderattachable.h 4 | // Created: 6/2001 5 | // Author: Tad E. Smith 6 | // 7 | // 8 | // Copyright 2001-2015 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_SPI_APPENDER_ATTACHABLE_HEADER_ 25 | #define LOG4CPLUS_SPI_APPENDER_ATTACHABLE_HEADER_ 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | namespace log4cplus { 39 | // Forward Declarations 40 | typedef helpers::SharedObjectPtr SharedAppenderPtr; 41 | typedef std::vector SharedAppenderPtrList; 42 | 43 | namespace spi { 44 | 45 | /** 46 | * This Interface is for attaching Appenders to objects. 47 | */ 48 | class LOG4CPLUS_EXPORT AppenderAttachable { 49 | public: 50 | // Methods 51 | /** 52 | * Add an appender. 53 | */ 54 | virtual void addAppender(SharedAppenderPtr newAppender) = 0; 55 | 56 | /** 57 | * Get all previously added appenders as an Enumeration. 58 | */ 59 | virtual SharedAppenderPtrList getAllAppenders() = 0; 60 | 61 | /** 62 | * Get an appender by name. 63 | */ 64 | virtual SharedAppenderPtr getAppender(const log4cplus::tstring& name) = 0; 65 | 66 | /** 67 | * Remove all previously added appenders. 68 | */ 69 | virtual void removeAllAppenders() = 0; 70 | 71 | /** 72 | * Remove the appender passed as parameter from the list of appenders. 73 | */ 74 | virtual void removeAppender(SharedAppenderPtr appender) = 0; 75 | 76 | /** 77 | * Remove the appender with the name passed as parameter from the 78 | * list of appenders. 79 | */ 80 | virtual void removeAppender(const log4cplus::tstring& name) = 0; 81 | 82 | // Dtor 83 | virtual ~AppenderAttachable() = 0; 84 | }; 85 | 86 | } // end namespace spi 87 | } // end namespace log4cplus 88 | 89 | #endif // LOG4CPLUS_SPI_APPENDER_ATTACHABLE_HEADER_ 90 | 91 | -------------------------------------------------------------------------------- /ThirdParty/log4cplus-1.2.1-rc2/include/log4cplus/spi/loggerfactory.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: loggerfactory.h 4 | // Created: 6/2001 5 | // Author: Tad E. Smith 6 | // 7 | // 8 | // Copyright 2001-2015 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_SPI_LOGGER_FACTORY_HEADER 25 | #define LOG4CPLUS_SPI_LOGGER_FACTORY_HEADER 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | #include 34 | 35 | 36 | namespace log4cplus { 37 | // Forward Declarations 38 | class Logger; 39 | class Hierarchy; 40 | 41 | namespace spi { 42 | /** 43 | * Implement this interface to create new instances of Logger or 44 | * a sub-class of Logger. 45 | */ 46 | class LOG4CPLUS_EXPORT LoggerFactory { 47 | public: 48 | /** 49 | * Creates a new Logger object. 50 | */ 51 | virtual Logger makeNewLoggerInstance(const log4cplus::tstring& name, 52 | Hierarchy& h) = 0; 53 | virtual ~LoggerFactory() = 0; 54 | }; 55 | 56 | } // end namespace spi 57 | } // end namespace log4cplus 58 | 59 | #endif // LOG4CPLUS_SPI_LOGGER_FACTORY_HEADER 60 | 61 | -------------------------------------------------------------------------------- /ThirdParty/log4cplus-1.2.1-rc2/include/log4cplus/spi/objectregistry.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: objectregistry.h 4 | // Created: 3/2003 5 | // Author: Tad E. Smith 6 | // 7 | // 8 | // Copyright 2003-2015 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_SPI_OBJECT_REGISTRY_HEADER_ 25 | #define LOG4CPLUS_SPI_OBJECT_REGISTRY_HEADER_ 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | 40 | namespace log4cplus { 41 | namespace spi { 42 | 43 | /** 44 | * This is the base class used to implement the functionality required 45 | * by the ObjectRegistry template class. 46 | */ 47 | class LOG4CPLUS_EXPORT ObjectRegistryBase { 48 | public: 49 | // public methods 50 | /** 51 | * Tests to see whether or not an object is bound in the 52 | * registry as name. 53 | */ 54 | bool exists(const log4cplus::tstring& name) const; 55 | 56 | /** 57 | * Returns the names of all registered objects. 58 | */ 59 | std::vector getAllNames() const; 60 | 61 | //! This function is internal implementation detail. 62 | //! It is related to work-around needed for initialization when 63 | //! using C++11 threads and mutexes. 64 | void _enableLocking (bool); 65 | 66 | protected: 67 | // Ctor and Dtor 68 | ObjectRegistryBase(); 69 | virtual ~ObjectRegistryBase(); 70 | 71 | // protected methods 72 | /** 73 | * Used to enter an object into the registry. (The registry now 74 | * owns object.) 75 | */ 76 | bool putVal(const log4cplus::tstring& name, void* object); 77 | 78 | /** 79 | * Used to retrieve an object from the registry. (The registry 80 | * owns the returned pointer.) 81 | */ 82 | void* getVal(const log4cplus::tstring& name) const; 83 | 84 | /** 85 | * Deletes object. 86 | */ 87 | virtual void deleteObject(void *object) const = 0; 88 | 89 | /** 90 | * Deletes all objects from this registry. 91 | */ 92 | virtual void clear(); 93 | 94 | // Types 95 | typedef std::map ObjectMap; 96 | 97 | // Data 98 | thread::Mutex mutex; 99 | ObjectMap data; 100 | 101 | private: 102 | ObjectRegistryBase (ObjectRegistryBase const &); 103 | ObjectRegistryBase & operator = (ObjectRegistryBase const &); 104 | 105 | bool volatile locking; 106 | }; 107 | 108 | } 109 | } 110 | 111 | 112 | #endif // LOG4CPLUS_SPI_OBJECT_REGISTRY_HEADER_ 113 | 114 | -------------------------------------------------------------------------------- /ThirdParty/log4cplus-1.2.1-rc2/include/log4cplus/spi/rootlogger.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: rootlogger.h 4 | // Created: 6/2001 5 | // Author: Tad E. Smith 6 | // 7 | // 8 | // Copyright 2001-2015 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_SPI_ROOT_LOGGER_HEADER_ 25 | #define LOG4CPLUS_SPI_ROOT_LOGGER_HEADER_ 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | #include 34 | 35 | namespace log4cplus { 36 | namespace spi { 37 | 38 | /** 39 | * RootLogger sits at the top of the logger hierachy. It is a 40 | * regular logger except that it provides several guarantees. 41 | * 42 | * First, it cannot be assigned a NOT_SET_LOG_LEVEL 43 | * LogLevel. Second, since root logger cannot have a parent, the 44 | * getChainedLogLevel method always returns the value of the 45 | * ll field without walking the hierarchy. 46 | */ 47 | class LOG4CPLUS_EXPORT RootLogger : public LoggerImpl { 48 | public: 49 | // Ctors 50 | /** 51 | * The root logger names itself as "root". However, the root 52 | * logger cannot be retrieved by name. 53 | */ 54 | RootLogger(Hierarchy& h, LogLevel ll); 55 | 56 | // Methods 57 | /** 58 | * Return the assigned LogLevel value without walking the logger 59 | * hierarchy. 60 | */ 61 | virtual LogLevel getChainedLogLevel() const; 62 | 63 | /** 64 | * Setting a NOT_SET_LOG_LEVEL value to the LogLevel of the root logger 65 | * may have catastrophic results. We prevent this here. 66 | */ 67 | void setLogLevel(LogLevel ll); 68 | 69 | }; 70 | 71 | } // end namespace spi 72 | } // end namespace log4cplus 73 | 74 | #endif // LOG4CPLUS_SPI_ROOT_LOGGER_HEADER_ 75 | 76 | -------------------------------------------------------------------------------- /ThirdParty/log4cplus-1.2.1-rc2/include/log4cplus/streams.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: streams.h 4 | // Created: 4/2003 5 | // Author: Tad E. Smith 6 | // 7 | // 8 | // Copyright 2003-2015 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_STREAMS_HEADER_ 25 | #define LOG4CPLUS_STREAMS_HEADER_ 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | #include 34 | 35 | #include 36 | 37 | 38 | namespace log4cplus 39 | { 40 | typedef std::basic_ostream tostream; 41 | typedef std::basic_istream tistream; 42 | typedef std::basic_ostringstream tostringstream; 43 | typedef std::basic_istringstream tistringstream; 44 | extern LOG4CPLUS_EXPORT tostream & tcout; 45 | extern LOG4CPLUS_EXPORT tostream & tcerr; 46 | } 47 | 48 | #if defined (UNICODE) && defined (LOG4CPLUS_ENABLE_GLOBAL_C_STRING_STREAM_INSERTER) 49 | 50 | LOG4CPLUS_EXPORT log4cplus::tostream& operator <<(log4cplus::tostream&, const char* psz ); 51 | 52 | #endif 53 | 54 | #endif // LOG4CPLUS_STREAMS_HEADER_ 55 | 56 | -------------------------------------------------------------------------------- /ThirdParty/log4cplus-1.2.1-rc2/include/log4cplus/tchar.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Copyright (C) 2010-2015, Vaclav Haisman. All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without modifica- 5 | // tion, are permitted provided that the following conditions are met: 6 | // 7 | // 1. Redistributions of source code must retain the above copyright notice, 8 | // this list of conditions and the following disclaimer. 9 | // 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 14 | // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 15 | // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 17 | // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 18 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- 19 | // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 20 | // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 21 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | 25 | /** @file */ 26 | 27 | #ifndef LOG4CPLUS_TCHAR_HEADER_ 28 | #define LOG4CPLUS_TCHAR_HEADER_ 29 | 30 | #include 31 | 32 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 33 | #pragma once 34 | #endif 35 | 36 | #if defined (_WIN32) 37 | #include 38 | #endif 39 | 40 | 41 | #ifdef UNICODE 42 | # define LOG4CPLUS_TEXT2(STRING) L##STRING 43 | #else 44 | # define LOG4CPLUS_TEXT2(STRING) STRING 45 | #endif // UNICODE 46 | #define LOG4CPLUS_TEXT(STRING) LOG4CPLUS_TEXT2(STRING) 47 | 48 | 49 | namespace log4cplus 50 | { 51 | 52 | #if defined (UNICODE) 53 | typedef wchar_t tchar; 54 | 55 | #else 56 | typedef char tchar; 57 | 58 | #endif 59 | 60 | } // namespace log4cplus 61 | 62 | 63 | #endif // LOG4CPLUS_TCHAR_HEADER_ 64 | -------------------------------------------------------------------------------- /ThirdParty/log4cplus-1.2.1-rc2/include/log4cplus/thread/impl/syncprims-pmsm.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Copyright (C) 2010-2015, Vaclav Haisman. All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without modifica- 5 | // tion, are permitted provided that the following conditions are met: 6 | // 7 | // 1. Redistributions of source code must retain the above copyright notice, 8 | // this list of conditions and the following disclaimer. 9 | // 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 14 | // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 15 | // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 17 | // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 18 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- 19 | // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 20 | // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 21 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | 25 | //! @file 26 | //! This file contains implementations of reader-writer locking 27 | //! primitive using other primitives, IOW poor man's rwlock. 28 | //! It does not contain any include guards because it is only a fragment 29 | //! to be included by syncprims-{pthreads,win32}.h. 30 | 31 | 32 | #if ! defined (INSIDE_LOG4CPLUS) 33 | # error "This header must not be be used outside log4cplus' implementation files." 34 | #endif 35 | 36 | 37 | // This implements algorithm described in "Concurrent Control with "Readers" 38 | // and "Writers"; P.J. Courtois, F. Heymans, and D.L. Parnas; 39 | // MBLE Research Laboratory; Brussels, Belgium" 40 | 41 | 42 | inline 43 | SharedMutex::SharedMutex () 44 | : m1 (log4cplus::thread::Mutex::DEFAULT) 45 | , m2 (log4cplus::thread::Mutex::DEFAULT) 46 | , m3 (log4cplus::thread::Mutex::DEFAULT) 47 | , w (1, 1) 48 | , writer_count (0) 49 | , r (1, 1) 50 | , reader_count (0) 51 | { } 52 | 53 | 54 | inline 55 | SharedMutex::~SharedMutex () 56 | { } 57 | 58 | 59 | inline 60 | void 61 | SharedMutex::rdlock () const 62 | { 63 | MutexGuard m3_guard (m3); 64 | SemaphoreGuard r_guard (r); 65 | MutexGuard m1_guard (m1); 66 | if (reader_count + 1 == 1) 67 | w.lock (); 68 | 69 | reader_count += 1; 70 | } 71 | 72 | 73 | inline 74 | void 75 | SharedMutex::rdunlock () const 76 | { 77 | MutexGuard m1_guard (m1); 78 | if (reader_count - 1 == 0) 79 | w.unlock (); 80 | 81 | reader_count -= 1; 82 | } 83 | 84 | 85 | inline 86 | void 87 | SharedMutex::wrlock () const 88 | { 89 | { 90 | MutexGuard m2_guard (m2); 91 | if (writer_count + 1 == 1) 92 | r.lock (); 93 | 94 | writer_count += 1; 95 | } 96 | try 97 | { 98 | w.lock (); 99 | } 100 | catch (...) 101 | { 102 | MutexGuard m2_guard (m2); 103 | writer_count -= 1; 104 | throw; 105 | } 106 | } 107 | 108 | 109 | inline 110 | void 111 | SharedMutex::wrunlock () const 112 | { 113 | w.unlock (); 114 | MutexGuard m2_guard (m2); 115 | if (writer_count - 1 == 0) 116 | r.unlock (); 117 | 118 | writer_count -= 1; 119 | } 120 | -------------------------------------------------------------------------------- /ThirdParty/log4cplus-1.2.1-rc2/include/log4cplus/thread/impl/threads-impl.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: threads.h 4 | // Created: 6/2001 5 | // Author: Tad E. Smith 6 | // 7 | // 8 | // Copyright 2001-2015 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_IMPL_THREADS_IMPL_HEADER_ 25 | #define LOG4CPLUS_IMPL_THREADS_IMPL_HEADER_ 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | #if defined (_WIN32) 34 | #include 35 | #endif 36 | #include 37 | #include 38 | #include 39 | 40 | #if ! defined (INSIDE_LOG4CPLUS) 41 | # error "This header must not be be used outside log4cplus' implementation files." 42 | #endif 43 | 44 | 45 | namespace log4cplus { namespace thread { namespace impl { 46 | 47 | 48 | #if defined (LOG4CPLUS_USE_PTHREADS) 49 | 50 | typedef pthread_t os_handle_type; 51 | typedef pthread_t os_id_type; 52 | 53 | 54 | inline 55 | pthread_t 56 | getCurrentThreadId () 57 | { 58 | return pthread_self (); 59 | } 60 | 61 | 62 | #elif defined (LOG4CPLUS_USE_WIN32_THREADS) 63 | 64 | typedef HANDLE os_handle_type; 65 | typedef DWORD os_id_type; 66 | 67 | 68 | inline 69 | DWORD 70 | getCurrentThreadId () 71 | { 72 | return GetCurrentThreadId (); 73 | } 74 | 75 | 76 | #elif defined (LOG4CPLUS_SINGLE_THREADED) 77 | 78 | typedef void * os_handle_type; 79 | typedef int os_id_type; 80 | 81 | 82 | inline 83 | int 84 | getCurrentThreadId () 85 | { 86 | return 1; 87 | } 88 | 89 | 90 | #endif 91 | 92 | 93 | #ifndef LOG4CPLUS_SINGLE_THREADED 94 | 95 | 96 | struct ThreadStart 97 | { 98 | # ifdef LOG4CPLUS_USE_PTHREADS 99 | static void* threadStartFuncWorker(void *); 100 | # elif defined(LOG4CPLUS_USE_WIN32_THREADS) 101 | static unsigned threadStartFuncWorker(void *); 102 | # endif 103 | }; 104 | 105 | 106 | /** 107 | * There are many cross-platform C++ Threading libraries. The goal of 108 | * this class is not to replace (or match in functionality) those 109 | * libraries. The goal of this class is to provide a simple Threading 110 | * class with basic functionality. 111 | */ 112 | class Thread 113 | : public ThreadImplBase 114 | { 115 | public: 116 | Thread(); 117 | bool isRunning() const; 118 | os_id_type getThreadId() const; 119 | os_handle_type getThreadHandle () const; 120 | void start(); 121 | void join (); 122 | 123 | protected: 124 | // Force objects to be constructed on the heap 125 | virtual ~Thread(); 126 | virtual void run() = 0; 127 | 128 | private: 129 | // Friends. 130 | friend struct ThreadStart; 131 | 132 | enum Flags 133 | { 134 | fRUNNING = 0x01, 135 | fJOINED = 0x02 136 | }; 137 | 138 | unsigned flags; 139 | 140 | os_handle_type handle; 141 | 142 | # if defined(LOG4CPLUS_USE_WIN32_THREADS) 143 | unsigned thread_id; 144 | # endif 145 | 146 | // Disallow copying of instances of this class. 147 | Thread(const Thread&); 148 | Thread& operator=(const Thread&); 149 | }; 150 | 151 | typedef helpers::SharedObjectPtr ThreadPtr; 152 | 153 | 154 | #endif // LOG4CPLUS_SINGLE_THREADED 155 | 156 | 157 | } } } // namespace log4cplus { namespace thread { namespace impl { 158 | 159 | 160 | #endif // LOG4CPLUS_IMPL_THREADS_IMPL_HEADER_ 161 | -------------------------------------------------------------------------------- /ThirdParty/log4cplus-1.2.1-rc2/include/log4cplus/thread/threads.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: threads.h 4 | // Created: 6/2001 5 | // Author: Tad E. Smith 6 | // 7 | // 8 | // Copyright 2001-2015 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_THREADS_HEADER_ 25 | #define LOG4CPLUS_THREADS_HEADER_ 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | #include 34 | #include 35 | 36 | 37 | namespace log4cplus { namespace thread { 38 | 39 | 40 | LOG4CPLUS_EXPORT log4cplus::tstring const & getCurrentThreadName(); 41 | LOG4CPLUS_EXPORT log4cplus::tstring const & getCurrentThreadName2(); 42 | LOG4CPLUS_EXPORT void setCurrentThreadName(const log4cplus::tstring & name); 43 | LOG4CPLUS_EXPORT void setCurrentThreadName2(const log4cplus::tstring & name); 44 | LOG4CPLUS_EXPORT void yield(); 45 | LOG4CPLUS_EXPORT void blockAllSignals(); 46 | 47 | 48 | #ifndef LOG4CPLUS_SINGLE_THREADED 49 | 50 | class ThreadImplBase 51 | : public virtual log4cplus::helpers::SharedObject 52 | { 53 | protected: 54 | virtual ~ThreadImplBase (); 55 | }; 56 | 57 | 58 | /** 59 | * There are many cross-platform C++ Threading libraries. The goal of 60 | * this class is not to replace (or match in functionality) those 61 | * libraries. The goal of this class is to provide a simple Threading 62 | * class with basic functionality. 63 | */ 64 | class LOG4CPLUS_EXPORT AbstractThread 65 | : public virtual log4cplus::helpers::SharedObject 66 | { 67 | public: 68 | AbstractThread(); 69 | bool isRunning() const; 70 | virtual void start(); 71 | void join () const; 72 | virtual void run() = 0; 73 | 74 | protected: 75 | // Force objects to be constructed on the heap 76 | virtual ~AbstractThread(); 77 | 78 | private: 79 | helpers::SharedObjectPtr thread; 80 | 81 | // Disallow copying of instances of this class. 82 | AbstractThread(const AbstractThread&); 83 | AbstractThread& operator=(const AbstractThread&); 84 | }; 85 | 86 | typedef helpers::SharedObjectPtr AbstractThreadPtr; 87 | 88 | 89 | #endif // LOG4CPLUS_SINGLE_THREADED 90 | 91 | 92 | } } // namespace log4cplus { namespace thread { 93 | 94 | 95 | #endif // LOG4CPLUS_THREADS_HEADER_ 96 | 97 | -------------------------------------------------------------------------------- /ThirdParty/log4cplus-1.2.1-rc2/include/log4cplus/tracelogger.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: tracelogger.h 4 | // Created: 1/2009 5 | // Author: Vaclav Haisman 6 | // 7 | // 8 | // Copyright 2009-2015 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_TRACELOGGER_H 25 | #define LOG4CPLUS_TRACELOGGER_H 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | #include 34 | 35 | 36 | namespace log4cplus 37 | { 38 | 39 | 40 | /** 41 | * This class is used to produce "Trace" logging. When an instance of 42 | * this class is created, it will log a "ENTER: " + msg 43 | * log message if TRACE_LOG_LEVEL is enabled for logger. 44 | * When an instance of this class is destroyed, it will log a 45 | * "ENTER: " + msg log message if TRACE_LOG_LEVEL is enabled 46 | * for logger. 47 | *

48 | * @see LOG4CPLUS_TRACE 49 | */ 50 | class TraceLogger 51 | { 52 | public: 53 | TraceLogger(const Logger& l, const log4cplus::tstring& _msg, 54 | const char* _file = LOG4CPLUS_CALLER_FILE (), 55 | int _line = LOG4CPLUS_CALLER_LINE (), 56 | char const * _function = LOG4CPLUS_CALLER_FUNCTION ()) 57 | : logger(l), msg(_msg), file(_file), function(_function), line(_line) 58 | { 59 | if(logger.isEnabledFor(TRACE_LOG_LEVEL)) 60 | logger.forcedLog(TRACE_LOG_LEVEL, LOG4CPLUS_TEXT("ENTER: ") + msg, 61 | file, line, function); 62 | } 63 | 64 | ~TraceLogger() 65 | { 66 | if(logger.isEnabledFor(TRACE_LOG_LEVEL)) 67 | logger.forcedLog(TRACE_LOG_LEVEL, LOG4CPLUS_TEXT("EXIT: ") + msg, 68 | file, line, function); 69 | } 70 | 71 | private: 72 | TraceLogger (TraceLogger const &); 73 | TraceLogger & operator = (TraceLogger const &); 74 | 75 | Logger logger; 76 | log4cplus::tstring msg; 77 | const char* file; 78 | const char* function; 79 | int line; 80 | }; 81 | 82 | 83 | } // log4cplus 84 | 85 | 86 | #endif // LOG4CPLUS_TRACELOGGER_H 87 | -------------------------------------------------------------------------------- /ThirdParty/log4cplus-1.2.1-rc2/include/log4cplus/tstring.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: tstring.h 4 | // Created: 4/2003 5 | // Author: Tad E. Smith 6 | // 7 | // 8 | // Copyright 2003-2015 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_TSTRING_HEADER_ 25 | #define LOG4CPLUS_TSTRING_HEADER_ 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | #include 34 | #include 35 | 36 | namespace log4cplus 37 | { 38 | 39 | typedef std::basic_string tstring; 40 | 41 | 42 | namespace helpers 43 | { 44 | 45 | inline 46 | std::string 47 | tostring (char const * str) 48 | { 49 | return std::string (str); 50 | } 51 | 52 | inline 53 | std::string 54 | tostring (std::string const & str) 55 | { 56 | return str; 57 | } 58 | 59 | inline 60 | std::string const & 61 | tostring (std::string & str) 62 | { 63 | return str; 64 | } 65 | 66 | #ifdef LOG4CPLUS_HAVE_RVALUE_REFS 67 | inline 68 | std::string 69 | tostring (std::string && str) 70 | { 71 | return std::move (str); 72 | } 73 | 74 | #endif 75 | 76 | 77 | 78 | inline 79 | std::wstring 80 | towstring (wchar_t const * str) 81 | { 82 | return std::wstring (str); 83 | } 84 | 85 | inline 86 | std::wstring 87 | towstring (std::wstring const & str) 88 | { 89 | return str; 90 | } 91 | 92 | inline 93 | std::wstring const & 94 | towstring (std::wstring & str) 95 | { 96 | return str; 97 | } 98 | 99 | #ifdef LOG4CPLUS_HAVE_RVALUE_REFS 100 | inline 101 | std::wstring 102 | towstring (std::wstring && str) 103 | { 104 | return std::move (str); 105 | } 106 | 107 | #endif 108 | 109 | LOG4CPLUS_EXPORT std::string tostring(const std::wstring&); 110 | LOG4CPLUS_EXPORT std::string tostring(wchar_t const *); 111 | 112 | LOG4CPLUS_EXPORT std::wstring towstring(const std::string&); 113 | LOG4CPLUS_EXPORT std::wstring towstring(char const *); 114 | 115 | } // namespace helpers 116 | 117 | #ifdef UNICODE 118 | 119 | #define LOG4CPLUS_C_STR_TO_TSTRING(STRING) log4cplus::helpers::towstring(STRING) 120 | #define LOG4CPLUS_STRING_TO_TSTRING(STRING) log4cplus::helpers::towstring(STRING) 121 | #define LOG4CPLUS_TSTRING_TO_STRING(STRING) log4cplus::helpers::tostring(STRING) 122 | 123 | #else // UNICODE 124 | 125 | #define LOG4CPLUS_C_STR_TO_TSTRING(STRING) (std::string(STRING)) 126 | #define LOG4CPLUS_STRING_TO_TSTRING(STRING) STRING 127 | #define LOG4CPLUS_TSTRING_TO_STRING(STRING) STRING 128 | 129 | #endif // UNICODE 130 | 131 | } // namespace log4cplus 132 | 133 | 134 | #endif // LOG4CPLUS_TSTRING_HEADER_ 135 | -------------------------------------------------------------------------------- /ThirdParty/log4cplus-1.2.1-rc2/include/log4cplus/version.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Copyright (C) 2010-2015, Vaclav Haisman. All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without modifica- 5 | // tion, are permitted provided that the following conditions are met: 6 | // 7 | // 1. Redistributions of source code must retain the above copyright notice, 8 | // this list of conditions and the following disclaimer. 9 | // 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 14 | // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 15 | // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 17 | // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 18 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- 19 | // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 20 | // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 21 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | 25 | 26 | #if ! defined (LOG4CPLUS_VERSION_H) 27 | #define LOG4CPLUS_VERSION_H 28 | 29 | #include 30 | 31 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 32 | #pragma once 33 | #endif 34 | 35 | #define LOG4CPLUS_MAKE_VERSION(major, minor, point) \ 36 | (major * 1000 * 1000u + minor * 1000u + point) 37 | 38 | #define LOG4CPLUS_MAKE_VERSION_STR(major, minor, point) \ 39 | #major "." #minor "." #point 40 | 41 | //! This is log4cplus version number as unsigned integer. This must 42 | //! be kept on a single line. It is used by Autotool and CMake build 43 | //! systems to parse version number. 44 | #define LOG4CPLUS_VERSION LOG4CPLUS_MAKE_VERSION(1, 2, 1) 45 | 46 | //! This is log4cplus version number as a string. 47 | #define LOG4CPLUS_VERSION_STR LOG4CPLUS_MAKE_VERSION_STR(1, 2, 1) 48 | 49 | 50 | namespace log4cplus 51 | { 52 | 53 | extern LOG4CPLUS_EXPORT unsigned const version; 54 | extern LOG4CPLUS_EXPORT char const versionStr[]; 55 | 56 | } 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /ThirdParty/log4cplus-1.2.1-rc2/include/log4cplus/win32consoleappender.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Copyright (C) 2009-2015, Vaclav Haisman. All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without modifica- 5 | // tion, are permitted provided that the following conditions are met: 6 | // 7 | // 1. Redistributions of source code must retain the above copyright notice, 8 | // this list of conditions and the following disclaimer. 9 | // 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 14 | // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 15 | // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 17 | // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 18 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- 19 | // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 20 | // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 21 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | 25 | #ifndef LOG4CPLUS_WIN32CONSOLEAPPENDER_H 26 | #define LOG4CPLUS_WIN32CONSOLEAPPENDER_H 27 | 28 | #include 29 | 30 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 31 | #pragma once 32 | #endif 33 | 34 | #if defined(_WIN32) && defined (LOG4CPLUS_HAVE_WIN32_CONSOLE) 35 | 36 | #include 37 | 38 | 39 | namespace log4cplus 40 | { 41 | 42 | /** 43 | * Prints events to Win32 console. 44 | * 45 | *

Properties

46 | *
47 | *
AllocConsole
48 | *
This boolean property specifies whether or not this appender 49 | * will try to allocate new console using the 50 | * AllocConsole() Win32 function.
51 | * 52 | *
logToStdErr
53 | *
When it is set true, the output will be into 54 | * STD_ERROR_HANDLE instead of STD_OUTPUT_HANDLE. 55 | *
56 | * 57 | *
TextColor
58 | *
See MSDN documentation for 59 | * 60 | * Character Attributes. 61 | *
62 | */ 63 | class LOG4CPLUS_EXPORT Win32ConsoleAppender 64 | : public Appender 65 | { 66 | public: 67 | explicit Win32ConsoleAppender (bool allocConsole = true, 68 | bool logToStdErr = false, unsigned int textColor = 0); 69 | Win32ConsoleAppender (helpers::Properties const & properties); 70 | virtual ~Win32ConsoleAppender (); 71 | 72 | virtual void close (); 73 | 74 | protected: 75 | virtual void append (spi::InternalLoggingEvent const &); 76 | 77 | void write_handle (void *, tchar const *, std::size_t); 78 | void write_console (void *, tchar const *, std::size_t); 79 | 80 | bool alloc_console; 81 | bool log_to_std_err; 82 | unsigned int text_color; 83 | 84 | private: 85 | Win32ConsoleAppender (Win32ConsoleAppender const &); 86 | Win32ConsoleAppender & operator = (Win32ConsoleAppender const &); 87 | }; 88 | 89 | } // namespace log4cplus 90 | 91 | #endif 92 | 93 | #endif // LOG4CPLUS_WIN32CONSOLEAPPENDER_H 94 | -------------------------------------------------------------------------------- /ThirdParty/log4cplus-1.2.1-rc2/include/log4cplus/win32debugappender.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: win32debugappender.h 4 | // Created: 12/2003 5 | // Author: Eduardo Francos, Odalio SARL 6 | // 7 | // 8 | // Copyright 2003-2015 Odalio SARL 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_WIN32DEBUG_APPENDER_HEADER_ 25 | #define LOG4CPLUS_WIN32DEBUG_APPENDER_HEADER_ 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | #if defined (LOG4CPLUS_HAVE_OUTPUTDEBUGSTRING) 34 | 35 | #include 36 | 37 | 38 | namespace log4cplus { 39 | 40 | /** 41 | * Prints log events using OutputDebugString(). 42 | */ 43 | class LOG4CPLUS_EXPORT Win32DebugAppender 44 | : public Appender 45 | { 46 | public: 47 | // Ctors 48 | Win32DebugAppender(); 49 | Win32DebugAppender(const log4cplus::helpers::Properties& properties); 50 | 51 | // Dtor 52 | virtual ~Win32DebugAppender(); 53 | 54 | // Methods 55 | virtual void close(); 56 | 57 | protected: 58 | virtual void append(const log4cplus::spi::InternalLoggingEvent& event); 59 | 60 | private: 61 | // Disallow copying of instances of this class 62 | Win32DebugAppender(const Win32DebugAppender&); 63 | Win32DebugAppender& operator=(const Win32DebugAppender&); 64 | }; 65 | 66 | } // end namespace log4cplus 67 | 68 | #endif // LOG4CPLUS_HAVE_OUTPUTDEBUGSTRING 69 | #endif // LOG4CPLUS_WIN32DEBUG_APPENDER_HEADER_ 70 | -------------------------------------------------------------------------------- /testEntityComponentSystem/HandleTest.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "CppUnitTest.h" 3 | 4 | #include "util/Handle.h" 5 | 6 | using namespace Microsoft::VisualStudio::CppUnitTestFramework; 7 | 8 | namespace Microsoft { namespace VisualStudio { namespace CppUnitTestFramework { 9 | 10 | template<> inline std::wstring ToString(const ECS::util::Handle32& t) { RETURN_WIDE_STRING(t); } 11 | #ifndef WIN32 12 | template<> inline std::wstring ToString(const ECS::util::Handle64& t) { RETURN_WIDE_STRING(t); } 13 | #endif 14 | }}} 15 | 16 | 17 | namespace ECS 18 | { 19 | using namespace util; 20 | 21 | TEST_CLASS(HandleTest) 22 | { 23 | public: 24 | 25 | TEST_METHOD(TestHandle32) 26 | { 27 | Handle32 h0; 28 | Handle32 h1; 29 | 30 | Assert::AreEqual(h0, (Handle32)Handle32::INVALID_HANDLE); 31 | Assert::AreEqual(h0, h1); 32 | 33 | 34 | Assert::AreNotEqual(Handle32(Handle32::MAX_INDICES, Handle32::MAX_VERSION), (Handle32)Handle32::INVALID_HANDLE); 35 | 36 | Assert::AreNotEqual(Handle32(123, 1), Handle32(123, 2)); 37 | Assert::AreNotEqual(Handle32(124, 1), Handle32(123, 1)); 38 | 39 | Assert::AreEqual(Handle32(123, 456), Handle32(123, 456)); 40 | } 41 | 42 | TEST_METHOD(TestHandle64) 43 | { 44 | Handle64 h0; 45 | Handle64 h1; 46 | 47 | Assert::AreEqual(h0, (Handle64)Handle64::INVALID_HANDLE); 48 | Assert::AreEqual(h0, h1); 49 | 50 | 51 | Assert::AreNotEqual(Handle64(Handle64::MAX_INDICES, Handle64::MAX_VERSION), (Handle64)Handle64::INVALID_HANDLE); 52 | 53 | Assert::AreNotEqual(Handle64(123, 1), Handle64(123, 2)); 54 | Assert::AreNotEqual(Handle64(124, 1), Handle64(123, 1)); 55 | 56 | Assert::AreEqual(Handle64(123, 456), Handle64(123, 456)); 57 | } 58 | }; 59 | } -------------------------------------------------------------------------------- /testEntityComponentSystem/TestDynVsCRTPCallSpeed.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "CppUnitTest.h" 3 | 4 | 5 | using namespace Microsoft::VisualStudio::CppUnitTestFramework; 6 | 7 | TEST_CLASS(TestDynVsCRTPCallSpeed) 8 | { 9 | static constexpr unsigned N { 40000 }; 10 | 11 | class DynamicInterface { 12 | public: 13 | virtual void tick(uint64_t n) = 0; 14 | virtual uint64_t getvalue() = 0; 15 | }; 16 | 17 | class DynamicImplementation : public DynamicInterface { 18 | uint64_t counter; 19 | 20 | public: 21 | DynamicImplementation() 22 | : counter(0) { 23 | } 24 | 25 | virtual void tick(uint64_t n) { 26 | counter += n; 27 | } 28 | 29 | virtual uint64_t getvalue() { 30 | return counter; 31 | } 32 | }; 33 | 34 | template 35 | class CRTPInterface { 36 | public: 37 | void tick(uint64_t n) { 38 | impl().tick(n); 39 | } 40 | 41 | uint64_t getvalue() { 42 | return impl().getvalue(); 43 | } 44 | private: 45 | Implementation & impl() { 46 | return *static_cast(this); 47 | } 48 | }; 49 | 50 | class CRTPImplementation : public CRTPInterface { 51 | uint64_t counter; 52 | public: 53 | CRTPImplementation() 54 | : counter(0) { 55 | } 56 | 57 | void tick(uint64_t n) { 58 | counter += n; 59 | } 60 | 61 | uint64_t getvalue() { 62 | return counter; 63 | } 64 | }; 65 | 66 | public: 67 | 68 | TEST_METHOD(TestDynCallSpeed) 69 | { 70 | DynamicInterface* obj = new DynamicImplementation(); 71 | 72 | for (unsigned i = 0; i < N; ++i) { 73 | for (unsigned j = 0; j < i; ++j) { 74 | obj->tick(j); 75 | } 76 | } 77 | 78 | delete obj; 79 | obj = nullptr; 80 | } 81 | 82 | TEST_METHOD(TestCRTPCallSpeed) 83 | { 84 | CRTPInterface* obj = new CRTPImplementation(); 85 | for (unsigned i = 0; i < N; ++i) { 86 | for (unsigned j = 0; j < i; ++j) { 87 | obj->tick(j); 88 | } 89 | } 90 | 91 | delete obj; 92 | obj = nullptr; 93 | } 94 | }; 95 | -------------------------------------------------------------------------------- /testEntityComponentSystem/Timer.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "CppUnitTest.h" 3 | 4 | #include "util/Timer.h" 5 | 6 | using namespace Microsoft::VisualStudio::CppUnitTestFramework; 7 | 8 | namespace Microsoft { namespace VisualStudio { namespace CppUnitTestFramework { 9 | 10 | template<> inline std::wstring ToString(const ECS::TimeStamp& t) { RETURN_WIDE_STRING(t); } 11 | }}} 12 | 13 | 14 | namespace ECS 15 | { 16 | using namespace util; 17 | 18 | TEST_CLASS(TimerTest) 19 | { 20 | public: 21 | 22 | TEST_METHOD(TestTimeStampConversion) 23 | { 24 | TimeStamp ts1; 25 | Assert::AreEqual((u32)ts1, 0U); 26 | 27 | TimeStamp ts2(123.456f), ts3(123.456f); 28 | Assert::IsTrue(ts2 == ts3); 29 | 30 | TimeStamp ts4(123.456f), ts5(123.457f); 31 | Assert::IsTrue(ts4 != ts5); 32 | 33 | TimeStamp ts6(1234.5678f); 34 | TimeStamp ts7; 35 | ts7.asUInt = ts6; 36 | Assert::AreEqual(1234.5678f, ts7.asFloat); 37 | } 38 | 39 | TEST_METHOD(TestTimer) 40 | { 41 | Timer t1; 42 | Assert::AreEqual((u32)t1.GetTimeStamp(), 0U); 43 | 44 | t1.Tick(100.0f); 45 | t1.Tick(150.0f); 46 | t1.Tick(10.0f); 47 | t1.Tick(0.5f); 48 | 49 | TimeStamp ts1 = t1.GetTimeStamp(); 50 | Assert::AreEqual(ts1, TimeStamp(260.5f)); 51 | 52 | t1.Reset(); 53 | Assert::AreEqual((u32)t1.GetTimeStamp(), 0U); 54 | 55 | t1.Tick(0.5f); 56 | t1.Tick(10.0f); 57 | t1.Tick(250.0f); 58 | TimeStamp ts2 = t1.GetTimeStamp(); 59 | 60 | Assert::AreEqual(ts1, ts2); 61 | } 62 | }; 63 | } -------------------------------------------------------------------------------- /testEntityComponentSystem/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // testEntityComponentSystem.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /testEntityComponentSystem/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | // Headers for CppUnitTest 11 | #include "CppUnitTest.h" 12 | 13 | // TODO: reference additional headers your program requires here 14 | -------------------------------------------------------------------------------- /testEntityComponentSystem/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /testEntityComponentSystem/testEntityComponentSystem.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {81691b14-1637-4f21-aa5f-630329971e97} 18 | 19 | 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files\util 34 | 35 | 36 | Source Files\util 37 | 38 | 39 | --------------------------------------------------------------------------------