|
The Vish Visualization Shell 0.3
Vish
|
Memory Management classes and routines. More...
Classes | |
| class | Ageable |
| Base class for objects which change from time to time. More... | |
| class | AlzheimerCreator |
| A Creator object which forgets its data when memory is going low. More... | |
| class | AssertionCallback |
| struct | AtomicityConfig |
| struct | AtomicityConfig< AtomicityConfigSelection::CXX_ATOMIC, 32 > |
| struct | AtomicityConfig< AtomicityConfigSelection::CXX_ATOMIC, 64 > |
| struct | AtomicityConfig< AtomicityConfigSelection::GCC_ATOMIC, 32 > |
| struct | AtomicityCounter |
| class | Attributes |
| Attributes are a selection of named MemCore::ChunkBase objects, each of them may carry arbitrary data. More... | |
| struct | Auto |
| A wrapper for constructing automatic or static objects or any kind of object whose destruction shall not be managed by strong reference pointers, but reference pointers to it are still allowed. More... | |
| struct | BaseChunk |
| Computing the right base class for a given element. More... | |
| struct | BaseChunk< T, Base, false > |
| Determine the base class for typed chunks of base classes that have another memory layout. More... | |
| struct | BaseChunk< T, Base, true > |
| Determine the base class for typed chunks of base classes that have the same memory layout. More... | |
| struct | BaseChunk< T, T, true > |
| Determine the base class for typed chunks of base classes. More... | |
| struct | C0 |
| Standardized control characters. More... | |
| class | Cache |
| Main administrative Cache object container. More... | |
| class | Cacheable |
| A domain for objects which may be cached. More... | |
| class | CacheBase |
| Abstract base class for Cache objects. More... | |
| class | CacheMap |
| A list of cache queues for each cacheable type. More... | |
| struct | CacheMultiQueue |
| Cache queues of different purpose. More... | |
| class | CacheQueue |
| A root object that holds a tail of cacheable objects. More... | |
| class | Chunk |
| A class which handles a chunk of memory. More... | |
| class | ChunkBase |
| Base class for chunks of managed memory (any type possible). More... | |
| struct | ChunkDataAddress |
| struct | ChunkDataAddress< bool > |
| struct | ChunkType |
| struct | Console |
| C++ API for stdio's puts(). More... | |
| struct | CopyRef |
| Pointer to a refcountable object which automatically initializes the pointer with constructing an object, whereby copies of this pointer object also mean copying its value. More... | |
| class | Counter |
| Base class for thread-safe counting, comes with an exception-safe incrementing/decrementing counter class. More... | |
| struct | CrashHandler |
| Usage: More... | |
| class | Creator |
| A Creator is a forwarding of some data object to its creational object. More... | |
| class | CreatorBase |
| A Domain-related abstract base class for reference-counted objects which occupy some memory but are able to release it on demand. More... | |
| class | CreatorCacheMap |
| A list of cache maps for each creator type. More... | |
| class | Creature |
| An abstract base class for object creators. More... | |
| struct | DeferredInitializationTrait |
| Trait class that allows to execute some action on an object when it receives the first strong reference count in its life. More... | |
| struct | DeferredInitializationTrait< Cacheable > |
| struct | DeferredInitializationTrait< Creature > |
| struct | DeferredInitializationTrait< ReferenceBase< Object > > |
| struct | DefineTypename |
| Convenience class to register and un-register names for types. More... | |
| class | DefineTypenameBase |
| A typemap used for adding new type names. More... | |
| struct | domain_cast |
| class | DynPtr |
| Encapsuled pointer class for pointers pointing to derived classes. More... | |
| class | DynPtr< ObjectBase, ObjectBase > |
| Base class for pointers to base classes. More... | |
| struct | DynPtrNotification |
| struct | DynPtrNotification< A > |
| struct | Exception |
| Base class for exceptions. More... | |
| class | FileInfo |
| Encapsulation for portable file times. More... | |
| class | Filetime |
| Encapsulation for portable file times. More... | |
| struct | Folder |
| Class for reading directory entries. More... | |
| class | FunctionStackProfiler |
| struct | Functor |
| An abstract base class for scalar functions on double values. More... | |
| struct | Globals |
| struct | IncrementDeadRefPtr |
| Exception class for cases when an invalid (dead) ref ptr is supposed to be incremented. More... | |
| class | Intercube |
| A container that holds many Interfaces. More... | |
| struct | IntercubeIterator |
| Iterator object for an Intercube. More... | |
| class | Interface |
| Interface template. More... | |
| class | interface_cast |
| Interface cast: Given an Intercube, retrive the an interface object which is stored there. More... | |
| class | InterfaceBase |
| Base class for Interfaces. More... | |
| class | InterfaceData |
| An interface for data. More... | |
| class | InterfaceIterationParameter |
| struct | InterfacePtr |
| struct | IOItem |
| class | IOTracer |
| struct | Irregularity |
| Handling irregular occurences in the program without terminating it but instead writing a logfile with extensive information and continuing program execution. More... | |
| struct | JohnConnor |
| class | LastKnownSourceCodeLineEntry |
| class | Lexicon |
| An incomplete development class for associating objects with strings, using lexical lookup and easy extraction of chapters. More... | |
| struct | LifeSupport |
| class | Loader |
| Abstract base class for object loaders, which are used by the LoaderRegistry. More... | |
| class | LoaderBase |
| Base class for Loaders. More... | |
| class | LoaderParameters |
| Parameters for the loading process. More... | |
| class | LoaderProgress |
| A base class for callbacks during the load process. More... | |
| class | LoaderRegistry |
| Database for routines that may create objects of type X. More... | |
| class | LoaderRegistryBase |
| class | LoaderRequest |
| Control structure that describes a network connection to a certain URL. More... | |
| class | lock |
| struct | MaxExceptionCount |
| Exception class for the rare case of a maximum reference count being reached. More... | |
| struct | MemoryException |
| struct | MemSizeConfig |
| struct | MemSizeConfig< 4 > |
| struct | MemSizeConfig< 8 > |
| struct | MemVector |
| A convenience class that looks like a std::vector<>, but is actually referring to a reference-counted common chunk of data. More... | |
| struct | MultiPtrMapHash |
| class | MutableCacheable |
| Cache objects that are allowed to change their size after creation. More... | |
| class | MutableName |
| A class holding a string whose changes are announced to a set of listeners. More... | |
| class | NamedCreatures |
| A convenience class to remember Creatures, which are base classes of all Creators, by name. More... | |
| class | NotNullPtr |
| A type to specify non-null pointer requirements. More... | |
| struct | NoVerboseRecursion |
| struct | NoVerboseStream |
| struct | NullPtrException |
| Exception class for accessing null pointer. More... | |
| class | OmegaPtr |
| The Omega pointer - forcibly makes an end to objects. More... | |
| struct | OmegaRef |
| Omega Pointer to a refcountable object which automatically destroys the object pointed to no matter how many strong references still exist to it. More... | |
| struct | PreDestructionTrait |
| Trait class that allows to execute some action on an object when it is going to be deleted. More... | |
| struct | PreDestructionTrait< Cacheable > |
| struct | Profiler |
| Profiling Support. More... | |
| struct | Provenance |
| Keeping track of provenance, where are objects created from? More... | |
| struct | PtrMap_t |
| struct | RangeException |
| Exception class for range violations. More... | |
| struct | Ref |
| Pointer to a refcountable object which automatically initializes the pointer with constructing an object. More... | |
| struct | reference_base |
| An convenience class to allow using std::shared_ptr and the ecosystem of the STL library in a syntax similar to the MemCore::RefPtr . More... | |
| class | ReferenceBase |
| Base class for objects which do reference counting. More... | |
| class | ReferenceCount |
| Base class for thread-safe reference counting. More... | |
| class | Referer |
| class | Referer< ReferenceBase< Object > > |
| Internal class for indirectly referencing objects, even dead ones. More... | |
| class | RefMap |
| Convenience template class for mapping of keys to strong reference pointers; provides a read-only search operation using the () operator. More... | |
| class | RefPtrTypeTrait |
| Default type trait for the RefPtr pointer -> operator. More... | |
| struct | ReserveOnly |
| Helper class as pseudo-argument for Chunk<> creators. More... | |
| class | ResizableChunk |
| A chunk that has no elements initially but can grow. More... | |
| class | Result |
| struct | SarahConnor |
| class | SaveInterfaceCreator |
| Abstract base class for objects that may equip a certain class object X with an interface to write this structure into a file. More... | |
| class | SaveInterfaceCreatorBase |
| class | SaveParameters |
| class | SaveRegistry |
| Database for routines saving a certain class to disk. More... | |
| class | SaveRegistryBase |
| struct | SelfInitialize |
| Internal class used as an argument for a computational destructor. More... | |
| class | SelfPtr |
| The kind of pointer used within a ReferenceBase as part of the reference-counted object itself. More... | |
| class | shared_mutex |
| class | simplestring |
| struct | SocketError |
| Exception class for socket failures. More... | |
| class | Span |
| Copying the definition from C++20 standard, to provide minimal API until it's fully available, see https://en.cppreference.com/w/cpp/container/span. More... | |
| class | Span< T, dynamic_extent > |
| Specialization of a span for the case of runtime-defined lengths. More... | |
| struct | SpeakPtr |
| struct | StackTrace |
| struct | StreamSaver |
| class | StreamSaverInterface |
| struct | StringChunk |
| A StringChunk is a chunk of character spans which references data within a contiguous storage space. More... | |
| struct | StringList |
| A list of strings. More... | |
| class | StrongPtr |
| A reference counting pointer class which keeps objects alive as long as strong pointers to these objects exist. More... | |
| struct | Terminator |
| class | ThreadPool |
| A pool of threads, to be used in conjunction with async(). More... | |
| class | Timer |
| A class to hide system dependent methods to count seconds. More... | |
| struct | type |
| class | TypedChunk |
| Class of chunks of a specific type, recursively derived from chunks on base classes of the given type. More... | |
| class | TypedChunkBase |
| The abstract base class for chunks that have a certain type. More... | |
| class | TypeInfo |
| Helper class for mapping C++ data types to objects. More... | |
| class | typemap |
| A class for mapping C++ types to some object. More... | |
| class | typeproperty |
| class | typeproperty< RefPtr< T > > |
| struct | VerboseCatcher |
| struct | VerboseRecursion |
| struct | VerboseStream |
| The class provides verbose printing of messages. More... | |
| class | WeakPtr |
| A pointer class which behaves like native C++ pointers, but knows about the lifetime of the referenced objects. More... | |
| class | WeakRefMap |
| Convenience template class for mapping of keys to weak reference pointers; provides a read-only search operation using the () operator. More... | |
| class | WorkerQueue |
Typedefs | |
| typedef StrongPtr< Cacheable, Cacheable > | CacheablePtr |
| Strong pointer to a cacheable object. | |
| typedef MemSizeConfig< sizeof(void *)>::memsize_t | memsize_t |
| The type to describe memory in bytes. | |
| template<class KeyObject , class ValueObject > | |
| using | MultiPtrMap = std::unordered_map< MultiPtrMapKey< KeyObject >, ValueObject, MultiPtrMapHash< KeyObject > > |
| Mapping one or multiple pointers to some value. | |
| using | NullPtr = std::nullptr_t |
| A type indicating an invalid pointer, similar to the NULL pointer in C, but type-safe. | |
| template<class Object , class ObjectBase = typename Object::reference_domain_t> | |
| using | RefPtr = StrongPtr< Object, ObjectBase > |
| Convenience template typedef to use RefPtr instead of StrongPtr. | |
| typedef int | socket_t |
| The identifier type for socked connection ID's, usually just an integer. | |
| typedef int | socketID_t |
| The identifier type for socked connection ID's, usually just an integer. | |
| typedef std::vector< socket_t > | sockets_t |
| Storage type for a set of socket connection descriptors. | |
| template<class Object , class ObjectBase = typename Object::reference_domain_t> | |
| using | StorageRefPtr = StrongPtr< Object, ObjectBase > |
| Strong pointers for rather persistent usage within a struct. | |
| template<class Object , class ObjectBase = typename Object::reference_domain_t> | |
| using | TempRefPtr = StrongPtr< Object, ObjectBase > |
| Strong pointers for temporary usage within a function. | |
| using | WCacheablePtr = WeakPtr< Cacheable, Cacheable > |
| Weak pointer to a cacheable object. | |
Functions | |
| template<typename F , typename... Args> | |
| auto | async (ThreadPool &thePool, F &&f, Args &&... args) |
| A custom implementation of std::async which is ensured to make use of a threadpool instead of always starting a new thread, thus this implementation avoids the overhead of thread creation. | |
| void | breakpoint (const char *Description) |
| Set a breakpoint from a description given as constant string, for situations where memory allocation as performed by a std::string may be an issue, like during exceptions that occur as result from severe memory corruption. | |
| void | breakpoint (const std::string &Description) |
| Programmatically set a breakpoint in the code for debugging purposes. | |
| MEMCORE_API void | CheckConstruction (void *, const std::type_info &RuntimeType, const std::type_info &CompiletimeType) |
| Debug function which registers a pointer with a type. | |
| void MEMCORE_API | CheckRefExcludeObject (void *myObject) |
| Debug function which unregisters a pointer, see CheckConstruction();. | |
| socketID_t | ConnectTo (const std::string &hostname, const std::string &service="6666") |
| Connect to a given host under service (portnumber). | |
| string | demangleSymbol (const char *name) |
| Demangle an compiler-specific symbol string, if possible. | |
| string | DirName (const string &file_or_dir_name) |
| Given a file or directory name, return the name of the directory it is contained in. | |
| string | FileRead (const string &filename, const char *how="rb") |
| Read a file completely into memory as string. | |
| bool | FileWrite (const string &filename, const string &Content, const char *how="wb") |
| Read a file from memory as string. | |
| unsigned long long | getAvailableMemory () |
| Memory available currently in the system. | |
| std::string | getCurrentDir () |
| Returns the current working directory. | |
| double | getEnvFloat (const char *n, const char *description, double Default=0.0) |
| Get a floating point value from an environment variable. | |
| int | getEnvInteger (const char *n, const char *description, int Default=0) |
| Get an integer from an environment variable. | |
| long | getEnvLong (const char *n, const char *description) |
| Get an long from an environment variable. | |
| std::string | getEnvString (const char *n, const char *description) |
| Get a string value from an environment variable. | |
| std::string | getExecutableDir () |
| Returns the directory the current executable is running in. | |
| unsigned long long | getInitialMemUsage () |
| Memory usage at program start, remember getMemUsage() at global constructor. | |
| unsigned long long | getMemCommitCharge () |
| Commit Charge as used under Windows. | |
| unsigned long long | getMemorySize () |
| Returns the size of physical memory (RAM) in bytes. | |
| unsigned long long | getMemUsage () |
| Memory used by current process. | |
| double | getMemUsageMiB () |
| Convenience function to get memory usage in MB. | |
| unsigned long long | getRelativeMemUsage () |
| Memory usage relative to program start, via getMemUsage() | |
| double | getRelativeMemUsageMiB () |
| Convenience function to get memory usage in MB. | |
| const type_info & | getType (const std::string &s) |
| Get the intrinsic type information of a registered type (see setTypename() ) from its textual description. | |
| MEMCORE_API void | ImmediateExitus (int ExitCode) |
| Forcefully exit the application without any cleanup and skipping any onexit() functions. | |
| template<class A , class Abase , class B , class Bbase > | |
| constexpr bool | operator^ (const DynPtr< A, Abase > &Aptr, const DynPtr< B, Bbase > &Bptr) |
| XOR operator on pointers, allows to check whether exactly one of them is valid. | |
| string | PathOpen (const std::list< string > &path, const string &filename) |
| Find a file out of a list of possible directories. | |
| void | print_stacktrace () |
| Print a stacktrace from the current call location. | |
| bool | setEnv (const char *a, const std::string &value, bool do_overwrite) |
| Set an environment variable, optionally overwriting or not. | |
| unsigned long long | setInitialMemUsage () |
| Set the memory usage base level, should be called in main() | |
| unsigned long long | setInitialMemUsage (unsigned long long) |
| Set the memory usage base level to some given value. | |
| std::string | to_address_string (const void *p) noexcept throw () |
| Provide a pointer as a hexadecimal string. | |
| std::string | to_string (const span< char > &s) |
| Convert a character span to a string, which involves a SLOW copy operation. | |
| MEMCORE_API std::string | Typename (const std::type_info &t) |
| Given some type, return some human-readable platform independent unique short description. | |
Variables | |
| MEMCORE_API refcount_t | CheckRefcountedObjects = 0 |
| The number of currently used reference counted objects. | |
| constexpr std::size_t | dynamic_extent = -1 |
| Copying the definition from C++20 standard. | |
| std::list< std::string > | PathPrefixes |
| A list of possible path prefixes that will be indicated with "%0" etc. | |
Memory Management classes and routines.
The MemCore library provides
"Weak" and "strong" pointers are a natural extension of the native C++ pointer concept. Their semantic is similar to native pointers, but they provide significant improvements:
In contrast to simple reference counting as e.g. implemented via handles in OpenInventor, MemCore allows cyclic references and pointers to non-dynamically allocated (e.g. static or automatic) objects. It does that by utilizing intermediate object referers.
| struct MemCore::AtomicityConfig |
| struct MemCore::BaseChunk |
Computing the right base class for a given element.
It will export a type "result" which is another TypedChunk<>, but of the type's base class, and if and only if the memory layout of the base class is identical to the one of the given type. If not, then the return false is the TypedChunkBase<>, as a base class of all those types.
| T | The type to be inspected. |
| Base | The base class of type T, which is determined from the BaseClass<> type trait. This type trait must exist for the given type, otherwise it will not be detected as a child class. |
| struct MemCore::BaseChunk< T, Base, false > |
Determine the base class for typed chunks of base classes that have another memory layout.
It will be a TypedChunkBase<T> and therefore terminate the derivation tree.
| struct MemCore::BaseChunk< T, Base, true > |
Determine the base class for typed chunks of base classes that have the same memory layout.
It will be another TypedChunk<T>.
| struct MemCore::BaseChunk< T, T, true > |
Determine the base class for typed chunks of base classes.
It will be a TypedChunkBase<T>.
| struct MemCore::ChunkType |
| struct MemCore::MemSizeConfig |
| struct MemCore::MemSizeConfig< 4 > |
| struct MemCore::MemSizeConfig< 8 > |
| class MemCore::NotNullPtr |
A type to specify non-null pointer requirements.
| class MemCore::Referer |
| struct MemCore::ReserveOnly |
Helper class as pseudo-argument for Chunk<> creators.
| struct MemCore::SelfInitialize |
Internal class used as an argument for a computational destructor.
| class MemCore::Span |
Copying the definition from C++20 standard, to provide minimal API until it's fully available, see https://en.cppreference.com/w/cpp/container/span.
| struct MemCore::StreamSaver |
| using MemCore::MultiPtrMap = typedef std::unordered_map<MultiPtrMapKey<KeyObject>, ValueObject, MultiPtrMapHash<KeyObject> > |
Mapping one or multiple pointers to some value.
Example application code:
|
inline |
A custom implementation of std::async which is ensured to make use of a threadpool instead of always starting a new thread, thus this implementation avoids the overhead of thread creation.
The ThreadPool argument should be some instance bound to an object that is destructed before main() ends, i.e., it should not be a static global object - because Windows would destruct its threads first, then the destructor is called which waits forever for no longer existing threads...
| string MemCore::DirName | ( | const string & | file_or_dir_name | ) |
Given a file or directory name, return the name of the directory it is contained in.
The function checks if given filename points to an existing directory, and if so returns the given argument, otherwise it returns the given name cropped until the last directory separator, considering / in any case, and \ in addition under Windows.
References MemCore::StringUtil::crop_after_last().
Referenced by Wizt::createVScript().
| MEMCORE_API string MemCore::FileRead | ( | const string & | filename, |
| const char * | how = "rb" |
||
| ) |
Read a file completely into memory as string.
| filename | The file name, for instance as retrieved by PathOpen(); |
| MEMCORE_API bool MemCore::FileWrite | ( | const string & | filename, |
| const string & | Content, | ||
| const char * | how = "wb" |
||
| ) |
Read a file from memory as string.
| filename | The file name, for instance as retrieved by PathOpen(); |
| MEMCORE_API double MemCore::getEnvFloat | ( | const char * | n, |
| const char * | description, | ||
| double | Default = 0.0 |
||
| ) |
Get a floating point value from an environment variable.
| int MemCore::getEnvInteger | ( | const char * | n, |
| const char * | description, | ||
| int | Default = 0 |
||
| ) |
Get an integer from an environment variable.
If the environment variable SHOW_ENVIRONMENT_CONTROL_VARIABLES is set, then a descriptive information is displayed for each environment variable upon its first possible use, even if it is not set.
Referenced by Wizt::GLRenderer::grab(), and MemCore::Cache::verbosity().
| MEMCORE_API long MemCore::getEnvLong | ( | const char * | n, |
| const char * | description | ||
| ) |
Get an long from an environment variable.
| MEMCORE_API std::string MemCore::getEnvString | ( | const char * | n, |
| const char * | description | ||
| ) |
Get a string value from an environment variable.
Referenced by Wizt::CommandLineParser::getDataDirs().
| MEMCORE_API unsigned long long MemCore::getMemorySize | ( | ) |
Returns the size of physical memory (RAM) in bytes.
http://nadeausoftware.com/articles/2012/09/c_c_tip_how_get_physical_memory_size_system
Referenced by MemCore::Cache::insert().
| string MemCore::PathOpen | ( | const std::list< string > & | path, |
| const string & | filename | ||
| ) |
Find a file out of a list of possible directories.
| MEMCORE_API unsigned long long MemCore::setInitialMemUsage | ( | unsigned long long | ) |
Set the memory usage base level to some given value.
the getRelativeMemUsage() function will be relative to this one.
| MEMCORE_API std::list<std::string> MemCore::PathPrefixes |
A list of possible path prefixes that will be indicated with "%0" etc.
within a PathOpen() call.
%0 is supposed to relate to the program's start path.