20 #include <pluginterfaces/base/ftypes.h> 21 #include <pluginterfaces/vst/ivstmessage.h> 24 #include <public.sdk/source/vst/vstpresetfile.h> 32 using namespace Steinberg;
33 using namespace Steinberg::Vst;
45 explicit Message(IMessage *message) : fMessage(message) {}
49 return static_cast<MessageID>(getInt(
ATTR_MSG_ID, -1));
54 fMessage->getAttributes()->setInt(
ATTR_MSG_ID, messageID);
57 inline int64
getInt(IAttributeList::AttrID
id, int64 defaultValue)
const 60 if(fMessage->getAttributes()->getInt(
id, value) != kResultOk)
65 inline void setInt(IAttributeList::AttrID
id, int64 value)
67 fMessage->getAttributes()->setInt(
id, value);
70 inline double getFloat(IAttributeList::AttrID
id,
double defaultValue)
const 73 if(fMessage->getAttributes()->getFloat(
id, value) != kResultOk)
78 inline void setFloat(IAttributeList::AttrID
id,
double value)
80 fMessage->getAttributes()->setFloat(
id, value);
91 inline tresult
setBinary(IAttributeList::AttrID
id,
const T *iData, uint32 iSize)
93 return fMessage->getAttributes()->setBinary(
id, iData, iSize *
sizeof(T));
105 inline int32 getBinary(IAttributeList::AttrID
id, T *iData, uint32 iSize)
const;
112 tresult setSerializableValue(IAttributeList::AttrID
id,
IParamSerializer<T> const &iSerializer, T
const &iValue);
119 tresult getSerializableValue(IAttributeList::AttrID
id,
IParamSerializer<T> const &iSerializer, T &oValue)
const;
134 if(fMessage->getAttributes()->getBinary(
id, data, size) != kResultOk)
137 uint32 oSize = size /
sizeof(T);
138 oSize = std::min(iSize, oSize);
140 memcpy(iData, data, oSize *
sizeof(T));
167 IBStreamer streamer{&stream};
172 auto const &buffer = stream.getBuffer();
173 return setBinary(
id, buffer.int8Ptr(), buffer.getFillSize());
187 tresult res = fMessage->getAttributes()->getBinary(
id, data, size);
193 Buffer buffer(data, size);
196 stream.seek(IBStream::kIBSeekSet, 0,
nullptr);
198 IBStreamer streamer{&stream};
IMessage * fMessage
Definition: Messaging.h:122
BufferStream(Buffer &&iFrom)
Definition: Messaging.h:152
int32 getBinary(IAttributeList::AttrID id, T *iData, uint32 iSize) const
Gets a binary message.
Definition: Messaging.h:129
virtual tresult readFromStream(IBStreamer &iStreamer, ParamType &oValue) const =0
Simple wrapper class with better api.
Definition: Messaging.h:42
BufferStream()
Definition: Messaging.h:151
tresult setSerializableValue(IAttributeList::AttrID id, IParamSerializer< T > const &iSerializer, T const &iValue)
Serializes the parameter value as an entry in the message.
Definition: Messaging.h:163
void setInt(IAttributeList::AttrID id, int64 value)
Definition: Messaging.h:65
Message(IMessage *message)
Definition: Messaging.h:45
MessageID getMessageID() const
Definition: Messaging.h:47
static const auto ATTR_MSG_ID
Definition: Messaging.h:35
double getFloat(IAttributeList::AttrID id, double defaultValue) const
Definition: Messaging.h:70
void setMessageID(MessageID messageID)
Definition: Messaging.h:52
void setFloat(IAttributeList::AttrID id, double value)
Definition: Messaging.h:78
tresult setBinary(IAttributeList::AttrID id, const T *iData, uint32 iSize)
Sets a binary message.
Definition: Messaging.h:91
Internal class to override the BufferStream class and give access to the buffer.
Definition: Messaging.h:148
int MessageID
Definition: Messaging.h:37
A vst parameter is represented by a ParamValue type which is a double in the range [0,...
Definition: ParamSerializers.h:105
Buffer const & getBuffer() const
Definition: Messaging.h:156
virtual tresult writeToStream(const ParamType &iValue, IBStreamer &oStreamer) const =0
int64 getInt(IAttributeList::AttrID id, int64 defaultValue) const
Definition: Messaging.h:57
tresult getSerializableValue(IAttributeList::AttrID id, IParamSerializer< T > const &iSerializer, T &oValue) const
Deserializes the parameter value from an entry in the message.
Definition: Messaging.h:182