Jamoma API  0.6.0.a19
TTAddressItem.h
1 /*
2  * TTAddressItem
3  * Copyright © 2012, Théo de la Hogue
4  *
5  * License: This code is licensed under the terms of the "New BSD License"
6  * http://creativecommons.org/licenses/BSD/
7  */
8 
9 #if !defined( __TT_NODE_ADDRESS_ITEM_H__ ) && !defined ( DISABLE_NODELIB )
10 #define __TT_NODE_ADDRESS_ITEM_H__
11 
12 #ifdef WIN_VERSION
13  #pragma warning(disable:4083) //warning C4083: expected 'newline'; found identifier 's'
14 #endif // WIN_VERSION
15 
16 #include "TTList.h"
17 #include "TTAddress.h"
18 
19 class TTAddressItem;
20 typedef TTAddressItem* TTAddressItemPtr;
21 
22 /****************************************************************************************************/
23 // Class Specifications
24 
25 /**
26 
27  */
28 
29 class TTFOUNDATION_EXPORT TTAddressItem : public TTList
30 {
31 
32 private:
33 
34  TTSymbol symbol; // any symbol
35  TTAddressItemPtr parent; // the parent item
36  TTListPtr options; // any optionnal symbols (like attribute, message)
37  TTBoolean selection; // selection state of the item
38  TTList handlers; // list of all TTObjectBase handling the item
39 
40 public:
41 
42  /** Constructor */
43  TTAddressItem (TTSymbol aSymbol=kTTSymEmpty, TTAddressItemPtr aParent=NULL, TTBoolean aSelection=NO);
44 
45  /** Destructor */
46  virtual ~TTAddressItem ();
47 
48  /** Set the parent of the item
49  @param newParent a namespace item pointer
50  @return a error code */
51  void setParent(const TTAddressItemPtr newParent);
52 
53  /** Set the selection state of the item
54  @param newSelectionState YES to select the item
55  @return a error code */
56  void setSelection(const TTBoolean newSelectionState, TTBoolean recursively=NO);
57 
58  /** Get the symbol of the item */
59  TTSymbol& getSymbol();
60 
61  /** Get the parent of the item */
62  TTAddressItemPtr getParent();
63 
64  /** Get the options of the item */
65  TTListPtr getOptions();
66 
67  /** Get the selection state of the item */
68  TTBoolean getSelection();
69 
70  /** Get an Item below this item */
71  TTAddressItemPtr getItem(TTSymbol aSymbol);
72 
73  /** Overwrite the TTList::clear() method to delete all items below */
74  void clear();
75 
76  /** Overwrite the TTList::append() method to append a node address */
77  TTErr append(TTAddress addressToAppend, TTAddressItemPtr *returnedItem);
78 
79  /** Overwrite the TTList::remove() method to remove a node address */
80  TTErr remove(TTAddress addressToRemove);
81 
82  /** Overwrite the TTList::current() method to access directly to the current item */
83  TTAddressItemPtr current();
84 
85  /** Overwrite the TTList::find() method to find a node address
86  Note : if it fails, it returns the TTAddressItem where the find fails */
87  TTErr find(TTAddress addressToFind, TTAddressItemPtr *returnedItem);
88 
89  /** Merge an item */
90  TTErr merge(const TTAddressItemPtr anItemToAppend);
91 
92  /** Destroy an item and his parent if he's empty */
93  TTErr destroy(const TTAddressItemPtr anItemToRemove);
94 
95  /** Check if a similar item exist and returns the last tested item */
96  TTBoolean exist(TTAddressItemPtr anItemToCheck, TTAddressItemPtr *returnedItem);
97 
98  /** Copy the item into a given item */
99  TTErr copy(TTAddressItemPtr *anItemCopy);
100 
101  /** Register a TTObjectBase handler */
102  void registerHandler(TTObject& anObject);
103 
104  /** Unregister a TTObjectBase handler */
105  void unregisterHandler(TTObject& anObject);
106 
107  /** Send a message to all handlers */
108  void iterateHandlersSendingMessage(TTSymbol& messageName);
109  void iterateHandlersSendingMessage(TTSymbol& messageName, TTValue& aValue);
110 
111  friend void TTFOUNDATION_EXPORT TTAddressItemFind(const TTValue& itemValue, TTPtr aSymbolBaseToMatch, TTBoolean& found);
112 };
113 
114 /* a TTFunctionMatch to find an item */
115 void TTFOUNDATION_EXPORT TTAddressItemFind(const TTValue& itemValue, TTPtr aSymbolBaseToMatch, TTBoolean& found);
116 
117 
118 #endif // __TT_NODE_ADDRESS_ITEM_H__
bool TTBoolean
Boolean flag, same as Boolean on the Mac.
Definition: TTBase.h:167
The TTAddress class is used to represent a string and efficiently pass and compare that string...
Definition: TTAddress.h:29
Create and use Jamoma object instances.
Definition: TTObject.h:29
void * TTPtr
A generic pointer.
Definition: TTBase.h:248
The TTSymbol class is used to represent a string and efficiently pass and compare that string...
Definition: TTSymbol.h:26
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
Definition: TTBase.h:342
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34