Commit 1677baab authored by jacobgladish's avatar jacobgladish

Brought interfaces up to date with WinRT DSB

parent 7180e0c3
......@@ -29,6 +29,12 @@ namespace mock
virtual int32_t Initialize();
virtual int32_t Shutdown();
virtual int32_t GetConfiguration(std::vector<uint8_t>* /*configData*/)
{ return 0; }
virtual int32_t SetConfiguration(std::vector<uint8_t> const& /*configData*/)
{ return 0; }
virtual int32_t EnumDevices(
bridge::EnumDeviceOptions opts,
bridge::AdapterDeviceVector& deviceList,
......
......@@ -75,6 +75,9 @@ namespace mock
MockAdapterProperty(MockPropertyDescriptor const& desc, weak_ptr<MockAdapterDevice> const& parent);
virtual std::string GetName();
virtual std::string GetInterfaceHint()
{ return std::string(""); }
virtual bridge::AdapterValueVector GetAttributes();
shared_ptr<MockAdapterDevice> GetParent()
......
......@@ -4,6 +4,7 @@
#include "Common/Guid.h"
#include "Common/Variant.h"
#include <map>
#include <string>
#include <vector>
......@@ -20,18 +21,42 @@ namespace bridge
std::string const kDsbDeviceNotificationSignal = "DeviceNotificationSignal";
std::string const kDsbSendMsgToDeviceMethod = "SendMessageToDeviceSynchronous";
class IAdapterValue;
class IAdapterProperty;
class IAdapterMethod;
class IAdapterSignal;
class IAdapterDevice;
typedef std::vector< shared_ptr<IAdapterValue> > AdapterValueVector;
typedef std::vector< shared_ptr<IAdapterValue> > AdapterValueVector;
typedef std::vector< shared_ptr<IAdapterProperty> > AdapterPropertyVector;
typedef std::vector< shared_ptr<IAdapterMethod> > AdapterMethodVector;
typedef std::vector< shared_ptr<IAdapterSignal> > AdapterSignalVector;
typedef std::vector< shared_ptr<IAdapterDevice> > AdapterDeviceVector;
typedef std::vector< shared_ptr<IAdapterMethod> > AdapterMethodVector;
typedef std::vector< shared_ptr<IAdapterSignal> > AdapterSignalVector;
typedef std::vector< shared_ptr<IAdapterDevice> > AdapterDeviceVector;
typedef std::map< std::string, std::string> AnnotationMap;
enum class AccessType
{
Read,
Write,
ReadWrite
};
enum class SignalBehavior
{
Unspecified,
Never,
Always,
AlwaysWithNoValue
};
class IAdapterAttribute
{
public:
virtual shared_ptr<IAdapterValue> GetValue() = 0;
virtual AnnotationMap GetAnnotations() = 0;
virtual AccessType GetAccess() = 0;
virtual SignalBehavior GetChangeOfValueBehavior() = 0;
};
class IAdapterValue
{
......@@ -47,6 +72,7 @@ namespace bridge
public:
virtual ~IAdapterProperty() { }
virtual std::string GetName() = 0;
virtual std::string GetInterfaceHint() = 0;
virtual AdapterValueVector GetAttributes() = 0;
};
......@@ -138,6 +164,9 @@ namespace bridge
virtual common::Guid GetExposedApplicationGuid() = 0;
virtual AdapterSignalVector GetSignals() = 0;
virtual int32_t SetConfiguration(std::vector<uint8_t> const& configData) = 0;
virtual int32_t GetConfiguration(std::vector<uint8_t>* configData) = 0;
virtual int32_t Initialize() = 0;
virtual int32_t Shutdown() = 0;
......@@ -177,5 +206,62 @@ namespace bridge
virtual int32_t UnregisterSignalListener(RegistrationHandle const& h) = 0;
};
// concrete implementations of some of the simple interfaces
class AdapterAttribute : public IAdapterAttribute
{
public:
AdapterAttribute(shared_ptr<IAdapterValue> const& value, AnnotationMap const& annotations,
AccessType accessType, SignalBehavior signalBehavior)
: m_adapterValue(value)
, m_annotationMap(annotations)
, m_accessType(accessType)
, m_signalBehavior(signalBehavior)
{
// empty
}
public:
virtual shared_ptr<IAdapterValue> GetValue()
{ return m_adapterValue; }
virtual AnnotationMap GetAnnotations()
{ return m_annotationMap; }
virtual AccessType GetAccess()
{ return m_accessType; }
virtual SignalBehavior GetChangeOfValueBehavior()
{ return m_signalBehavior; }
private:
shared_ptr<IAdapterValue> m_adapterValue;
AnnotationMap m_annotationMap;
AccessType m_accessType;
SignalBehavior m_signalBehavior;
};
class AdapterValue : public IAdapterValue
{
public:
AdapterValue(std::string const& name, common::Variant const& data)
: m_name(name)
, m_data(data)
{
// empty
}
virtual std::string GetName()
{ return m_name; }
virtual common::Variant const& GetData() const
{ return m_data; }
private:
std::string m_name;
common::Variant m_data;
};
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment