Jamoma API  0.6.0.a19
MaxGraph.h
1 /*
2  * MaxGraph
3  * A thin wrapper of the Jamoma Graph system for use in the Cycling '74 Max/MSP environment.
4  * Includes an automated class wrapper to make TTFoundation objects available as objects for Max/MSP.
5  * Copyright © 2010 by Timothy Place
6  *
7  * License: This code is licensed under the terms of the "New BSD License"
8  * http://creativecommons.org/licenses/BSD/
9  */
10 
11 #ifndef __TT_MAX_GRAPH_H__
12 #define __TT_MAX_GRAPH_H__
13 
14 #include "ext.h" // Max Header
15 #include "ext_obex.h" // Max Object Extensions (attributes) Header
16 #include "ext_strings.h" // String Functions
17 #include "commonsyms.h" // Common symbols used by the Max 4.5 API
18 #include "z_dsp.h" // MSP Header
19 #include "jpatcher_api.h" // Required for patcher traversal code
20 
21 #include "TTGraphAPI.h" // Definitions for Jamoma Graph
22 
23 // TYPE DEFINITIONS
24 
25 #ifndef SELF
26 #define SELF ((t_object*)(self))
27 #endif
28 
29 
30 typedef TTErr (*TTValidityCheckFunction)(const TTPtr data); ///< A type that can be used to store a pointer to a validity checking function.
31 
32 class WrappedClassOptions;
33 
34 typedef struct _wrappedClass {
35  t_class* maxClass; ///< The Max class pointer.
36  t_symbol* maxClassName; ///< The name to give the Max class.
37  TTSymbol ttClassName; ///< The name of the class as registered with the Jamoma framework.
38  TTValidityCheckFunction validityCheck; ///< A function to call to validate the context for an object before it is instantiated.
39  TTPtr validityCheckArgument; ///< An argument to pass to the validityCheck function when it is called.
40  WrappedClassOptions* options; ///< Additional configuration options specified for the class.
41  t_hashtab* maxNamesToTTNames; ///< names may not be direct mappings, as we downcase the first letter.
42 } WrappedClass;
43 
44 
45 
46 class WrappedClassOptions {
47 protected:
48  TTHash* options;
49 
50 public:
51  WrappedClassOptions()
52  {
53  options = new TTHash;
54  }
55 
56  virtual ~WrappedClassOptions()
57  {
58  delete options;
59  }
60 
61  TTErr append(const TTSymbol& optionName, const TTValue& optionValue)
62  {
63  return options->append(optionName, optionValue);
64  }
65 
66  /** Returns an error if the requested option doesn't exist. */
67  TTErr lookup(const TTSymbol& optionName, TTValue& optionValue)
68  {
69  return options->lookup(optionName, optionValue);
70  }
71 
72 };
73 
74 
75 typedef WrappedClass* WrappedClassPtr; ///< A pointer to a WrappedClass.
76 typedef WrappedClassOptions* WrappedClassOptionsPtr; ///< A pointer to WrappedClassOptions.
77 
78 
79 // FUNCTIONS
80 
81 // Wrap a Jamoma Graph class as a Max class.
82 TTErr wrapAsMaxGraph(TTSymbol& ttClassName, char* maxClassName, WrappedClassPtr* c);
83 
84 // This version can be passed a method that is called to make sure it is legit to instantiate the class.
85 TTErr wrapAsMaxGraph(TTSymbol& ttClassName, char* maxClassName, WrappedClassPtr* c, TTValidityCheckFunction validityCheck);
86 
87 // This version can be passed a method that is called to make sure it is legit to instantiate the class.
88 TTErr wrapAsMaxGraph(TTSymbol& ttClassName, char* maxClassName, WrappedClassPtr* c, TTValidityCheckFunction validityCheck, TTPtr validityCheckArgument);
89 
90 
91 // These are versions of the above, but for which additional options can be specified.
92 TTErr wrapAsMaxGraph(TTSymbol& ttblueClassName, char* maxClassName, WrappedClassPtr* c, WrappedClassOptionsPtr options);
93 TTErr wrapAsMaxGraph(TTSymbol& ttblueClassName, char* maxClassName, WrappedClassPtr* c, TTValidityCheckFunction validityCheck, WrappedClassOptionsPtr options);
94 TTErr wrapAsMaxGraph(TTSymbol& ttblueClassName, char* maxClassName, WrappedClassPtr* c, TTValidityCheckFunction validityCheck, TTPtr validityCheckArgument, WrappedClassOptionsPtr options);
95 
96 
97 TTErr MaxGraphReset(t_object* self);
98 TTErr MaxGraphSetup(t_object* self);
99 TTErr MaxGraphConnect(t_object* self, TTGraphObjectBasePtr audioSourceObject, TTUInt16 sourceOutletNumber);
100 TTErr MaxGraphDrop(t_object* x, long inletNumber, t_object* sourceMaxObject, long sourceOutletNumber);
101 TTErr MaxGraphObject(t_object* x, TTGraphObjectBasePtr* returnedGraphObject);
102 
103 #endif // __TT_MAX_GRAPH_H__
104 
The TTGraphObjectBase wraps a TTDSP object such that it is possible to build a dynamic graph of audio...
std::uint16_t TTUInt16
16 bit unsigned integer
Definition: TTBase.h:176
TTErr lookup(const TTSymbol key, TTValue &value)
Find the value for the given key.
Definition: TTHash.cpp:76
Maintain a collection of TTValue objects indexed by TTSymbol pointers.
Definition: TTHash.h:36
void * TTPtr
A generic pointer.
Definition: TTBase.h:248
TTErr(* TTValidityCheckFunction)(const TTPtr data)
A type that can be used to store a pointer to a validity checking function.
Definition: MaxAudioGraph.h:36
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
Jamoma Asynchronous Object Graph Layer.
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