| AAX SDK 2.6.1 Avid Audio Extensions Development Kit

- Welcome
- Manual
- Classes
- Files
- Lists
- Support

- File List
- File Members

Loading...
Searching...
No Matches
AAX_CPacketDispatcher.h
Go to the documentation of this file.
1/*================================================================================================*/
2/*
3 *
4 * Copyright 2013-2017, 2023 Avid Technology, Inc.
5 * All rights reserved.
6 *
7 * CONFIDENTIAL: this document contains confidential information of Avid. Do
8 * not disclose to any third party. Use of the information contained in this
9 * document is subject to an Avid SDK license.
10 *
11 */
12
19/*================================================================================================*/
20
21
22#ifndef AAX_CPACKETDISPATCHER_H
23#define AAX_CPACKETDISPATCHER_H
24
25#include "AAX.h"
26#include "AAX_IController.h"
27#include "AAX_CMutex.h"
28
29#include <string>
30#include <map>
31
32
41 class AAX_CPacket
42{
43 public:
44 AAX_CPacket(AAX_CFieldIndex inFieldIndex) : mID(inFieldIndex), mDirty(true), mDataSize(0) {}
45 ~AAX_CPacket() {}
46
47 template<typename DataType>
48 DataType* GetPtr()
49 {
50 mDataSize = sizeof(DataType);
51 void * data = mPacketData.Get(mDataSize);
52 return reinterpret_cast<DataType*> (data);
53 }
54
55 void SetDirty(bool iDirty) { mDirty = iDirty; };
56 bool IsDirty() const { return mDirty; };
57
58 AAX_CFieldIndex GetID() const { return mID; };
59 uint32_t GetSize() const { return mDataSize; }
60
61 private:
62 AAX_CFieldIndex mID;
63 bool mDirty;
64 uint32_t mDataSize;
65
66 private:
67 struct SPacketData
68 {
69 public:
70 SPacketData();
71 ~SPacketData();
72 const void* Get() const;
73 void* Get(size_t newSize) const;
74 private:
75 mutable void* mData;
76 } mPacketData;
77};
78
79// GetPtr() specialization for void*
80 template <>
81 inline const void*
82AAX_CPacket::GetPtr<const void>()
83{
84 return mPacketData.Get();
85}
86
87
90 struct AAX_IPacketHandler
91{
92 virtual ~AAX_IPacketHandler() {};
93 virtual AAX_IPacketHandler* Clone() const = 0;
94 virtual AAX_Result Call( AAX_CParamID inParamID, AAX_CPacket& ioPacket ) const = 0;
95};
96
99 template<class TWorker>
100 class AAX_CPacketHandler : public AAX_IPacketHandler
101{
102 typedef AAX_Result(TWorker::*fPt2Fn)(AAX_CPacket&);
103 typedef AAX_Result(TWorker::*fPt2FnEx)(AAX_CParamID, AAX_CPacket&);
104
105 public:
106 AAX_CPacketHandler( TWorker* iPt2Object, fPt2Fn infPt )
107 : pt2Object(iPt2Object), fpt(infPt), fptEx(NULL) {}
108
109 AAX_CPacketHandler( TWorker* iPt2Object, fPt2FnEx infPt )
110 : pt2Object(iPt2Object), fpt(NULL), fptEx(infPt) {}
111
112 AAX_IPacketHandler* Clone() const
113 {
114 return new AAX_CPacketHandler(*this);
115 }
116
117 AAX_Result Call( AAX_CParamID inParamID, AAX_CPacket& ioPacket ) const
118 {
119 if (fptEx)
120 return (*pt2Object.*fptEx)( inParamID, ioPacket);
121 else if (fpt)
122 return (*pt2Object.*fpt)( ioPacket);
123 else
124 return AAX_ERROR_NULL_OBJECT;
125 }
126
127 protected:
128 TWorker * pt2Object; // pointer to object
129 fPt2Fn fpt ; // pointer to member function
130 fPt2FnEx fptEx ; // pointer to member function
131};
132
133
134 class AAX_IEffectParameters;
135
149 class AAX_CPacketDispatcher
150{
151 typedef std::map<AAX_CFieldIndex, AAX_CPacket*> PacketsHolder;
152 typedef std::multimap<std::string, std::pair<AAX_CPacket*, AAX_IPacketHandler*> > PacketsHandlersMap;
153
154 public:
155 AAX_CPacketDispatcher();
156 ~AAX_CPacketDispatcher();
157
158 void Initialize( AAX_IController* iPlugIn, AAX_IEffectParameters* iEffectParameters);
159
160 AAX_Result RegisterPacket( AAX_CParamID paramID, AAX_CFieldIndex portID, const AAX_IPacketHandler* iHandler);
161
162 template <class TWorker, typename Func>
163 AAX_Result RegisterPacket( AAX_CParamID paramID, AAX_CFieldIndex portID,
164 TWorker* iPt2Object, Func infPt)
165 {
166 AAX_CPacketHandler<TWorker> handler(iPt2Object, infPt);
167 return RegisterPacket(paramID, portID, &handler);
168 }
169
170 AAX_Result RegisterPacket( AAX_CParamID paramID, AAX_CFieldIndex portID)
171 {
172 AAX_CPacketHandler<AAX_CPacketDispatcher> handler(this, &AAX_CPacketDispatcher::GenerateSingleValuePacket);
173 return RegisterPacket(paramID, portID, &handler);
174 }
175
176 AAX_Result SetDirty(AAX_CParamID paramID, bool iDirty = true);
177
178 AAX_Result Dispatch();
179
180 AAX_Result GenerateSingleValuePacket( AAX_CParamID iParam, AAX_CPacket& ioPacket);
181
182 private:
183 PacketsHolder mPacketsHolder;
184 PacketsHandlersMap mPacketsHandlers;
185 AAX_IController* mController;
186 AAX_IEffectParameters* mEffectParameters;
187
188 AAX_CMutex mLockGuard;
189};
190
191
192#endif // AAX_CPACKETDISPATCHER_H
AAX_CMutex.h
Mutex.
AAX_ERROR_NULL_OBJECT
@ AAX_ERROR_NULL_OBJECT
Definition: AAX_Errors.h:41
AAX.h
Various utility definitions for AAX.
AAX_CParamID
const char * AAX_CParamID
Parameter identifier.
Definition: AAX.h:349
AAX_Result
int32_t AAX_Result
Definition: AAX.h:334
AAX_CFieldIndex
AAX_CIndex AAX_CFieldIndex
Not used by AAX plug-ins (except in AAX_FIELD_INDEX macro)
Definition: AAX.h:346
AAX_IController.h
Interface for the AAX host's view of a single instance of an effect.
AAX_CMutex
Mutex with try lock functionality.
Definition: AAX_CMutex.h:27
AAX_CPacket
Container for packet-related data.
Definition: AAX_CPacketDispatcher.h:42
AAX_CPacket::IsDirty
bool IsDirty() const
Definition: AAX_CPacketDispatcher.h:56
AAX_CPacket::SetDirty
void SetDirty(bool iDirty)
Definition: AAX_CPacketDispatcher.h:55
AAX_CPacket::GetPtr
DataType * GetPtr()
Definition: AAX_CPacketDispatcher.h:48
AAX_CPacket::GetSize
uint32_t GetSize() const
Definition: AAX_CPacketDispatcher.h:59
AAX_CPacket::~AAX_CPacket
~AAX_CPacket()
Definition: AAX_CPacketDispatcher.h:45
AAX_CPacket::GetID
AAX_CFieldIndex GetID() const
Definition: AAX_CPacketDispatcher.h:58
AAX_CPacket::AAX_CPacket
AAX_CPacket(AAX_CFieldIndex inFieldIndex)
Definition: AAX_CPacketDispatcher.h:44
AAX_IPacketHandler
Callback container used by AAX_CPacketDispatcher.
Definition: AAX_CPacketDispatcher.h:91
AAX_IPacketHandler::Clone
virtual AAX_IPacketHandler * Clone() const =0
AAX_IPacketHandler::Call
virtual AAX_Result Call(AAX_CParamID inParamID, AAX_CPacket &ioPacket) const =0
AAX_IPacketHandler::~AAX_IPacketHandler
virtual ~AAX_IPacketHandler()
Definition: AAX_CPacketDispatcher.h:92
AAX_CPacketHandler
Callback container used by AAX_CPacketDispatcher.
Definition: AAX_CPacketDispatcher.h:101
AAX_CPacketHandler::Call
AAX_Result Call(AAX_CParamID inParamID, AAX_CPacket &ioPacket) const
Definition: AAX_CPacketDispatcher.h:117
AAX_CPacketHandler::Clone
AAX_IPacketHandler * Clone() const
Definition: AAX_CPacketDispatcher.h:112
AAX_CPacketHandler::AAX_CPacketHandler
AAX_CPacketHandler(TWorker *iPt2Object, fPt2Fn infPt)
Definition: AAX_CPacketDispatcher.h:106
AAX_CPacketHandler::fpt
fPt2Fn fpt
Definition: AAX_CPacketDispatcher.h:129
AAX_CPacketHandler::pt2Object
TWorker * pt2Object
Definition: AAX_CPacketDispatcher.h:128
AAX_CPacketHandler::fptEx
fPt2FnEx fptEx
Definition: AAX_CPacketDispatcher.h:130
AAX_CPacketHandler::AAX_CPacketHandler
AAX_CPacketHandler(TWorker *iPt2Object, fPt2FnEx infPt)
Definition: AAX_CPacketDispatcher.h:109
AAX_CPacketDispatcher
Helper class for managing AAX packet posting.
Definition: AAX_CPacketDispatcher.h:150
AAX_CPacketDispatcher::RegisterPacket
AAX_Result RegisterPacket(AAX_CParamID paramID, AAX_CFieldIndex portID, const AAX_IPacketHandler *iHandler)
AAX_CPacketDispatcher::AAX_CPacketDispatcher
AAX_CPacketDispatcher()
AAX_CPacketDispatcher::~AAX_CPacketDispatcher
~AAX_CPacketDispatcher()
AAX_CPacketDispatcher::SetDirty
AAX_Result SetDirty(AAX_CParamID paramID, bool iDirty=true)
AAX_CPacketDispatcher::RegisterPacket
AAX_Result RegisterPacket(AAX_CParamID paramID, AAX_CFieldIndex portID)
Definition: AAX_CPacketDispatcher.h:170
AAX_CPacketDispatcher::Initialize
void Initialize(AAX_IController *iPlugIn, AAX_IEffectParameters *iEffectParameters)
AAX_CPacketDispatcher::Dispatch
AAX_Result Dispatch()
AAX_CPacketDispatcher::RegisterPacket
AAX_Result RegisterPacket(AAX_CParamID paramID, AAX_CFieldIndex portID, TWorker *iPt2Object, Func infPt)
Definition: AAX_CPacketDispatcher.h:163
AAX_CPacketDispatcher::GenerateSingleValuePacket
AAX_Result GenerateSingleValuePacket(AAX_CParamID iParam, AAX_CPacket &ioPacket)
AAX_IController
Interface for the AAX host's view of a single instance of an effect. Used by both clients of the AAX ...
Definition: AAX_IController.h:42
AAX_IEffectParameters
The interface for an AAX Plug-in's data model.
Definition: AAX_IEffectParameters.h:80