20 #include <pluginterfaces/base/ftypes.h> 21 #include <pluginterfaces/vst/ivstmessage.h> 24 #include <public.sdk/source/vst/vstpresetfile.h> 25 #include <public.sdk/source/common/memorystream.h> 34 using namespace Steinberg;
35 using namespace Steinberg::Vst;
47 explicit Message(IMessage *message) : fMessage(message) {}
51 return static_cast<MessageID>(getInt(
ATTR_MSG_ID, -1));
56 fMessage->getAttributes()->setInt(
ATTR_MSG_ID, messageID);
59 inline int64
getInt(IAttributeList::AttrID
id, int64 defaultValue)
const 62 if(fMessage->getAttributes()->getInt(
id, value) != kResultOk)
67 inline void setInt(IAttributeList::AttrID
id, int64 value)
69 fMessage->getAttributes()->setInt(
id, value);
72 inline double getFloat(IAttributeList::AttrID
id,
double defaultValue)
const 75 if(fMessage->getAttributes()->getFloat(
id, value) != kResultOk)
80 inline void setFloat(IAttributeList::AttrID
id,
double value)
82 fMessage->getAttributes()->setFloat(
id, value);
93 inline tresult
setBinary(IAttributeList::AttrID
id,
const T *iData, uint32 iSize)
95 return fMessage->getAttributes()->setBinary(
id, iData, iSize *
sizeof(T));
107 inline int32 getBinary(IAttributeList::AttrID
id, T *iData, uint32 iSize)
const;
114 tresult setSerializableValue(IAttributeList::AttrID
id,
IParamSerializer<T> const &iSerializer, T
const &iValue);
121 tresult getSerializableValue(IAttributeList::AttrID
id,
IParamSerializer<T> const &iSerializer, T &oValue)
const;
136 if(fMessage->getAttributes()->getBinary(
id, data, size) != kResultOk)
139 uint32 oSize = size /
sizeof(T);
140 oSize = std::min(iSize, oSize);
142 memcpy(iData, data, oSize *
sizeof(T));
155 IBStreamer streamer{&stream};
160 return setBinary(
id, stream.getData(), stream.getSize());
174 tresult res = fMessage->getAttributes()->getBinary(
id, data, size);
180 MemoryStream stream(const_cast<void*>(data), size);
181 stream.seek(IBStream::kIBSeekSet, 0,
nullptr);
183 IBStreamer streamer{&stream};
IMessage * fMessage
Definition: Messaging.h:124
int32 getBinary(IAttributeList::AttrID id, T *iData, uint32 iSize) const
Gets a binary message.
Definition: Messaging.h:131
virtual tresult readFromStream(IBStreamer &iStreamer, ParamType &oValue) const =0
Simple wrapper class with better api.
Definition: Messaging.h:44
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:151
void setInt(IAttributeList::AttrID id, int64 value)
Definition: Messaging.h:67
Message(IMessage *message)
Definition: Messaging.h:47
MessageID getMessageID() const
Definition: Messaging.h:49
static const auto ATTR_MSG_ID
Definition: Messaging.h:37
double getFloat(IAttributeList::AttrID id, double defaultValue) const
Definition: Messaging.h:72
void setMessageID(MessageID messageID)
Definition: Messaging.h:54
This class is a copy of MemoryStream for the purpose of fixing the growing issue encountered on Windo...
Definition: FastWriteMemoryStream.h:41
void setFloat(IAttributeList::AttrID id, double value)
Definition: Messaging.h:80
tresult setBinary(IAttributeList::AttrID id, const T *iData, uint32 iSize)
Sets a binary message.
Definition: Messaging.h:93
int MessageID
Definition: Messaging.h:39
A vst parameter is represented by a ParamValue type which is a double in the range [0,...
Definition: ParamSerializers.h:105
virtual tresult writeToStream(const ParamType &iValue, IBStreamer &oStreamer) const =0
int64 getInt(IAttributeList::AttrID id, int64 defaultValue) const
Definition: Messaging.h:59
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:169