The Vish Visualization Shell 0.3
Vish
MemCore Namespace Reference

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...
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...
struct  ExecutableInfo
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  list
 STL class. More...
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
class  string
 STL class. More...
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, CacheableCacheablePtr
 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_tsockets_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

std::string addrstr () const
 make a string containing hex numbers from the object's adress.
stringappendProvenance (const RefPtr< Provenance > &P)
 Append a Provenance object.
stringappendProvenance (const string &s)
 Append a provenance information string.
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).
 Creature (const WCachePtr &myCache)
 Constructor, keeps track of the cache, but does NOT insert this object into the Cache.
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.
virtual bool discardCreation ()
 Asynchron mode: aha.
void enableCaching (bool CreateAsOld=false) const
 Insert the available Cacheable object, as retrieved by the getCacheable() function to the Cache associated with this Creator.
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.
virtual CacheablePtr getCacheable () const =0
 Get a pointer to the associated cacheable object, if such is available in a child class.
std::vector< std::string > getCommandLineArguments (int argc, const char **argv)
 Get the command line arguments in an UTF8/UTF16-safe manner which otherwise is an issue under Windows.
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.
RefPtr< ProvenancegetFirstCreationSource () const
 Retrieve the first creation source if there are any defined.
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.
virtual bool hasData () const
 Query whether data exist here.
virtual std::string hasProducer () const
 Query some more info about the kind of re-production facility associated with this creature.
MEMCORE_API void ImmediateExitus (int ExitCode)
 Forcefully exit the application without any cleanup and skipping any onexit() functions.
virtual bool isReproducible () const
 Query whether this Creature can be reproduced (i.e., be created again ) after release().
virtual bool isUnderCreation () const
 Asynchron mode: check if the requested data are just under creation.
const WCachePtr & myCache () const
 Return the associated Cache object.
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 register_named_verb (const std::string &progID, const std::string &verb, const std::string &label, const std::string &exePath, const std::string &argSpec)
 Register a single named verb under the ProgID so Explorer shows it (e.g., "Edit in Vish").
bool register_verbs (const std::string &exePath, const std::string &exeName, const std::string &fileExtension, const std::string &progID, const std::vector< std::string > &verbs, std::function< std::string(std::string)> MenuEntryForVerb, std::function< std::string(std::string)> CommandEntryForVerb, const std::string &progDisplayName="")
 Register file-type and application verbs for a given extension.
virtual ReasonForReleasal release ()=0
 Query the object to release as much memory as it can.
template<class RefType>
ReasonForReleasal releasePtr (RefPtr< RefType > &Data) const
 Template helper function to release a data pointer in a derived class.
void resetStatistics ()
 Reset statistic info, creation times and number of creations.
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.
stringsetProvenance (const RefPtr< Provenance > &P)
 Append provenance information.
stringsetProvenance (const string &s)
 Overwrite latest provenance information.
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.
virtual ~Creature ()=0
 Destructor (virtual).

Variables

MEMCORE_API refcount_t CheckRefcountedObjects = 0
 The number of currently used reference counted objects.
std::string creationError
 Indicator of possible creation errors.
constexpr std::size_t dynamic_extent = -1
 Copying the definition from C++20 standard.
std::list< RefPtr< Provenance > > myCreationSources
 An abstract base class for object creators.
std::list< std::string > PathPrefixes
 A list of possible path prefixes that will be indicated with "%0" etc.

Detailed Description

Memory Management classes and routines.

The MemCore library provides

  • weak and strong pointers, i.e. allows reference counted garbage collection with manually controlled cycles
  • simplified downcasting of pointers
  • runtime-determined multiple inheritance via dynamic interfaces
  • cache management with prioritized queueing
  • transparent delayed on-demand procedural creation of objects The MemCore library is kept as simple as possible to provide only core services that might be central to a broad range of applications. It is a top-level library in that it does not require any other libraries.

"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:

  • A "weak pointer" is a pointer that has knowledge about the lifetime of the referenced objects. If the object is destructed, then the weak pointer becomes NULL (in contrast to a native pointer which is unchanged when the referred object is destructed).
  • A "strong pointer" keeps the referenced object alive as long as the pointer itself lives. This is commonly known as reference counting. Here, a strong pointer is also a weak pointer, i.e. if the object in charge is destroyed (e.g. the lifetime of an automatic object has expired or the object has been explicitely deleted), then the pointer becomes NULL. This allows mixing of pointers to dynamically and automatically/static allocated objects.
  • The C++ dynamic_cast<> operations allows to assign a base class to a pointer of a derived class. Its syntax requires the type name twice, which is an unneccesary inconvenience, because the type of the left-hand-side is already known in assignments or function paramaters. MemCore's weak and strong pointers allow dynamic_cast<> operations during construction and assignment from compatible class pointers. "compatible" means that they have the same base class, which is defined via class ReferenceBase<>. All objects that may be used via MemCore pointers must be derived from template class ReferenceBase<> instantiated over a common base type.

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.


Class Documentation

◆ MemCore::AtomicityConfig

struct MemCore::AtomicityConfig
template<AtomicityConfigSelection, int Bits>
struct MemCore::AtomicityConfig< AtomicityConfigSelection, Bits >

◆ MemCore::BaseChunk

struct MemCore::BaseChunk
template<typename T, typename Base = typename META::BaseClass<T>::result, bool HasSameSize = (sizeof(T) == sizeof(Base) )>
struct MemCore::BaseChunk< T, Base, HasSameSize >

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.

Parameters
TThe type to be inspected.
BaseThe 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 A
{
int i;
};
struct B : A
{
};
template <>
struct BaseClass<B>
{
typedef A result;
};
Definition RefPtrPerformance.cpp:24

◆ MemCore::BaseChunk< T, Base, false >

struct MemCore::BaseChunk< T, Base, false >
template<typename T, typename Base>
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.

◆ MemCore::BaseChunk< T, Base, true >

struct MemCore::BaseChunk< T, Base, true >
template<typename T, typename Base>
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>.

◆ MemCore::BaseChunk< T, T, true >

struct MemCore::BaseChunk< T, T, true >
template<typename T>
struct MemCore::BaseChunk< T, T, true >

Determine the base class for typed chunks of base classes.

It will be a TypedChunkBase<T>.

◆ MemCore::ChunkType

struct MemCore::ChunkType

◆ MemCore::ExecutableInfo

struct MemCore::ExecutableInfo

◆ MemCore::MemSizeConfig

struct MemCore::MemSizeConfig
template<int bits>
struct MemCore::MemSizeConfig< bits >

◆ MemCore::MemSizeConfig< 4 >

struct MemCore::MemSizeConfig< 4 >

◆ MemCore::MemSizeConfig< 8 >

struct MemCore::MemSizeConfig< 8 >

◆ MemCore::NotNullPtr

class MemCore::NotNullPtr

A type to specify non-null pointer requirements.

◆ MemCore::Referer

class MemCore::Referer
template<class Object>
class MemCore::Referer< Object >

◆ MemCore::ReserveOnly

struct MemCore::ReserveOnly

Helper class as pseudo-argument for Chunk<> creators.

◆ MemCore::SelfInitialize

struct MemCore::SelfInitialize

Internal class used as an argument for a computational destructor.

◆ MemCore::Span

class MemCore::Span
template<class T, std::size_t Extent = dynamic_extent>
class MemCore::Span< T, Extent >

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.

◆ MemCore::StreamSaver

struct MemCore::StreamSaver

Typedef Documentation

◆ MultiPtrMap

template<class KeyObject, class ValueObject>
using MemCore::MultiPtrMap = std::unordered_map<MultiPtrMapKey<KeyObject>, ValueObject, MultiPtrMapHash<KeyObject> >

Mapping one or multiple pointers to some value.

Example application code:

#include "Creature.hpp"
int mapCreatures()
{
TM[ {A,B} ] = 56;
int R = TM[ {A,B} ];
return R;
}
StrongPtr< Object, ObjectBase > RefPtr
Convenience template typedef to use RefPtr instead of StrongPtr.
Definition RefPtr.hpp:776
std::unordered_map< MultiPtrMapKey< KeyObject >, ValueObject, MultiPtrMapHash< KeyObject > > MultiPtrMap
Mapping one or multiple pointers to some value.
Definition MultiPtrMap.hpp:51

Function Documentation

◆ async()

template<typename F, typename... Args>
auto MemCore::async ( ThreadPool & thePool,
F && f,
Args &&... args )
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...

◆ Creature()

MemCore::Creature ( const WCachePtr & myCache)

Constructor, keeps track of the cache, but does NOT insert this object into the Cache.

This has to be done later, once a Creator has been associated and externally referenced, using the enableCaching() function.

References myCache().

◆ DirName()

MEMCORE_API 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().

◆ discardCreation()

bool Creature::discardCreation ( )
virtual

Asynchron mode: aha.

Data are under creation, but we don't want them any longer. Soo... cancel this creation request. Hopefully that works.

Referenced by isUnderCreation().

◆ enableCaching()

void Creature::enableCaching ( bool CreateAsOld = false) const

Insert the available Cacheable object, as retrieved by the getCacheable() function to the Cache associated with this Creator.

This function must be called in a derived create() function if a new data object has been allocated.

This function may throw an exception if the associated Cache decides to do so.

Parameters
CreateAsOldA rarely used parameter to insert the current object as the oldest one instead of being the newest. Such allows insertion of temporary objects. This may be required to avoid infinite recursions when creating new objects that require temporary creation of other objects.

That is ok, because enableCaching() may also be called for freshly constructed creators with no data yet.

References getCacheable(), and myCache().

Referenced by MemCore::CreatorBase< Domain >::create(), getCacheable(), Wizt::AnemoneCreator< AnemoneInitializer >::produce(), Wizt::VBOCreator::produce(), and MemCore::Creator< Object, MyCreatorBase >::supersede().

◆ FileRead()

MEMCORE_API string MemCore::FileRead ( const string & filename,
const char * how = "rb" )

Read a file completely into memory as string.

Parameters
filenameThe file name, for instance as retrieved by PathOpen();

◆ FileWrite()

MEMCORE_API bool MemCore::FileWrite ( const string & filename,
const string & Content,
const char * how = "wb" )

Read a file from memory as string.

Parameters
filenameThe file name, for instance as retrieved by PathOpen();

◆ getEnvFloat()

MEMCORE_API double MemCore::getEnvFloat ( const char * n,
const char * description,
double Default = 0.0 )

Get a floating point value from an environment variable.

See also
getEnvInteger

◆ getEnvInteger()

MEMCORE_API 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().

◆ getEnvLong()

MEMCORE_API long MemCore::getEnvLong ( const char * n,
const char * description )

Get an long from an environment variable.

See also
getEnvInteger

◆ getEnvString()

MEMCORE_API std::string MemCore::getEnvString ( const char * n,
const char * description )

Get a string value from an environment variable.

See also
getEnvInteger

Referenced by Wizt::CommandLineParser::getDataDirs().

◆ getMemorySize()

MEMCORE_API unsigned long long MemCore::getMemorySize ( )

◆ hasProducer()

virtual std::string MemCore::hasProducer ( ) const
virtual

Query some more info about the kind of re-production facility associated with this creature.

An empty string if no such re-production is not possible. Even with a re-production capability, isReproducible() may still return false due to certain circumstances.

References hasProducer().

Referenced by hasProducer().

◆ isUnderCreation()

virtual bool MemCore::isUnderCreation ( ) const
virtual

Asynchron mode: check if the requested data are just under creation.

If this returns true, then the create() function will return block - better not ask the create() function, as we know than that this creator is already busy.

By default, returns false, meaning that data are just there OR they are not currently under creation, so the create() function would block when called.

The recommended behavior when returned true is to skip this very Creature, do something else in the meantime, and query it again sometime later.

References discardCreation(), and isUnderCreation().

Referenced by isUnderCreation().

◆ PathOpen()

MEMCORE_API string MemCore::PathOpen ( const std::list< string > & path,
const string & filename )

Find a file out of a list of possible directories.

Returns
The full filename.

◆ register_named_verb()

MEMCORE_API bool MemCore::register_named_verb ( const std::string & progID,
const std::string & verb,
const std::string & label,
const std::string & exePath,
const std::string & argSpec )

Register a single named verb under the ProgID so Explorer shows it (e.g., "Edit in Vish").

The caller iterates over verbs externally.

Parameters
progIDThe ProgID owning the file type (e.g. "VishVisualizationShell").
verbInternal verb name (e.g. "EditInVish").
labelMenu label shown in Explorer (e.g. "Edit in Vish").
exePathFull normalized path to the application.
argSpecArgument pattern, e.g. "\"Edit<%1>\"" or simply "\"%1\"".
Returns
true on success, false on registry write failure.

◆ register_verbs()

MEMCORE_API bool MemCore::register_verbs ( const std::string & exePath,
const std::string & exeName,
const std::string & fileExtension,
const std::string & progID,
const std::vector< std::string > & verbs,
std::function< std::string(std::string)> MenuEntryForVerb,
std::function< std::string(std::string)> CommandEntryForVerb,
const std::string & progDisplayName = "" )

Register file-type and application verbs for a given extension.

Writes .ext\OpenWithProgids, ProgID\shell<verb>\command and Applications<exe>\shell<verb>\command under HKCU, normalizes exePath, calls SHChangeNotify to refresh the shell, and is idempotent. Returns true on success, false on invalid inputs or write failure.

◆ release()

virtual ReasonForReleasal MemCore::release ( )
pure virtual

Query the object to release as much memory as it can.

Return false if the memory could not be released. In this case, the object remains in the queue.

References release().

Referenced by release().

◆ releasePtr()

template<class RefType>
ReasonForReleasal MemCore::releasePtr ( RefPtr< RefType > & Data) const

Template helper function to release a data pointer in a derived class.

This function checks if there is only one strong reference to the given data pointer, and if so, set the pointer to NullPtr() which is supposed to delete the data object. If there is more than one strong reference pointer, then the type temporarily_unreleasable will be returned as ReasonForReleasal, because setting the data pointer to null would not release the data. The calling function is then supposed to try releasing the data again once those external strong references have been removed.

References releasePtr().

Referenced by Wizt::TextureCreator::release(), and releasePtr().

◆ setInitialMemUsage()

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.

Returns
The previous base level.

◆ setProvenance()

string & Creature::setProvenance ( const RefPtr< Provenance > & P)

Append provenance information.

Return string property of the provided provenance.

References myCreationSources.

Variable Documentation

◆ creationError

std::string MemCore::creationError

Indicator of possible creation errors.

An error happened during creation if this string is non-empty.

◆ PathPrefixes

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.