Jamoma API  0.6.0.a19
TTNodeInfo.cpp
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup modularLibrary
4  *
5  * @brief TTNodeInfo provides priority, tag and description for a node.
6  *
7  * @details ...
8  *
9  * @authors Théo de la Hogue
10  *
11  * @copyright © 2014, Théo de la Hogue @n
12  * This code is licensed under the terms of the "New BSD License" @n
13  * http://creativecommons.org/licenses/BSD/
14  */
15 
16 
17 #include "TTNodeInfo.h"
18 
19 #define thisTTClass TTNodeInfo
20 #define thisTTClassName "NodeInfo"
21 #define thisTTClassTags "node info"
22 
23 TT_MODULAR_CONSTRUCTOR,
24 mDescription(kTTSym_none),
25 mPriority(0),
26 mTags(TTValue(kTTSym_none))
27 {
30  addAttributeWithSetter(Description, kTypeSymbol);
31 }
32 
33 TTNodeInfo::~TTNodeInfo()
34 {
35  ;
36 }
37 
38 TTErr TTNodeInfo::setDescription(const TTValue& value)
39 {
40  TTValue n = value; // use new value to protect the attribute
41  mDescription = value;
42 
43  this->notifyObservers(kTTSym_description, n);
44  return kTTErrNone;
45 }
46 
47 TTErr TTNodeInfo::setPriority(const TTValue& value)
48 {
49  TTValue n = value; // use new value to protect the attribute
50  mPriority = value;
51 
52  this->notifyObservers(kTTSym_priority, n);
53  return kTTErrNone;
54 }
55 
56 TTErr TTNodeInfo::setTags(const TTValue& value)
57 {
58  TTValue n = value; // use new value to protect the attribute
59  mTags = value;
60  this->notifyObservers(kTTSym_tags, n);
61  return kTTErrNone;
62 }
63 
64 TTErr TTNodeInfo::notifyObservers(TTSymbol attrName, const TTValue& value)
65 {
66  TTAttributePtr anAttribute = NULL;
67  TTErr err;
68 
69  err = this->findAttribute(attrName, &anAttribute);
70 
71  if (!err)
72  anAttribute->sendNotification(kTTSym_notify, value); // we use kTTSym_notify because we know that observers are TTCallback
73 
74  return kTTErrNone;
75 }
TTErr sendNotification(const TTSymbol name, const TTValue &arguments)
Send a notification.
This class represents a single attribute, as used by the TTObjectBase class.
Definition: TTAttribute.h:79
Symbol type.
Definition: TTBase.h:282
This is a special type used by TTAttribute to indicate that a value is a TTValue and is locally maint...
Definition: TTBase.h:286
TTNodeInfo provides priority, tag and description for a node.
The TTSymbol class is used to represent a string and efficiently pass and compare that string...
Definition: TTSymbol.h:26
32-bit signed integer, range is -2,147,483,648 through 2,147,483,647.
Definition: TTBase.h:277
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
Definition: TTBase.h:342
#define addAttributeWithSetter(name, type)
A convenience macro to be used by subclasses for registering attributes with a custom setter...
Definition: TTAttribute.h:47
No Error.
Definition: TTBase.h:343
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34
TTErr findAttribute(const TTSymbol name, TTAttribute **attr)
Find an attribute.