Jamoma API  0.6.0.a19
TTClass.cpp
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup foundationLibrary
4  *
5  * @brief The TTClass object represents a class in the Jamoma environment.
6  *
7  * @details This is to say that it represents everything about a class except for the class itself,
8  * which is a subclass of TTObjectBase.
9  *
10  * @todo: We could override the () operator to make TTClass a functor for creating instances.
11  *
12  * @author Timothy Place, Trond Lossius
13  *
14  * @copyright Copyright © 2008, Timothy Place @n
15  * This code is licensed under the terms of the "New BSD License" @n
16  * http://creativecommons.org/licenses/BSD/
17  */
18 
19 #include "TTClass.h"
20 
21 
22 /****************************************************************************************************/
23 
24 TTClass::TTClass(const TTSymbol className, const TTValue& tagList, const TTObjectBaseInstantiationMethod anInstantiationMethod)
25  : name(className), tags(tagList), instantiationMethod(anInstantiationMethod), external(false)
26 {
27  ;
28 }
29 
30 
32 {
33 
34 }
35 
36 
37 TTErr TTClass::createInstance(TTObjectBase** anObject, const TTValue& anArgument)
38 {
39  TTErr err = kTTErrNone;
40 
41  try {
42  *anObject = instantiationMethod(name, anArgument);
43  }
44  catch (...) {
45  TTLogError("Exception thrown trying to create TTClass %s\n", name.c_str());
46  err = kTTErrAllocFailed;
47  }
48 
49  //TT_ASSERT(create_instance_successful, err == kTTErrNone);
50  return err;
51 }
52 
53 
55 {
56  delete anObject;
57  return kTTErrNone;
58 }
59 
TTClass(const TTSymbol className, const TTValue &tags, const TTObjectBaseInstantiationMethod anInstantiationMethod)
Constructor method.
Definition: TTClass.cpp:24
Couldn't get memory.
Definition: TTBase.h:345
The TTClass object represents a class in the Jamoma environment.
Base class for all first-class Jamoma objects.
Definition: TTObjectBase.h:109
TTObjectBase *(* TTObjectBaseInstantiationMethod)(TTSymbol className, const TTValue arguments)
A function pointer for an instance creation function required to be provided by all classes...
Definition: TTEnvironment.h:29
The TTSymbol class is used to represent a string and efficiently pass and compare that string...
Definition: TTSymbol.h:26
void TTFOUNDATION_EXPORT TTLogError(TTImmutableCString message,...)
Platform and host independent method for posting errors.
Definition: TTBase.cpp:572
const char * c_str() const
Return a pointer to the internal string as a C-string.
Definition: TTSymbol.h:77
TTErr releaseInstance(TTObjectBase *anObject)
Free an instance of a TTObjectBase class.
Definition: TTClass.cpp:54
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
Definition: TTBase.h:342
No Error.
Definition: TTBase.h:343
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34
TTErr createInstance(TTObjectBase **anObject, const TTValue &anArgument)
Create a new instance of a registered TTObjectBase class.
Definition: TTClass.cpp:37
virtual ~TTClass()
Destructor.
Definition: TTClass.cpp:31