Jamoma API  0.6.0.a19
TTEnvironment Class Reference

The global object maintains all global attributes/settings for the Jamoma environment. More...

#include <TTEnvironment.h>

+ Inheritance diagram for TTEnvironment:
+ Collaboration diagram for TTEnvironment:

Public Member Functions

 TTEnvironment ()
 Constructor.
 
virtual ~TTEnvironment ()
 Destructor.
 
TTErr getVersion (const TTValue &anInputValue, TTValue &anOutputValue)
 Retrieve the environment version number. More...
 
TTErr registerClass (const TTSymbol className, const TTString &tagString, const TTObjectBaseInstantiationMethod anInstantiationMethod)
 Register the unit name, and associate it with the constructor to be called. More...
 
TTErr getAllClassNames (const TTValue &anInputValue, TTValue &anOutputValue)
 Remove a class from the environment's registry. More...
 
TTErr getClassNamesWithTags (TTValue &classNames, const TTValue &searchTags)
 Retreive the names of all registered TTObjectBase classes in the environment that are associated with the given tag(s). More...
 
TTErr getClassNamesForTags (const TTValue &anInputValue, TTValue &anOutputValue)
 A message-bound version of getClassNamesWithTags()
 
TTErr isClassRegistered (const TTSymbol &className)
 Check if a class is registered. More...
 
TTErr createInstance (const TTSymbol className, TTObjectBasePtr *anObject, const TTValue &anArgument)
 Create a new instance of a registered TTObjectBase class. More...
 
TTObjectBasePtr referenceInstance (TTObjectBasePtr anObject)
 Create a reference to an object. More...
 
TTErr releaseInstance (TTObjectBasePtr *anObject)
 Release an instance of a TTObjectBase class. More...
 
- Public Member Functions inherited from TTObjectBase
virtual ~TTObjectBase ()
 Destructor.
 
TTUInt16 getReferenceCount ()
 Query an object to get its current reference count. More...
 
TTUInt32 getObserverCount () const
 Query an object to get the number of observers. More...
 
TTErr registerAttribute (const TTSymbol name, const TTDataType type, void *address)
 Register an attribute. More...
 
TTErr extendAttribute (const TTSymbol name, const TTObjectBasePtr extendedObject, const TTSymbol extendedName)
 Extend the attribute of an existing TTObjectBase to this TTObjectBase (using another attribute name) More...
 
TTErr removeAttribute (const TTSymbol name)
 Remove an attribute. More...
 
TTErr findAttribute (const TTSymbol name, TTAttribute **attr)
 Find an attribute. More...
 
TTErr setAttributeValue (const TTSymbol name, TTValue &value)
 Set an attribute value for an object. More...
 
template<class T >
TTErr set (const TTSymbol aName, T aValue)
 Set an attribute value for an object This is the same as calling setAttributeValue(). More...
 
TTErr getAttributeValue (const TTSymbol name, TTValue &value)
 Get an attribute value for an object. More...
 
template<class T >
TTErr get (const TTSymbol aName, T &aReturnedValue)
 Get an attribute value for an object This is the same as calling getAttributeValue(). More...
 
TTSymbol getAttributeType (const TTSymbol name)
 Return the type of an attribute as a symbol. More...
 
TTErr getAttributeGetterFlags (const TTSymbol name, TTAttributeFlags &value)
 Get the getterFlags of an attribute. More...
 
TTErr setAttributeGetterFlags (const TTSymbol name, TTAttributeFlags &value)
 Set the getterFlags of an attribute. More...
 
TTErr getAttributeSetterFlags (const TTSymbol name, TTAttributeFlags &value)
 Get the setterFlags of an attribute. More...
 
TTErr setAttributeSetterFlags (const TTSymbol name, TTAttributeFlags &value)
 Set the setterFlags of an attribute. More...
 
TTErr registerAttributeProperty (const TTSymbol attributeName, const TTSymbol propertyName, const TTValue &initialValue, TTGetterMethod getter, TTSetterMethod setter)
 Register an attribute property. More...
 
TTErr registerMessageProperty (const TTSymbol messageName, const TTSymbol propertyName, const TTValue &initialValue, TTGetterMethod getter, TTSetterMethod setter)
 Register an message property. More...
 
TTErr getAttribute (const TTSymbol name, TTAttributePtr *attributeObject)
 Search for and locate an attribute. More...
 
TTErr getMessage (const TTSymbol name, TTMessagePtr *messageObject)
 Search for and locate a message. More...
 
void getAttributeNames (TTValue &attributeNameList)
 Return a list of names of the available attributes. More...
 
void getMessageNames (TTValue &messageNameList)
 Return a list of names of the available messages. More...
 
TTSymbol getName () const
 Return the name of this class. More...
 
TTErr registerMessage (const TTSymbol name, TTMethod method)
 Register a message with this object. More...
 
TTErr findMessage (const TTSymbol name, TTMessage **message)
 Find a message registered with this object. More...
 
TTErr removeMessage (const TTSymbol name)
 Remove a message. More...
 
TTErr sendMessage (const TTSymbol name)
 TODO: Document this function. More...
 
TTErr registerObserverForMessage (const TTObject &observingObject, const TTSymbol messageName)
 Register an observer for a message. More...
 
TTErr registerObserverForAttribute (const TTObject &observingObject, const TTSymbol attributeName)
 Register an observer for an attribute. More...
 
TTErr registerObserverForNotifications (const TTObject &observingObject)
 Register an observer. More...
 
TTErr unregisterObserverForMessage (const TTObject &observingObject, const TTSymbol messageName)
 Unregister an observer for a message. More...
 
TTErr unregisterObserverForAttribute (const TTObject &observingObject, const TTSymbol attributeName)
 Unregister an observer for an attribute. More...
 
TTErr unregisterObserverForNotifications (const TTObject &observingObject)
 Unregister an observer for notifications. More...
 
TTErr sendNotification (const TTSymbol name, const TTValue &arguments)
 Send a notification. More...
 
TTErr logMessage (TTImmutableCString fmtstring,...)
 Log messages scoped to this object instance. More...
 
TTErr logWarning (TTImmutableCString fmtstring,...)
 Log warnings scoped to this object instance. More...
 
TTErr logError (TTImmutableCString fmtstring,...)
 Log errors scoped to this object instance. More...
 
TTErr logDebug (TTImmutableCString fmtstring,...)
 Log messages (scoped to this object instance) to output only if the basic debugging flag is enabled in the environment. More...
 
TTErr lock ()
 Lock the object in order to ensure thread-safe processing. More...
 
TTErr unlock ()
 Unlock the object when thread-safe processing is no longer required. More...
 
TTBoolean isLocked ()
 Query if the object currently is locked for thread-safe processing. More...
 
TTBoolean waitForLock ()
 If the object is locked (e.g. More...
 

Public Attributes

TTBoolean mDebugBasic
 Attribute: Basic debug functionality is enabled when true.
 
TTBoolean mDebugMessaging
 Attribute: Should all message traffic be logged?
 
TTUInt32 mSampleRate
 Current sample rate as understood by the environment as a whole.
 
TTBoolean mBenchmarking
 Attribute: Enable benchmarking in TTAudioObject and TTDataObject ?
 
- Public Attributes inherited from TTObjectBase
TTBoolean valid
 If the object isn't completely built, or is in the process of freeing, this will be false.
 
TTBoolean track
 enable the print of a log message to ease the track of reference counting mechanism on an instance More...
 

Additional Inherited Members

- Protected Member Functions inherited from TTObjectBase
 TTObjectBase (const TTValue arguments)
 Constructor. More...
 
- Protected Attributes inherited from TTObjectBase
TTList observers
 List of all objects watching this object for life-cycle and other changes.
 

Detailed Description

The global object maintains all global attributes/settings for the Jamoma environment.

All attribute members of the environment are made public, since essentially every class is a friend. They should, however, be treated as read-only.

Definition at line 47 of file TTEnvironment.h.

Member Function Documentation

TTErr TTEnvironment::createInstance ( const TTSymbol  className,
TTObjectBasePtr anObject,
const TTValue anArgument 
)

Create a new instance of a registered TTObjectBase class.

Parameters
classNamePass in a TTSymbol with the name of the unit to load.
anObjectUpon successful return, the value will be set to a TTObjectBase which is the new instance. If the pointer is passed in as non-NULL then createUnit() will try to free to the existing object to which it points prior to instantiating the new unit.
anArgumentFor most audio processing objects, this should be passed the maximum number of channels. For this reason, we overload this method with a TTUint16 argument as a convenience.
Returns
TTErr error code if the method fails to execute, else kTTErrNone.

Definition at line 219 of file TTEnvironment.cpp.

References TTClass::createInstance(), kTTErrGeneric, TTHash::lookup(), and releaseInstance().

Referenced by TTDataObjectBase::TTDataObjectBase(), TTObject::TTObject(), and TTObjectBaseInstantiate().

+ Here is the call graph for this function:

TTErr TTEnvironment::getAllClassNames ( const TTValue anInputValue,
TTValue anOutputValue 
)

Remove a class from the environment's registry.

If the executable from which it is loaded is no longer referenced by other classes, then also unload the executable.

Parameters
classNameThe name of the class to remove the registry.
Returns
An error code. TTErr unregisterClass(const TTSymbolRef className); unload/reload all external classes. NOTE that to do this, we need to keep a piece of information that tags a class as external or internal.

This probably means that the hash is going to need to map not to a function pointer, but rather to a struct or an object that keeps all of the class's information bundled together. TTErr refreshAllClasses();Retreive the names of all registered TTObjectBase classes in the environment.

Parameters
anInputValueThis is not being used.
anOutputValuePass a TTValue that will be filled with an array of TTSymbol pointers with the names of the classes.
Returns
TTErr error code if the method fails to execute, else kTTErrNone.

Definition at line 136 of file TTEnvironment.cpp.

References TTHash::getKeys().

Referenced by TTObject::GetRegisteredClassNames(), TTEnvironment(), and TTGetRegisteredClassNames().

+ Here is the call graph for this function:

TTErr TTEnvironment::getClassNamesWithTags ( TTValue classNames,
const TTValue searchTags 
)

Retreive the names of all registered TTObjectBase classes in the environment that are associated with the given tag(s).

Parameters
classNamesAn array of TTSymbols upon return.
tagsAn array of tags by which to search the environment's registry.
Returns
TTErr error code if the method fails to execute, else kTTErrNone.

Definition at line 157 of file TTEnvironment.cpp.

References TTValue::append(), TTValue::clear(), kTTErrGeneric, kTTErrNone, TTHash::lookup(), and TTValue::size().

Referenced by getClassNamesForTags(), TTObject::GetRegisteredClassNamesForTags(), and TTGetRegisteredClassNamesForTags().

+ Here is the call graph for this function:

TTErr TTEnvironment::getVersion ( const TTValue anInputValue,
TTValue anOutputValue 
)

Retrieve the environment version number.

Parameters
anInputValueThis is ignored.
anOutputValueReturns the current version number of the environment.
Returns
TTErr error code if the method fails to execute, else kTTErrNone.

Definition at line 62 of file TTEnvironment.cpp.

References kTTErrNone.

Referenced by TTEnvironment().

TTErr TTEnvironment::isClassRegistered ( const TTSymbol className)

Check if a class is registered.

Parameters
classNamethe name of a class
Returns
TTErr error code if the class is not registered, else kTTErrNone.

Definition at line 212 of file TTEnvironment.cpp.

References TTHash::lookup().

+ Here is the call graph for this function:

TTObjectBasePtr TTEnvironment::referenceInstance ( TTObjectBasePtr  anObject)

Create a reference to an object.

Definition at line 260 of file TTEnvironment.cpp.

References TTObjectBase::track, TTLogMessage(), and TTObjectBase::valid.

Referenced by TTObject::operator=(), TTObject::TTObject(), and TTObjectBaseReference().

+ Here is the call graph for this function:

TTErr TTEnvironment::registerClass ( const TTSymbol  className,
const TTString tagString,
const TTObjectBaseInstantiationMethod  anInstantiationMethod 
)

Register the unit name, and associate it with the constructor to be called.

Parameters
classNameThe name of the class to register.
tagsA comma-delimited list of tags in a string.
anInstantiationMethodA pointer to the C-function that is used to create a new instance of the class.
Returns
TTErr error code if the method fails to execute, else kTTErrNone.

Definition at line 69 of file TTEnvironment.cpp.

References TTHash::append(), TTSymbol::c_str(), kTTErrValueNotFound, TTHash::lookup(), TTValue::size(), TTValue::transformCSVStringToSymbolArray(), and TTLogDebug().

+ Here is the call graph for this function:

TTErr TTEnvironment::releaseInstance ( TTObjectBasePtr anObject)

Release an instance of a TTObjectBase class.

At the moment this is simply freeing the class, but it may use reference counting in the future (e.g. for TTBuffer references).

There are a couple of reasons we want to have this wrapper around the delete operator.

  • For instrumenting the code to investigate bugs, performance, etc.
  • So that we can handle any threading, spin-locks, mutexes, or other issues before actually freeing the object.
  • At some point we may do a more release-like-thing where we reference count for pseudo-garbage-collection.
Parameters
unitA pointer to the unit to free.
Returns
TTErr error code if the method fails to execute, else kTTErrNone.

Definition at line 281 of file TTEnvironment.cpp.

References kTTErrNone, TTLogMessage(), and TTObjectBase::waitForLock().

Referenced by createInstance(), TTObject::operator=(), TTObjectBaseRelease(), TTDataObjectBase::~TTDataObjectBase(), and TTObject::~TTObject().

+ Here is the call graph for this function:


The documentation for this class was generated from the following files: