C++ API Reference RNBO: common/RNBO_PatcherInterface.h Source File

RNBO: common/RNBO_PatcherInterface.h Source File

1 //
2 // _RNBO_PatcherInterface_H_
3 //
4 // Created by Rob Sussman on 8/4/15.
5 //
6 //
7 
8 #ifndef _RNBO_PatcherInterface_H_
9 #define _RNBO_PatcherInterface_H_
10 
11 #include "RNBO_Types.h"
12 #include "RNBO_ProcessInterface.h"
13 #include "RNBO_PatcherEventTarget.h"
14 #include "RNBO_EngineLink.h"
15 #include "RNBO_ProbingInterface.h"
16 #include "RNBO_PatcherStateInterface.h"
17 #include "RNBO_EngineInterface.h"
18 
19 namespace RNBO {
20 
21  class DataRef;
22 
24  public PatcherEventTarget,
25  public EngineLink,
26  public ProbingInterface
27  {
28  protected:
29  // must be deleted by calling destroy()
30  virtual ~PatcherInterface() { }
31 
32  public:
34  { }
35 
36  virtual void destroy() = 0;
37 
38  // Parameters:
39  // - represent state of the patcher that can be set from the Engine
40  // - "visible" parameters are made available to plugin environments
41  // - Index identifies a parameter but might change when patcher code is regenerated
42  // - Index starts at 0 and goes up to getNumParameters() - 1
43  // - The parameter name is intended for users to see for plugin environments
44 
45  virtual void dump() {}
46 
47  // extract the current state from a patcher
48  // this will leave the patcher in an UNDEFINED state and most likely unusable
49  virtual void extractState(PatcherStateInterface& state)
50  {
51  RNBO_UNUSED(state);
52  }
53 
54  void initialize() override
55  {
56  // you have to overload at least one initialize methods
57  // assert(false); // can't use assert in Common
58  }
59 
60  // initialize the patcehr and apply the given state - take care - the state is
61  // in an UNDEFINED state afterwards and not re-usable
62  virtual void initialize(PatcherStateInterface& state)
63  {
64  RNBO_UNUSED(state);
65  // the state will only be used if the Patcher overloads this function
66  initialize();
67  }
68 
69  virtual void getPreset(PatcherStateInterface&) {}
70  virtual void setPreset(MillisecondTime, PatcherStateInterface&) {}
71  virtual DataRefIndex getNumDataRefs() const = 0;
72  virtual DataRef* getDataRef(DataRefIndex index) = 0;
73  virtual ParameterIndex getNumSignalInParameters() const = 0;
74  virtual ParameterIndex getNumSignalOutParameters() const = 0;
75  virtual MessageTagInfo resolveTag(MessageTag tag) const = 0;
76  virtual MessageIndex getNumMessages() const { return 0; }
77  virtual const MessageInfo& getMessageInfo(MessageIndex) const { return NullMessageInfo; }
78  virtual Index getMaxBlockSize() const = 0;
79  virtual number getSampleRate() const = 0;
80  virtual bool hasFixedVectorSize() const = 0;
81  virtual MillisecondTime getPatcherTime() const = 0;
82 
83  protected:
84 
85  virtual void sendParameter(ParameterIndex, bool) {}
86 
87  };
88 
94  template <>
95  struct default_delete<RNBO::PatcherInterface>
96  {
97  void operator() (RNBO::PatcherInterface* pi) const
98  {
99  pi->destroy();
100  }
101  };
102 
103 } // namespace RNBO
104 
105 #ifndef RNBO_NOSTL
106 
108 
109 // std::default_delete for RNBO::PatcherInterface allows putting PatcherInterface into std::unique_ptr
110 namespace std
111 {
112  template <>
113  struct default_delete<RNBO::PatcherInterface>
114  {
115  void operator() (RNBO::PatcherInterface* pi) const
116  {
117  pi->destroy();
118  }
119  };
120 }
121 
123 
124 #endif // RNBO_NOSTL
125 
126 
127 #endif // #ifndef _RNBO_PatcherInterface_H_