diff --git a/src/lib/hash-fnv.c b/src/lib/hash-fnv.c deleted file mode 100644 index 601840d71..000000000 --- a/src/lib/hash-fnv.c +++ /dev/null @@ -1,166 +0,0 @@ -/* - HashFNV - FNV hash functions - - original by chongo /\oo/\ - http://www.isthe.com/chongo/ - adapted for Lumiera - 2010, 2011 Christian Thaeter - - Please do not copyright this code. This code is in the public domain. - - LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO - EVENT SHALL LANDON CURT NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR - CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF - USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - PERFORMANCE OF THIS SOFTWARE. - - Share and Enjoy! :-) - -* *****************************************************************/ - - -/** @file hash-fnv.c - ** Implementation of FNV ("Fowler-Noll-Vo") hashing functions. - ** @remarks code for this implementation is public domain - */ - - -#include "lib/hash-fnv.h" - -#include - - - -uint64_t -hash_fnv64a_buf (const void *buf, size_t len, uint64_t hval) -{ - const unsigned char *bp = (const unsigned char *)buf; - const unsigned char *be = bp + len; - while (bp < be) - { - hval ^= (uint64_t)*bp++; - hval *= HASH_FNV64_PRIME; - } - - return hval; -} - - - -uint32_t -hash_fnv32a_buf (const void *buf, size_t len, uint32_t hval) -{ - const unsigned char *bp = (const unsigned char *)buf; - const unsigned char *be = bp + len; - while (bp < be) - { - hval ^= (uint32_t)*bp++; - hval *= HASH_FNV32_PRIME; - } - - return hval; -} - - -uint64_t -hash_fnv64a_strn (const char* str, size_t len, uint64_t hval) -{ - const unsigned char *bp = (const unsigned char *)str; - if (bp) - while (*bp && len--) - { - hval ^= (uint64_t)*bp++; - hval *= HASH_FNV64_PRIME; - } - - return hval; -} - - - -uint32_t -hash_fnv32a_strn (const char* str, size_t len, uint32_t hval) -{ - const unsigned char *bp = (const unsigned char *)str; - if (bp) - while (*bp && len--) - { - hval ^= (uint32_t)*bp++; - hval *= HASH_FNV32_PRIME; - } - - return hval; -} - - - -uint64_t -hash_fnv64_xorfold (uint64_t hash, int bits) -{ - REQUIRE(bits <= 64); - - bits = 64-bits; - - uint64_t mask = ~0ULL>>bits; - for (int todo = 32; bits && todo; todo >>= 1) - if (bits >= todo) - { - hash = hash ^ hash>>todo; - bits-=todo; - } - - return hash & mask; -} - - -uint32_t -hash_fnv32_xorfold (uint32_t hash, int bits) -{ - REQUIRE (bits <= 32); - - bits = 32-bits; - - uint32_t mask = ~0ULL>>bits; - for (int todo = 16; bits && todo; todo >>= 1) - if (bits >= todo) - { - hash = hash ^ hash>>todo; - bits-=todo; - } - - return hash & mask; -} - - -uint64_t -hash_fnv64_retry (uint64_t hash, uint64_t limit) -{ - uint64_t retry_level= (UINT64_MAX / limit) * limit; - - while (hash >= retry_level) - hash = (hash * HASH_FNV64_PRIME) + HASH_FNV64_BASE; - - return hash % limit; -} - - -uint32_t -hash_fnv32_retry (uint64_t hash, uint32_t limit) -{ - uint32_t retry_level= (UINT32_MAX / limit) * limit; - - while (hash >= retry_level) - hash = (hash * HASH_FNV32_PRIME) + HASH_FNV32_BASE; - - return hash % limit; -} - -/* -// Local Variables: -// mode: C -// c-file-style: "gnu" -// indent-tabs-mode: nil -// End: -*/ diff --git a/src/lib/hash-fnv.h b/src/lib/hash-fnv.h deleted file mode 100644 index 874f2ee8e..000000000 --- a/src/lib/hash-fnv.h +++ /dev/null @@ -1,155 +0,0 @@ -/* - HASH-FNV.h - FNV hash functions - - original by chongo /\oo/\ - http://www.isthe.com/chongo/ - adapted for Lumiera - 2010, 2011 Christian Thaeter - - Please do not copyright this code. This code is in the public domain. - - LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO - EVENT SHALL LANDON CURT NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR - CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF - USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - PERFORMANCE OF THIS SOFTWARE. - - Share and Enjoy! :-) - -*/ - - -/** @file hash-fnv.h - ** Fowler-Noll-Vo Hashes. - ** FNV is a non-cryptographic hash function created by Glenn Fowler, Landon Curt Noll, and Phong Vo. - */ - - -#ifndef HASH_FNV_H -#define HASH_FNV_H - -#include /* for size_t */ -#include - -#define HASH_FNV64_BASE ((uint64_t)14695981039346656037ULL) -#define HASH_FNV32_BASE ((uint32_t)2166136261UL) - -#define HASH_FNV64_PRIME ((uint64_t)1099511628211ULL) -#define HASH_FNV32_PRIME ((uint32_t)16777619UL) - - -/** - * FNV-1a 64 bit hash over a buffer. - * @param buf start of the buffer - * @param len size of the buffer - * @param hval previous hash value when incremental hashing or HASH_FNV64_BASE when starting a new hash - * @return new hash value - */ -uint64_t -hash_fnv64a_buf (const void *buf, size_t len, uint64_t hval); - -/** - * FNV-1a 64 bit hash over a zero terminated string. - * @param str start of the buffer - * @param len maximum size to be processed - * @param hval previous hash value when incremental hashing or HASH_FNV64_BASE when starting a new hash - * @return new hash value - */ -uint64_t -hash_fnv64a_strn (const char* str, size_t len, uint64_t hval); - - -/** - * FNV-1a 32 bit hash over a buffer. - * @param buf start of the buffer - * @param len size of the buffer - * @param hval previous hash value when incremental hashing or HASH_FNV32_BASE when starting a new hash - * @return new hash value - */ -uint32_t -hash_fnv32a_buf (const void *buf, size_t len, uint32_t hval); - - -/** - * FNV-1a 32 bit hash over a zero terminated string. - * @param str start of the buffer - * @param len maximum size to be processed - * @param hval previous hash value when incremental hashing or HASH_FNV32_BASE when starting a new hash - * @return new hash value - */ -uint32_t -hash_fnv32a_strn (const char* str, size_t len, uint32_t hval); - - - -/** - * reduce a hash value to n bits. - * Uses the xor folding method to stash a hash value together, this preserves unbiased hash distribution - * @param hash result from one of the 64 bit hash functions above - * @param bits number of significat bits for the result - * @result hashvalue with no more than 'bits' significant bits - */ -uint64_t -hash_fnv64_xorfold (uint64_t hash, int bits); - - -/** - * reduce a hash value to n bits. - * Uses the xor folding method to stash a hash value together, this preserves unbiased hash distribution - * @param hash result from one of the 32 bit hash functions above - * @param bits number of significat bits for the result - * @result hashvalue with no more than 'bits' significant bits - */ -uint32_t -hash_fnv32_xorfold (uint32_t hash, int bits); - - -/** - * reduce hash to be within 0 to limit-1. - * Uses the retry method to limit a hash value, this preserves unbiased hash distribution. - * @param hash result from one of the 64 bit hash functions above - * @param limit upper limit plus one for the result - * @result hashvalue in the range from 0 to limit-1 - */ -uint64_t -hash_fnv64_retry (uint64_t hash, uint64_t limit); - - -/** - * reduce hash to be within 0 to limit-1. - * Uses the retry method to limit a hash value, this preserves unbiased hash distribution. - * @param hash result from one of the 32 bit hash functions above - * @param limit upper limit plus one for the result - * @result hashvalue in the range from 0 to limit-1 - */ -uint32_t -hash_fnv32_retry (uint64_t hash, uint32_t limit); - - - -/* -PLANNED? 128 bit and 256bit hashes -128 bit FNV_prime = 288 + 28 + 0x3b = 309485009821345068724781371 - -256 bit FNV_prime = 2168 + 28 + 0x63 = 374144419156711147060143317175368453031918731002211 - -128 bit offset_basis = 144066263297769815596495629667062367629 - -256 bit offset_basis = -100029257958052580907070968620625704837092796014241193945225284501741471925557 - -*/ - - - -#endif - -/* -// Local Variables: -// mode: C -// c-file-style: "gnu" -// indent-tabs-mode: nil -// End: -*/ diff --git a/src/lib/multifact.hpp b/src/lib/multifact.hpp index de33aec77..07d00c880 100644 --- a/src/lib/multifact.hpp +++ b/src/lib/multifact.hpp @@ -42,6 +42,11 @@ ** relying on rvalue references and variadic templates. However, we still need a ** specialised factory template to allow for a _family of factory functions_ with ** common configuration. + ** @todo 2025 ...and still not fully convinced this is the way to go; + ** admittedly we did not get to a point yet where fabricating lots of elements + ** poses any kind of challenge — up to now a dedicated factory function within a service + ** was enough to handle this task. Yet this may change, once we have stream types, + ** various kinds of assets (notably effects and processors) and lots of queries. ** ** @see multifact-test.cpp ** @see multifact-singleton-test.cpp diff --git a/src/lib/nobug-resource-handle-context.hpp b/src/lib/nobug-resource-handle-context.hpp deleted file mode 100644 index e4365a753..000000000 --- a/src/lib/nobug-resource-handle-context.hpp +++ /dev/null @@ -1,94 +0,0 @@ -/* - NOBUG-RESOURCE-HANDLE-CONTEXT.hpp - thread local stack to manage NoBug resource handles - - Copyright (C) - 2010, Hermann Vosseler - -  **Lumiera** is free software; you can redistribute it and/or modify it -  under the terms of the GNU General Public License as published by the -  Free Software Foundation; either version 2 of the License, or (at your -  option) any later version. See the file COPYING for further details. - -*/ - -/** @file nobug-resource-handle-context.hpp - ** Thread-local stack of NoBug resource handles. - ** This helper allows to access the resource handle in the nearest enclosing scope. - ** The motivation for this approach was to avoid passing the resource handle over - ** several intermediary function calls when using a scoped variable to control - ** object monitor locking. Within this usage context, the necessity of passing - ** a NoBug resource handle seems to be a cross-cutting concern, and not directly - ** related to the core concern (controlling a mutex). - ** - ** @remarks as of 8/2011, this feature is not used anymore. In 12/2011, the concept - ** of a diagnostic context stack was generalised. At that point, this header was - ** created as an off-spin, now based on the generalised feature, to document this - ** usage possibility, which might be required again at some point in the future. - ** - ** @see lib::DiagnosticContext - ** @see diagnostic-context-test.hpp - ** - **/ - - -#ifndef LIB_NOBUG_RESOURCE_HANDLE_CONTEXT_H -#define LIB_NOBUG_RESOURCE_HANDLE_CONTEXT_H - - -#include "lib/error.hpp" -#include "lib/diagnostic-context.hpp" - -#include - - - -namespace lib { - - - -#ifdef NOBUG_MODE_ALPHA ////////////////////////TODO don't we need the handle in BETA builds for resource logging? - - /** - * Diagnostic data frame to hold a NoBug resource handle. - * This way, code in nested function calls may pick up the nearest available handle. - * @warning relies on thread-local access; never use this within global data structures. - */ - class NobugResourceHandleContext - : DiagnosticContext - { - public: - }; - - -#else /* not NOBUG_ALPHA */ - - - /** - * Disabled placeholder for the Diagnostic context, not used in release builds. - */ - class NobugResourceHandleContext - : util::NonCopyable - { - - typedef nobug_resource_user* Handle; - - public: - - operator Handle () ///< payload: NoBug resource tracker user handle - { - return 0; - } - - /** accessing the innermost diagnostic context created */ - static NobugResourceHandleContext& - access () - { - UNIMPLEMENTED ("how to disable DiagnosticContext with minimum overhead"); - } - }; -#endif /* NOBUG_ALPHA? */ - - - -} // namespace lib -#endif diff --git a/src/lib/simple-allocator.hpp b/src/lib/simple-allocator.hpp deleted file mode 100644 index 45fa8969c..000000000 --- a/src/lib/simple-allocator.hpp +++ /dev/null @@ -1,295 +0,0 @@ -/* - SIMPLE-ALLOCATOR.hpp - frontend for plain explicit allocations - - Copyright (C) - 2011, Hermann Vosseler - -  **Lumiera** is free software; you can redistribute it and/or modify it -  under the terms of the GNU General Public License as published by the -  Free Software Foundation; either version 2 of the License, or (at your -  option) any later version. See the file COPYING for further details. - -*/ - - -/** @file simple-allocator.hpp - ** Frontend and marker interface for allocating small objects explicitly. - ** Contrary to the TypedAllocationManager, the SimpleAllocator doesn't provide any - ** ref-counting or tracking facilities, nor does he support bulk de-allocation. - ** Each object needs to be allocated and released by explicit call. - ** The advantage over using std::allocator directly is the shortcut for (placement) construction, - ** and -- of course -- the ability to exchange the memory model at one central location. - ** - ** SimpleAllocator instances will be defined for a specific collection of types; for each of those - ** types, there will be an embedded dedicated custom allocator (currently as of 9/2011, just - ** implemented as std::allocator). Objects of these preconfigured types can be constructed - ** and destroyed through this allocator instance. Each call needs to be done explicitly, with - ** the precise, concrete type to be created or destroyed. This is especially important for - ** the releasing of objects: there is \em no support for any kind of virtual destruction. - ** - ** @see engine::BufferMetadata - ** @see TypedAllocationManager (another more elaborate custom allocation scheme) - ** - */ - - - -#ifndef LIB_SIMPLE_ALLOCATOR_H -#define LIB_SIMPLE_ALLOCATOR_H - -#include "lib/error.hpp" -#include "lib/meta/generator.hpp" -#include "lib/meta/typelist-util.hpp" -#include "lib/meta/util.hpp" -#include "lib/typed-counter.hpp" -#include "include/logging.h" - -#include -#include - - - -namespace lib { - - using lib::meta::Types; - using lib::meta::IsInList; - using lib::meta::InstantiateForEach; - - - - /* === Policies for simple custom allocator === */ - - /** - * Policy: use just plain heap allocations - * @warning whenever you define a specialisation, - * _you_ are responsible for proper alignment - * @see TICKET #1204 - */ - template - class CustomAllocator - : public std::allocator - { }; - - - /** - * Policy: maintain explicit per type instance count - * @note this imposes additional locking - */ - struct UseInstantiationCounting - { - template - size_t - allocationCount() const - { - return allocCnt_.get(); - } - - template - void - incrementCount() - { - allocCnt_.inc(); - } - - template - void - decrementCount() - { - allocCnt_.dec(); - } - - private: - lib::TypedCounter allocCnt_; - }; - - /** - * Policy: no additional instantiation accounting - */ - struct NoInstantiationCount - { - template size_t allocationCount() const { return 0; } - template void incrementCount() { /* NOP */ } - template void decrementCount() { /* NOP */ } - }; - - - - - - - /* === Allocator frontend === */ - - /** - * Frontend for explicit allocations, using a custom allocator. - * This template is to be instantiated for the collection of types - * later to be allocated through this custom memory manager/model. - * It provides convenience shortcuts for placement-construction - * and releasing of target objects. - * - * @todo currently (as of 8/09) the low-level pooled allocator - * isn't implemented; instead we do just heap allocations. - * ////////////////////////////////////////////////////////////////////////////////////////////Ticket #835 - */ - template - class SimpleAllocator - : InstantiateForEach< typename TYPES::List // for each of those types... - , CustomAllocator // ...mix in the custom allocator - > - , COUNTER // ...Instantiation accounting policy - { - - /** forward plain memory allocation */ - template - XX * - allocateSlot () - { - TRACE (memory, "allocate «%s»", util::typeStr().c_str()); - XX * newStorage = CustomAllocator::allocate (1); - COUNTER::template incrementCount(); - return newStorage; - } - - template - void - releaseSlot (XX* entry) - { - TRACE (memory, "release «%s»", util::typeStr().c_str()); - CustomAllocator::deallocate (entry, 1); - COUNTER::template decrementCount(); - } - - - template - void - ___assertSupportedType() - { - typedef typename TYPES::List PreconfiguredTypes; - typedef IsInList IsSupportedType; - - BOOST_STATIC_ASSERT (IsSupportedType::value); - } - - - - - public: /* ==== build objects with managed allocation ==== */ - -#define _EXCEPTION_SAFE_INVOKE(_CTOR_) \ - \ - ___assertSupportedType(); \ - XX* storage = allocateSlot(); \ - try \ - { \ - return (new(storage) _CTOR_ ); \ - } \ - catch(...) \ - { \ - releaseSlot(storage); \ - throw; \ - } - - template< class XX> - XX* //_____________________ - create () ///< invoke default ctor - { - _EXCEPTION_SAFE_INVOKE ( XX() ) - } - - - template< class XX, typename P1> - XX* //___________________ - create (P1& p1) ///< invoke 1-arg ctor - { - _EXCEPTION_SAFE_INVOKE ( XX (p1) ) - } - - - template< class XX - , typename P1 - , typename P2 - > - XX* //___________________ - create (P1& p1, P2& p2) ///< invoke 2-arg ctor - { - _EXCEPTION_SAFE_INVOKE ( XX (p1,p2) ) - } - - - template< class XX - , typename P1 - , typename P2 - , typename P3 - > - XX* //___________________ - create (P1& p1, P2& p2, P3& p3) ///< invoke 3-arg ctor - { - _EXCEPTION_SAFE_INVOKE ( XX (p1,p2,p3) ) - } - - - template< class XX - , typename P1 - , typename P2 - , typename P3 - , typename P4 - > - XX* //___________________ - create (P1& p1, P2& p2, P3& p3, P4& p4) ///< invoke 4-arg ctor - { - _EXCEPTION_SAFE_INVOKE ( XX (p1,p2,p3,p4) ) - } - - - template< class XX - , typename P1 - , typename P2 - , typename P3 - , typename P4 - , typename P5 - > - XX* //___________________ - create (P1& p1, P2& p2, P3& p3, P4& p4, P5& p5) ///< invoke 5-arg ctor - { - _EXCEPTION_SAFE_INVOKE ( XX (p1,p2,p3,p4,p5) ) - } - -#undef _EXCEPTION_SAFE_INVOKE - - - - template - void - destroy (XX* entry) - { - if (!entry) return; - ___assertSupportedType(); - try - { - entry->~XX(); - } - catch(...) - { - lumiera_err errorID = lumiera_error(); - WARN (common_dbg, "dtor of «%s» failed: %s", util::typeStr(entry).c_str() - , errorID ); - } - releaseSlot (entry); - } - - - /** diagnostics */ - template - size_t - numSlots() const - { - return COUNTER::template allocationCount(); - } - }; - - - - -} // namespace lib -#endif diff --git a/src/lib/sub-id.hpp b/src/lib/sub-id.hpp deleted file mode 100644 index 68567571a..000000000 --- a/src/lib/sub-id.hpp +++ /dev/null @@ -1,143 +0,0 @@ -/* - SUB-ID.hpp - extensible symbolic identifier - - Copyright (C) - 2009, Hermann Vosseler - -  **Lumiera** is free software; you can redistribute it and/or modify it -  under the terms of the GNU General Public License as published by the -  Free Software Foundation; either version 2 of the License, or (at your -  option) any later version. See the file COPYING for further details. - -*/ - - -/** @file sub-id.hpp - ** Extensible symbolic ID type. - ** @remark this is a design sketch (from 9/2009) an not used anywhere as of 3/2017... - ** - ** My observation is that, during design, I did run again and again into a specific - ** situation, which I then needed to circumvent in lack of a first class solution. - ** Learning from that experiences, I start building this structured ID template. - ** - it shall be an \em symbolic identifier, not an artificial ID - ** - the basic value set should be limited and statically type safe. - ** - possibility of structured adornments and variations - ** - optionally concealing these extensions from the interface level - ** - ** The first attempt to build such an entity is based on standard techniques, - ** disregarding performance and memory footprint considerations. - ** - ** @todo 1/2016 this idea seems very reasonable, and we should just make it - ** robust and usable, along the lines pointed out by that draft - ** - use std::tuple as storage - ** - remove the `format-util` dependency (!) ////////////////////////////////TICKET #985 - ** - provide a hash implementation for real - ** - extend to arbitrary number of sub-dimensions (variadic) - ** - implement comparisons as you'd do for any algebraic type - ** - provide a metaprogramming facility to get an id tuple - ** - ** @see SubID_test - ** @see MultiFact - ** - */ - - - -#ifndef LIB_SUB_ID_H -#define LIB_SUB_ID_H - -#include "lib/format-util.hpp" - -//#include -#include /////TODO better push the hash implementation into a cpp file (and btw, do it more seriously!) - -#include - - -namespace lib { - - using boost::hash_value; - using std::string; - - - - /** - * - */ - template - class SubId; - - class SubID - { - public: - virtual ~SubID() { } - - virtual operator string() const =0; - }; - - - inline size_t - hash_value (SubID const& sID) - { - return hash_value (string (sID)); - } - - inline bool - operator== (SubID const& id1, SubID const& id2) - { - return (string (id1) == string (id2)); - } - - ////////TODO a serious implementation should descend recursively, instead of relying on the string representation - - - - - - - template - class SubId - : public SubID - { - I baseID_; - - public: - SubId (I id) - : baseID_(id) - { } - - operator string() const - { - using util::toString; - return toString (baseID_); // note: extension point - } - }; - - - template - class ExtendedSubId - : public SubId - { - typedef SubId _baID; - - SUZ extID_; - - public: - ExtendedSubId (I i, SUZ const& chain) - : _baID(i) - , extID_(chain) - { } - - operator string() const - { - return _baID::operator string() - + '.' - + string (extID_); - } - }; - - - - -} // namespace lib -#endif diff --git a/src/lib/vcall.h b/src/lib/vcall.h deleted file mode 100644 index 83b04a055..000000000 --- a/src/lib/vcall.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - vcall.h - helper macros for virtual (method) calls in C - - Copyright (C) Lumiera.org - 2010, Christian Thaeter - -  **Lumiera** is free software; you can redistribute it and/or modify it -  under the terms of the GNU General Public License as published by the -  Free Software Foundation; either version 2 of the License, or (at your -  option) any later version. See the file COPYING for further details. -*/ - -#ifndef LUMIERA_VCALL_H -#define LUMIERA_VCALL_H - -#include - -/** - * @file - * This allows one to do polymorphic programming in C by referencing a vtable - * member which contains function pointers to a structure and then calling - * this 'virtual' functions through the VCALL macro. - */ - -/* - TODO usage example, see btree.h -*/ - -/** - * helper macro for calling vtable functions - * just adds syntacic sugar VCALL(obj, func, params...) - * translates to obj->vtable->func(obj, params...) plus some saftey checks - */ -#define LUMIERA_VCALL(self, function, ...) \ - ({ \ - REQUIRE (self); \ - REQUIRE (self->vtable->function); \ - self->vtable->function (self, ## __VA_ARGS__); \ - }) - -#ifndef VCALL -#define VCALL LUMIERA_VCALL -#else -#error "WTF! someone defined VCALL!" -#endif - -#endif -/* -// Local Variables: -// mode: C -// c-file-style: "gnu" -// indent-tabs-mode: nil -// End: -*/ diff --git a/tests/15library.tests b/tests/15library.tests index 3816752ea..f5932dbbc 100644 --- a/tests/15library.tests +++ b/tests/15library.tests @@ -628,18 +628,6 @@ return: 0 END -TEST "extensible symbolic identifier" SubID_test < - -  **Lumiera** is free software; you can redistribute it and/or modify it -  under the terms of the GNU General Public License as published by the -  Free Software Foundation; either version 2 of the License, or (at your -  option) any later version. See the file COPYING for further details. - -* *****************************************************************/ - -/** @file simple-allocator-test.cpp - ** unit test \ref SimpleAllocator_test - */ - - -#include "lib/test/run.hpp" -#include "lib/simple-allocator.hpp" -#include "lib/util.hpp" - -#include - - -namespace lib { -namespace test{ - - using util::isSameObject; - using std::string; - - - - namespace { // test data and helpers... - - long checksum_ = 0; - - /** - * Yet-another ctor/dtor-tracking test dummy object.... - */ - template - class DummyObj - { - char crap_[siz]; - - public: - DummyObj() - { - REQUIRE (siz); - for (uint i=0; i,DummyObj<23>,string> SupportedTypes; - typedef SimpleAllocator TestAllocator; - } - - - - /***********************************************************************************//** - * @test cover the basic operations of a custom allocator, delegating to mpool. - * The SimpleAllocator doesn't provide any ref-counting or tracking facilities, - * nor does he support bulk de-allocation. The advantage over using std::allocator - * directly is the shortcut for (placement) construction, and -- of course -- the - * ability to exchange the memory model at one central location. - * - * @todo as of 9/11 we do heap allocation, but we should use mpool -- see also Ticket #835 - * - * @see engine::BufferMetadata - * @see TypedAllocationManager_test - */ - class SimpleAllocator_test : public Test - { - - virtual void - run (Arg) - { - CHECK (0 == checksum_); - seedRand(); - - TestAllocator allocator; - - typedef string * PS; - typedef DummyObj<1> * PD1; - typedef DummyObj<23> * PD23; - CHECK (sizeof(DummyObj<1>) != sizeof(DummyObj<23>)); - - PD1 pD11 = allocator.create>(); - PD1 pD12 = allocator.create>(); - PD23 pD21 = allocator.create>(); - PD23 pD22 = allocator.create>(); - PS pS11 = allocator.create ("Lumiera"); - PS pS12 = allocator.create ("the paradox"); - - CHECK (pD11); - CHECK (pD12); - CHECK (pD21); - CHECK (pD22); - CHECK (pS11); - CHECK (pS12); - CHECK (!isSameObject (*pD11, *pD12)); - CHECK (!isSameObject (*pD11, *pD21)); - CHECK (!isSameObject (*pD11, *pD22)); - CHECK (!isSameObject (*pD11, *pS11)); - CHECK (!isSameObject (*pD11, *pS12)); - CHECK (!isSameObject (*pD12, *pD21)); - CHECK (!isSameObject (*pD12, *pD22)); - CHECK (!isSameObject (*pD12, *pS11)); - CHECK (!isSameObject (*pD12, *pS12)); - CHECK (!isSameObject (*pD21, *pD22)); - CHECK (!isSameObject (*pD21, *pS11)); - CHECK (!isSameObject (*pD21, *pS12)); - CHECK (!isSameObject (*pD22, *pS11)); - CHECK (!isSameObject (*pD22, *pS12)); - CHECK (!isSameObject (*pS11, *pS12)); - - CHECK (*pS11 == "Lumiera"); - CHECK (*pS12 == "the paradox"); - - PD23 pDxx = allocator.create> (*pD21); - PS pSxx = allocator.create (*pS12); - - CHECK (*pS12 == *pSxx); - CHECK (!isSameObject (*pS12, *pSxx)); - - allocator.destroy (pD11); - allocator.destroy (pD12); - allocator.destroy (pD21); - allocator.destroy (pD22); - allocator.destroy (pS11); - allocator.destroy (pS12); - allocator.destroy (pDxx); - allocator.destroy (pSxx); - - CHECK (0 == allocator.numSlots>()); - CHECK (0 == allocator.numSlots>()); - CHECK (0 == allocator.numSlots()); - CHECK (0 == checksum_); - } - }; - - - /** Register this test class... */ - LAUNCHER (SimpleAllocator_test, "unit common"); - - -}} // namespace lib::test diff --git a/tests/library/sub-id-test.cpp b/tests/library/sub-id-test.cpp deleted file mode 100644 index 54a5c63d2..000000000 --- a/tests/library/sub-id-test.cpp +++ /dev/null @@ -1,178 +0,0 @@ -/* - SubID(Test) - exploring possible properties of an extensible symbolic identifier - - Copyright (C) - 2009, Hermann Vosseler - -  **Lumiera** is free software; you can redistribute it and/or modify it -  under the terms of the GNU General Public License as published by the -  Free Software Foundation; either version 2 of the License, or (at your -  option) any later version. See the file COPYING for further details. - -* *****************************************************************/ - -/** @file sub-id-test.cpp - ** unit test \ref SubID_test - */ - - -#include "lib/test/run.hpp" -#include "lib/util.hpp" -#include "lib/util-foreach.hpp" -#include "lib/format-cout.hpp" - -#include "lib/sub-id.hpp" - -#include -#include -#include -#include -#include - - - -namespace lib { -namespace test{ - - using util::for_each; - using std::bind; - using std::placeholders::_1; - using boost::hash; - using std::vector; - using std::string; - - - - namespace { // test data - - enum Colour { R,G,B }; - - - inline string - toString (Colour c) ///< make the enum printable - { - static string sym("RGB"); - return sym.substr(c,1); - } - - } - - - - - /************************************************************************//** - * @test for now (9/09) this is a playground for shaping a vague design idea - * - base types and casts - * - exploring some extensions - * - use this ID as Hash-Map key - * - * @see lib::SubID - */ - class SubID_test : public Test - { - - virtual void - run (Arg) - { - checkBaseType(); - checkExtension(); - checkSubIDHash(); - } - - - void - checkBaseType () - { - typedef SubId CID; - CID c1 (R); - CID c2 (G); - CID c3 (B); - - cout << "...." << c1 << c2 << c3 << endl; - } - - - void - checkExtension () - { - typedef SubId UID; - - typedef ExtendedSubId CUID; - - SubID const& id1 = CUID(R, 12); - SubID const& id2 = CUID(G, 13); - - cout << "id1=" << id1 << endl; - cout << "id2=" << id2 << endl; - } - - - void - checkSubIDHash() - { - typedef SubId CID; - typedef SubId UID; - typedef ExtendedSubId CUID; - - vector simpleIDs; - simpleIDs.push_back(CID(R)); - simpleIDs.push_back(CID(R)); - simpleIDs.push_back(CID(G)); - simpleIDs.push_back(CID(B)); - - vector extendedIDs; - extendedIDs.push_back(CUID(R,22)); - extendedIDs.push_back(CUID(R,22)); // note the duplicates get dropped - extendedIDs.push_back(CUID(R,23)); - extendedIDs.push_back(CUID(R,24)); - extendedIDs.push_back(CUID(G,24)); - extendedIDs.push_back(CUID(B,25)); - - buildHashtable (simpleIDs); - buildHashtable (extendedIDs); - } - - - - template - struct HashTable - : std::unordered_map> - { - void - add (KEY key) - { - (*this)[key] = string(key); - } - - void - verify (KEY key) - { - cout << "verify....." << key << endl; - CHECK (string(key) == (*this)[key]); - } - }; - - - template - void - buildHashtable (vector keys) - { - - typedef HashTable HTab; - HTab tab; - - for_each (keys, bind (&HTab::add, ref(tab), _1 )); - for_each (keys, bind (&HTab::verify, ref(tab), _1 )); - - cout << "Elements in hashtable: " << tab.size() << endl; - } - - - }; - - - /** Register this test class... */ - LAUNCHER (SubID_test, "unit common"); - - -}} // namespace lib::test diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index e1c0fab9f..8907af842 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -163776,8 +163776,7 @@ Since then others have made contributions, see the log for the history. - - + @@ -163805,6 +163804,37 @@ Since then others have made contributions, see the log for the history. + + + + + + + + + + + + + +

+ ein Müll-Header mit einem Dummy-Test, der seit > 10 Jahren herumliegt, und alle wichtigen Probleme nicht löst ... +

+

+ dann kann man auch gleich von Null anfangen +

+ + +
+
+
+ + + + + + +