Develop Biology
The language of life
|
#include <Perspective.h>
Classes | |
class | Hadit |
Public Types | |
typedef std::vector< Hadit > | Hadits |
typedef DIMENSION | Id |
typedef std::vector< Id > | Ids |
Public Member Functions | |
Perspective () | |
virtual | ~Perspective () |
virtual bool | AssociateType (Id id, Wave *type) |
virtual bool | DisassociateType (Id id) |
Hadits::iterator | Find (Id id) |
Hadits::const_iterator | Find (Id id) const |
virtual Id | GetIdFromName (Name name) |
virtual Id | GetIdWithoutCreation (Name name) const |
virtual Name | GetNameFromId (Id id) const |
virtual Wave * | GetNewObjectFromId (Id id) const |
template<typename T > | |
T | GetNewObjectFromIdAs (Id id) |
virtual Wave * | GetNewObjectFromName (Name name) |
template<typename T > | |
T | GetNewObjectFromNameAs (Name name) |
virtual Id | GetNumUsedIds () const |
virtual const Wave * | GetTypeFromId (Id id) const |
template<typename T > | |
const T | GetTypeFromIdAs (Id id) const |
virtual const Wave * | GetTypeFromName (Name name) const |
template<typename T > | |
const T | GetTypeFromNameAs (Name name) const |
virtual Id | GetUniqueIdFor (Name name) |
Public Member Functions inherited from bio::ThreadSafe | |
ThreadSafe () | |
ThreadSafe (const ThreadSafe &toCopy) | |
virtual | ~ThreadSafe () |
void | LockThread () const |
void | UnlockThread () const |
Static Public Member Functions | |
static Id | InvalidId () |
static Name | InvalidName () |
Protected Attributes | |
Hadits | m_hadits |
Id | m_nextId |
A Perspective keeps track of Names and Ids for a certain set of objects within a DIMENSION and ensures a unique Id <-> Name pairing for all objects it "observes". A DIMENSION is a numeric space in which objects may be defined. The size of the space determines how many objects may be "observed" (i.e. kept track of) by a single Perspective. Together, a Perspective and DIMENSION can be thought to define the "size" of the "lens" used to "observe" "objects", if you'll permit the physical analogy of what is purely imaginative. Only objects that share a DIMENSION may be derived from, combined, etc. You cannot have a child class that derives from 2 different Identifiable templates (without solving diamond inheritance and some other caveats). Thus, functionally, you can think of each DIMENSION as a different library, with its source code hidden, such that only objects within that library, that DIMENSION, may inherit from each other. An example DIMENSION would be uint32_t, with up to 4,294,967,295 unique object names per perspective.
An example use case can be seen with Neurons and Synapses. Both are distinct objects and both can be tracked through different Perspectives. This means a Neuron of Id 1 can have the name "MyNeuron" and a Synapse of Id 1 can have the name "MySynapse". However, Neurons and Synapses share a lot of code and should exist within the same DIMENSION (e.g. in case you wanted to make some strange Neuron/Synapse hybrid). If your DIMENSION is a uint8_t, you could have 255 Neurons and 255 Synapses using a different Perspective for each. Using a single Respective, you could only have 255 uniquely identified Neurons OR Connections, total. Therefore, you'd likely want multiple Perspectives and a much larger DIMENSION (uint32_t, for instance) in order to accommodate a more total objects. See below for a macro for creating singleton of Perspectives.
Definition at line 70 of file Perspective.h.
typedef std::vector< Hadit > bio::physical::Perspective< DIMENSION >::Hadits |
Definition at line 101 of file Perspective.h.
typedef DIMENSION bio::physical::Perspective< DIMENSION >::Id |
Definition at line 74 of file Perspective.h.
typedef std::vector< Id > bio::physical::Perspective< DIMENSION >::Ids |
Definition at line 75 of file Perspective.h.
|
inline |
Definition at line 106 of file Perspective.h.
|
inlinevirtual |
Definition at line 115 of file Perspective.h.
References bio::physical::PerspectiveUtilities::Delete(), bio::ThreadSafe::LockThread(), bio::physical::Perspective< DIMENSION >::m_hadits, and bio::ThreadSafe::UnlockThread().
|
inlinevirtual |
Associates the given Wave type with the given id. This is only necessary if you want to use GetTypeFromId later on. NOTE: There is no GetIdFromType(). For that behavior, see chemical::PeriodicTable and chemical::Atom.
id | |
type |
Definition at line 354 of file Perspective.h.
References BIO_SANITIZE, bio::physical::PerspectiveUtilities::Clone(), bio::physical::Perspective< DIMENSION >::Find(), bio::ThreadSafe::LockThread(), bio::physical::Perspective< DIMENSION >::m_hadits, and bio::ThreadSafe::UnlockThread().
|
inlinevirtual |
Removes the type association created by AssociateType().
id |
Definition at line 379 of file Perspective.h.
References BIO_SANITIZE_AT_SAFETY_LEVEL_2, bio::physical::PerspectiveUtilities::Delete(), bio::physical::Perspective< DIMENSION >::Find(), bio::ThreadSafe::LockThread(), bio::physical::Perspective< DIMENSION >::m_hadits, and bio::ThreadSafe::UnlockThread().
|
inline |
Gives an iterator fos the given id.
id |
Definition at line 162 of file Perspective.h.
References bio::ThreadSafe::LockThread(), bio::physical::Perspective< DIMENSION >::m_hadits, and bio::ThreadSafe::UnlockThread().
Referenced by bio::physical::Perspective< DIMENSION >::AssociateType(), bio::physical::Perspective< DIMENSION >::DisassociateType(), bio::physical::Perspective< DIMENSION >::GetNameFromId(), and bio::physical::Perspective< DIMENSION >::GetTypeFromId().
|
inline |
Gives an iterator fos the given id.
id |
Definition at line 187 of file Perspective.h.
References bio::ThreadSafe::LockThread(), bio::physical::Perspective< DIMENSION >::m_hadits, and bio::ThreadSafe::UnlockThread().
|
inlinevirtual |
This will create a new Id for the given name if one does not exist.
name |
Definition at line 212 of file Perspective.h.
References bio::string::CloneInto(), bio::physical::Perspective< DIMENSION >::GetIdWithoutCreation(), bio::physical::Perspective< DIMENSION >::InvalidId(), bio::physical::Perspective< DIMENSION >::InvalidName(), bio::ThreadSafe::LockThread(), bio::physical::Perspective< DIMENSION >::m_hadits, bio::physical::Perspective< DIMENSION >::m_nextId, and bio::ThreadSafe::UnlockThread().
Referenced by bio::physical::Perspective< DIMENSION >::GetNewObjectFromName(), bio::chemical::LinearMotif< CONTENT_TYPE >::GetOrCreateByNameImplementation(), bio::physical::Perspective< DIMENSION >::GetUniqueIdFor(), and bio::genetic::Plasmid::TranscribeFor().
|
inlinevirtual |
the same as GetIdFromName but will RETURN 0 instead of making a new association, if name is not found.
name |
Definition at line 310 of file Perspective.h.
References bio::physical::Perspective< DIMENSION >::InvalidId(), bio::physical::Perspective< DIMENSION >::InvalidName(), and bio::physical::Perspective< DIMENSION >::m_hadits.
Referenced by bio::physical::Perspective< DIMENSION >::GetIdFromName(), bio::physical::Perspective< DIMENSION >::GetTypeFromName(), and bio::physical::Perspective< DIMENSION >::GetUniqueIdFor().
|
inlinevirtual |
This requires that the Id has been previously associated with the name, perhaps from a call to GetIdFromName.
id |
Definition at line 253 of file Perspective.h.
References bio::physical::Perspective< DIMENSION >::Find(), bio::physical::Perspective< DIMENSION >::InvalidId(), bio::physical::Perspective< DIMENSION >::InvalidName(), and bio::physical::Perspective< DIMENSION >::m_hadits.
|
inlinevirtual |
Creates a new object by Clone()ing the associated type.
id |
Definition at line 430 of file Perspective.h.
References bio::physical::PerspectiveUtilities::Clone(), and bio::physical::Perspective< DIMENSION >::GetTypeFromId().
Referenced by bio::physical::Perspective< DIMENSION >::GetNewObjectFromIdAs(), and bio::physical::Perspective< DIMENSION >::GetNewObjectFromName().
|
inline |
Ease of use method for casting the result of GetNewObjectFromId()
T |
id |
Definition at line 485 of file Perspective.h.
References BIO_SANITIZE_WITH_CACHE, BIO_SINGLE_ARG, and bio::physical::Perspective< DIMENSION >::GetNewObjectFromId().
|
inlinevirtual |
Creates a new object by Clone()ing the associated type.
name |
Definition at line 445 of file Perspective.h.
References bio::physical::Perspective< DIMENSION >::GetIdFromName(), and bio::physical::Perspective< DIMENSION >::GetNewObjectFromId().
Referenced by bio::physical::Perspective< DIMENSION >::GetNewObjectFromNameAs().
|
inline |
Ease of access method for casting the result of GetNewObjectFromName()
T |
name |
Definition at line 499 of file Perspective.h.
References BIO_SANITIZE_WITH_CACHE, BIO_SINGLE_ARG, and bio::physical::Perspective< DIMENSION >::GetNewObjectFromName().
|
inlinevirtual |
Definition at line 340 of file Perspective.h.
References bio::physical::Perspective< DIMENSION >::m_nextId.
|
inlinevirtual |
Only works if AssociateType has been called with the given id.
id |
Definition at line 402 of file Perspective.h.
References BIO_SANITIZE, bio::physical::Perspective< DIMENSION >::Find(), bio::physical::Perspective< DIMENSION >::InvalidId(), and bio::physical::Perspective< DIMENSION >::m_hadits.
Referenced by bio::physical::Perspective< DIMENSION >::GetNewObjectFromId(), bio::physical::Perspective< DIMENSION >::GetTypeFromIdAs(), and bio::physical::Perspective< DIMENSION >::GetTypeFromName().
|
inline |
Ease of access method for casting the result of GetTypeFromId().
T |
id |
Definition at line 457 of file Perspective.h.
References BIO_SANITIZE_WITH_CACHE, BIO_SINGLE_ARG, and bio::physical::Perspective< DIMENSION >::GetTypeFromId().
|
inlinevirtual |
Only works if AssociateType has been called with the given id.
name |
Definition at line 420 of file Perspective.h.
References bio::physical::Perspective< DIMENSION >::GetIdWithoutCreation(), and bio::physical::Perspective< DIMENSION >::GetTypeFromId().
Referenced by bio::physical::Perspective< DIMENSION >::GetTypeFromNameAs().
|
inline |
Ease of access method for casting the result of GetTypeFromId().
T |
name |
Definition at line 471 of file Perspective.h.
References BIO_SANITIZE_WITH_CACHE, BIO_SINGLE_ARG, and bio::physical::Perspective< DIMENSION >::GetTypeFromName().
|
inlinevirtual |
There can be up to 256 additional names.
name |
Definition at line 274 of file Perspective.h.
References bio::physical::Perspective< DIMENSION >::GetIdFromName(), bio::physical::Perspective< DIMENSION >::GetIdWithoutCreation(), bio::physical::Perspective< DIMENSION >::InvalidId(), and bio::physical::Perspective< DIMENSION >::InvalidName().
|
inlinestatic |
When overloading other methods of *this, make sure to check your inputs for invalid Ids. See the functions below for examples.
Definition at line 143 of file Perspective.h.
Referenced by bio::physical::Perspective< DIMENSION >::GetIdFromName(), bio::physical::Perspective< DIMENSION >::GetIdWithoutCreation(), bio::physical::Perspective< DIMENSION >::GetNameFromId(), bio::physical::Perspective< DIMENSION >::GetTypeFromId(), and bio::physical::Perspective< DIMENSION >::GetUniqueIdFor().
|
inlinestatic |
When overloading other methods of *this, make sure to check your inputs for invalid Names. See the functions below for examples.
Definition at line 152 of file Perspective.h.
Referenced by bio::physical::Perspective< DIMENSION >::GetIdFromName(), bio::physical::Perspective< DIMENSION >::GetIdWithoutCreation(), bio::physical::Perspective< DIMENSION >::GetNameFromId(), and bio::physical::Perspective< DIMENSION >::GetUniqueIdFor().
|
protected |
Definition at line 508 of file Perspective.h.
Referenced by bio::physical::Perspective< DIMENSION >::~Perspective(), bio::physical::Perspective< DIMENSION >::AssociateType(), bio::physical::Perspective< DIMENSION >::DisassociateType(), bio::physical::Perspective< DIMENSION >::Find(), bio::physical::Perspective< DIMENSION >::GetIdFromName(), bio::physical::Perspective< DIMENSION >::GetIdWithoutCreation(), bio::physical::Perspective< DIMENSION >::GetNameFromId(), and bio::physical::Perspective< DIMENSION >::GetTypeFromId().
|
protected |
Definition at line 509 of file Perspective.h.
Referenced by bio::physical::Perspective< DIMENSION >::GetIdFromName(), and bio::physical::Perspective< DIMENSION >::GetNumUsedIds().