Jamoma API  0.6.0.a19
TTModular.cpp
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup modularLibrary
4  *
5  * @brief the Modular Application Programming Interface
6  *
7  * @details The Modular API allows to use Modular inside another application @n@n
8  *
9  * @see TTModular
10  *
11  * @authors Théo de la Hogue
12  *
13  * @copyright Copyright © 2013, Théo de la Hogue @n
14  * This code is licensed under the terms of the "New BSD License" @n
15  * http://creativecommons.org/licenses/BSD/
16  */
17 
18 #include "TTModular.h"
19 
20 // those classes are included here to avoid circular inclusion when they are included from TTModularIncludes.h
21 #include "TTInputAudio.h"
22 #include "TTOutputAudio.h"
23 #include "TTInput.h"
24 #include "TTOutput.h"
25 
26 #if 0
27 #pragma mark -
28 #pragma mark Initialisation
29 #endif
30 
31 // is the Modular library have been initilialized ?
32 static bool TTModularInitialized = false;
33 
35 TTHashPtr TTModularSelections = NULL;
36 
37 #ifdef TT_PLATFORM_LINUX
38 int main(void)
39 {
40  // TODO: should we call TTModularInit here ?
41  return 0;
42 }
43 #endif
44 
45 void TTModularInit(const char* binaries, bool loadFromBuiltinPaths)
46 {
47  // Initialized Foundation framework
48  TTFoundationInit(binaries, loadFromBuiltinPaths);
49 
50 //#define TO_DEBUG
51 #ifdef TO_DEBUG
52 
53  TTValue t, out;
54  TTObject test("nodelib.test");
55  test.send("test", t, out);
56 
57 #endif // TO_DEBUG
58 
59  // if Modular has not been initialized
60  if (!TTModularInitialized) {
61 
62  TTModularInitialized = true;
63 
64  TTValue v, none;
65 
66  // Register classes -- both internal and external
67  TTApplication::registerClass();
68  TTApplicationManager::registerClass();
69  TTContainer::registerClass();
70  TTCue::registerClass();
71  TTCueManager::registerClass();
72  TTData::registerClass();
73  TTExplorer::registerClass();
74  TTInput::registerClass();
75  TTInputAudio::registerClass();
76  TTMapper::registerClass();
77  TTMapperManager::registerClass();
78  TTMirror::registerClass();
79  TTNodeInfo::registerClass();
80  TTOutput::registerClass();
81  TTOutputAudio::registerClass();
82  TTPreset::registerClass();
83  TTPresetManager::registerClass();
84  TTRamp::registerClass();
85  TTReceiver::registerClass();
86  TTSender::registerClass();
87  TTScript::registerClass();
88  TTSubscriber::registerClass();
89  TTTextHandler::registerClass();
90  TTViewer::registerClass();
91  TTXmlHandler::registerClass();
92 
93  // Create a hash table to manage namespace selections
94  TTModularSelections = new TTHash();
95 
96 #ifdef TT_DEBUG
97  TTLogMessage("Modular -- Version %s -- Debugging Enabled\n", TTMODULAR_VERSION_STRING);
98 #else
99  TTLogMessage("Modular -- Version %s\n", TTMODULAR_VERSION_STRING);
100 #endif
101 
102  }
103 }
104 
105 #if 0
106 #pragma mark -
107 #pragma mark Selection management
108 #endif
109 
110 TTAddressItemPtr TTModularSelectionLookup(const TTSymbol selectionName)
111 {
112  TTAddressItemPtr aSelection = NULL;
113  TTValue v;
114 
115  if (selectionName != kTTSymEmpty && selectionName != kTTSym_none) {
116 
117  if (!TTModularSelections->lookup(selectionName, v)) {
118 
119  aSelection = TTAddressItemPtr((TTPtr)v[0]);
120 
121  } else {
122 
123  aSelection = new TTAddressItem();
124 
125  v = TTValue((TTPtr)aSelection);
126  TTModularSelections->append(selectionName, v);
127  }
128  }
129 
130  return aSelection;
131 }
132 
133 #if 0
134 #pragma mark -
135 #pragma mark Addresses edition
136 #endif
137 
138 TTAddress TTModularAddressEditNumericInstance(const TTSymbol integerFormatAddress, const TTUInt32 instanceNumber)
139 {
140  return kTTAdrsEmpty;
141 }
142 
143 TTAddress TTModularAddressEditSymbolInstance(const TTSymbol symbolFormatAddress, const TTSymbol instanceSymbol)
144 {
145  return kTTAdrsEmpty;
146 }
147 
149 {
150  return kTTErrGeneric;
151 }
TTApplicationManagerPtr TTModularApplicationManager
Export a pointer to a TTApplicationManager instance.
Definition: TTModular.cpp:34
TTErr send(const TTSymbol aName)
Send a message to this object with no arguments.
Definition: TTObject.cpp:135
TTAddress TTModularAddressEditNumericInstance(const TTSymbol integerFormatAddress, const TTUInt32 instanceNumber)
Edit a specific integer instance address using an integer format address.
Definition: TTModular.cpp:138
TTErr lookup(const TTSymbol key, TTValue &value)
Find the value for the given key.
Definition: TTHash.cpp:76
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
Maintain a collection of TTValue objects indexed by TTSymbol pointers.
Definition: TTHash.h:36
TTAddress TTModularAddressEditSymbolInstance(const TTSymbol symbolFormatAddress, const TTSymbol instanceSymbol)
Edit a specific symbol instance address using an symbol format address.
Definition: TTModular.cpp:143
void * TTPtr
A generic pointer.
Definition: TTBase.h:248
An audio output component for Jamoma models.
The TTSymbol class is used to represent a string and efficiently pass and compare that string...
Definition: TTSymbol.h:26
TTErr append(const TTSymbol key, const TTValue &value)
Insert an item into the hash table.
Definition: TTHash.cpp:70
Handles any signal input.
Handles TTApplication and #Protocol instances.
TTAddressItemPtr TTModularSelectionLookup(const TTSymbol selectionName)
Get a selection or create one if it doesn't exist yet.
Definition: TTModular.cpp:110
TTErr TTModularAddressGetInstances(const TTAddress address, TTValue &instances)
Get all intances at an address.
Definition: TTModular.cpp:148
void TTFOUNDATION_EXPORT TTLogMessage(TTImmutableCString message,...)
Platform and host independent method for posting log messages.
Definition: TTBase.cpp:534
Something went wrong, but what exactly is not known. Typically used for context-specific problems...
Definition: TTBase.h:344
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
Definition: TTBase.h:342
std::uint32_t TTUInt32
32 bit unsigned integer
Definition: TTBase.h:178
An audio input component for Jamoma models.
Handles any signal output.
the Modular Application Programming Interface
void TTModularInit(const char *binaries, bool loadFromBuiltinPaths)
Initialize the Modular library and intanciate the TTModular object.
Definition: TTModular.cpp:45
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34