#pragma once #include "../../common/compat.hpp" namespace sprawl { template<typename ValueType, typename KeyType, KeyType(ValueType::*function)()> class MemberAccessor { public: typedef KeyType key_type; struct arg_type {}; MemberAccessor(ValueType& value) : m_value(&value) { // } inline KeyType const Key() const { return (m_value->*function)(); } inline ValueType& Value() { return *m_value; } inline ValueType const& Value() const { return *m_value; } private: ValueType* m_value; }; template<typename ValueType, typename KeyType, KeyType(ValueType::*function)() const> class ConstMemberAccessor { public: typedef KeyType key_type; struct arg_type {}; ConstMemberAccessor(ValueType& value) : m_value(&value) { // } inline KeyType const Key() const { return (m_value->*function)(); } inline ValueType& Value() { return *m_value; } inline ValueType const& Value() const { return *m_value; } private: ValueType* m_value; }; template<typename ValueType, typename KeyType, KeyType(ValueType::*function)(), typename PointerType = ValueType*> class PtrMemberAccessor { public: typedef KeyType key_type; struct arg_type {}; PtrMemberAccessor(PointerType& value) : m_value(&value) { // } inline KeyType const Key() const { return ((*(*m_value)).*function)(); } inline PointerType& Value() { return *m_value; } inline PointerType const& Value() const { return *m_value; } private: PointerType* m_value; }; template<typename ValueType, typename KeyType, KeyType(ValueType::*function)() const, typename PointerType = ValueType*> class PtrConstMemberAccessor { public: typedef KeyType key_type; struct arg_type {}; PtrConstMemberAccessor(PointerType& value) : m_value(&value) { // } inline KeyType const Key() const { return ((*m_value).*function)(); } inline PointerType& Value() { return *m_value; } inline PointerType const& Value() const { return *m_value; } private: PointerType* m_value; }; template<typename ValueType, typename KeyType, KeyType(*function)(ValueType*)> class FunctionAccessor { public: typedef KeyType key_type; struct arg_type {}; FunctionAccessor(ValueType& value) : m_value(&value) { // } inline KeyType const Key() const { return (*function)(m_value); } inline ValueType& Value() { return *m_value; } inline ValueType const& Value() const { return *m_value; } private: ValueType* m_value; }; template<typename ValueType, typename KeyType, KeyType(*function)(ValueType*), typename PointerType = ValueType*> class PtrFunctionAccessor { public: typedef KeyType key_type; struct arg_type {}; PtrFunctionAccessor(PointerType& value) : m_value(&value) { // } inline KeyType const Key() const { return (*function)(&(*(*m_value))); } inline PointerType& Value() { return *m_value; } inline PointerType const& Value() const { return *m_value; } private: mutable PointerType* m_value; }; template<typename ValueType, typename KeyType> class KeyAccessor { public: typedef KeyType key_type; typedef KeyType arg_type; KeyAccessor(ValueType& value, KeyType const& key) : m_key(key) , m_value(&value) { // } inline KeyType const& Key() const { return m_key; } inline ValueType& Value() { return *m_value; } inline ValueType const& Value() const { return *m_value; } private: KeyType m_key; ValueType* m_value; }; template<typename ValueType> class SelfAccessor { public: typedef ValueType key_type; struct arg_type {}; SelfAccessor(ValueType& value) : m_value(&value) { // } inline ValueType const& Key() const { return *m_value; } inline ValueType& Value() { return *m_value; } inline ValueType const& Value() const { return *m_value; } private: ValueType* m_value; }; class NullAccessor { public: typedef void* key_type; struct arg_type {}; inline void* Key() { return nullptr; } }; }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 23398 | ququlala | "Forking branch Mainline of shadauxcat-libsprawl to ququlala-libsprawl." | ||
//guest/ShadauxCat/Sprawl/Mainline/collections/accessor/Accessors.hpp | |||||
#3 | 16052 | ShadauxCat |
- Changed default block size for concurrent queue to a more reasonable value - Changed some memory orders to memory_order_seq_cst when they don't actually need to be that to get around a bug in visual studio 2013 - debug builds assert when memory_order_acq_rel is used for a compare_exchange_strong (this is a standard library bug and is fixed in VS2015) - Added Event API - events are an alternative to condition variables that do not require a mutex and are guaranteed not to miss any signals, even if the signal comes while the thread is not listening for it. Unlike condition variables, however, they do not support broadcasting (and in fact, in general, are not safe to use with multiple threads listening for the same event simultaneously - though notifying on the same event is fine) - Rewrote ThreadManager around ConcurrentQueue and Event API so it is now lock-free. Also improved some behaviors of the staged thread manager operation so it now supports tasks that can be run on multiple stages via a bitmask. - Fixed an issue where the Coroutine copy constructor was calling the std::function constructor instead and another where initializing with a stack might try to call the wrong constructor and vice-versa - Fixed Coroutine never calling munmap() on its stack in linux and causing a memory leak - Added default arguments to time functions - Attempted to fix some issues with BinaryTree. Fixed some but not all. It's currently not suitable for use, sadly. - Logging Improvements: - - Added thread ID to logging - - Fixed some issues with category handlers - - Added backtraces - - Added the following additional log macros: - - - LOG_IF - - - LOG_EVERY_N - - - LOG_FIRST_N - - - LOG_IF_EVERY_N - - - LOG_IF_FIRST_N - - - LOG_ASSERT - - Added the ability to set extra info callbacks to get data such as script backtraces - - Removed the thread-related handlers and replaced them with RunHandler_Threaded and RunHandler_ThreadManager, which will enable any passed-in handler to be run in a threaded fashion - Removed StaticPoolAllocator and renamed DynamicPoolAllocator to PoolAllocator; adjusted unit tests accordingly - PoolAllocator now allocates its pool with mmap and VirtualAlloc, rather than with malloc - Fixed a bug with Vector copy assignment operator - Improved performance of StringBuilder considerably for cases where there are no modifier strings - Removed Copy-On-Write behavior of JSONToken as it was broken; copies are now performed with explicit DeepCopy() and ShallowCopy() functions - Fixed some parser bugs with JSONToken - Added iteration to JSONToken to iterate its children - Fixed crash when reading a negative number of bytes from a file - Changed StringBuilder to favor speed instead of memory by default - Added some performance unit tests for JSON token #review-16053 |
||
#2 | 14066 | ShadauxCat |
-Improved iterating in hashmap - range-based for now gives the ability to access both key and value instead of just value -Slightly improved some of the template aliases -Mega-deprecated VC11 support. Probably doesn't compile anymore. Maintaining it is too much of a headache. #review-14067 |
||
#1 | 11496 | ShadauxCat | Initial checkin: Current states for csbuild and libSprawl |