Jamoma API  0.6.0.a19
TTDictionaryAppend.cpp
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup graphDictionaryLib
4  *
5  * @brief Object that appends keys/values to a dictionary
6  *
7  * @details
8  *
9  * @authors Timothy Place
10  *
11  * @copyright Copyright © 2010 by Timothy Place @n
12  * This code is licensed under the terms of the "New BSD License" @n
13  * http://creativecommons.org/licenses/BSD/
14  */
15 
16 #include "TTDictionaryAppend.h"
17 
18 #define thisTTClass TTDictionaryAppend
19 #define thisTTClassName "dictionary.append"
20 #define thisTTClassTags "dictionary, graph"
21 
22 
24  mKey(kTTSymEmpty),
25  mValue(NULL)
26 {
27  mValue = new TTValue(0);
28 
30  addAttributeWithGetterAndSetter(Value, kTypeSymbol); // TODO: make this a generic TTValue
31  addMessageWithArguments(dictionary);
32 }
33 
34 
35 // Destructor
36 TTDictionaryAppend::~TTDictionaryAppend()
37 {
38  ;
39 }
40 
41 
42 TTErr TTDictionaryAppend::dictionary(const TTValue& input, TTValue& output)
43 {
44  TTDictionary d;
45 
46  if (input[0].type() == kTypeDictionary) {
47  d = input[0];
48  d.remove(mKey);
49  d.append(mKey, *mValue);
50  output[0] = d;
51  return kTTErrNone;
52  }
53  return kTTErrInvalidValue;
54 }
55 
56 
57 TTErr TTDictionaryAppend::getKey(TTValue& newValue)
58 {
59  newValue = mKey;
60  return kTTErrNone;
61 }
62 
63 
64 TTErr TTDictionaryAppend::setKey(const TTValue& newValue)
65 {
66  mKey = newValue;
67  return kTTErrNone;
68 }
69 
70 
71 TTErr TTDictionaryAppend::getValue(TTValue& newValue)
72 {
73  newValue = (*mValue);
74  return kTTErrNone;
75 }
76 
77 
78 TTErr TTDictionaryAppend::setValue(const TTValue& newValue)
79 {
80  (*mValue) = newValue;
81  return kTTErrNone;
82 }
An inappropriate value was specified for an attribute or variable.
Definition: TTBase.h:349
TTErr append(const TTSymbol aKey, const TTValue aValue)
Insert an item into the hash table.
Definition: TTDictionary.h:212
Dictionary type.
Definition: TTBase.h:288
Symbol type.
Definition: TTBase.h:282
A type that represents the key as a C-String and the value as a pointer to the matching TTSymbol obje...
Definition: TTDictionary.h:47
Object that appends keys/values to a dictionary.
#define addMessageWithArguments(name)
A convenience macro to be used by subclasses for registering messages.
Definition: TTMessage.h:27
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
TT_OBJECT_CONSTRUCTOR
Constructor macro.
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34
TTErr remove(const TTSymbol aKey)
Remove an item from the hash table.
Definition: TTDictionary.h:231
#define addAttributeWithGetterAndSetter(name, type)
A convenience macro to be used by subclasses for registering attributes with a custom getter and sett...
Definition: TTAttribute.h:57