implement globally available taggable objects
WIP: A list of globally available TQTaggable objects is desirable to ease and simplify the flow of information and settings. Examples of such objects (or their use cases) include globally available aliases or globally available options.
Suggested implementation: have a static list of TQTaggable objects and retrieval methods like
static TQTaggable* TQTaggable::getGlobalTaggable(const char* name) //returns a pointer to the (global) taggable object corresponding to the given name. Creates a new instance and stores a pointer to it internally if no matching instance is present yet.
static bool TQTaggable::hasGlobalTaggable(const char* name) //Checks if there is already a taggable instance corresponding to the given name
static bool TQTaggable::hasGlobalTaggable(TQTaggable* t) // same as previous one but using the pointer to the TQTaggable instead of its identifier/name
static bool TQTaggable::removeGlobalTaggable(const char* name) //removes a TQTaggable from the internal list (returns false if no matching instance is found)
Notes:
- a TQTaggable::addGlobalTaggable(TQTaggable* t, const char* name) would lead to some situations where ownership management can easily become confusing. If one wants to make information from an existing TQTaggable available globally, one should request a TQTaggable object via getGlobalTaggable and import the tags from the existing one to this one.
TBC:
- what data type should be used for the names? const char*, std::string or TString? -> provide overloads for const char* and TString (as std::string should auto-convert to const char*) and TString is the most commonly used in the existing framework.
Edited by Ralf Gugel