Commit 13d3fefe authored by gladish's avatar gladish

Some helper stuff, DeviceMain

parent 96bba8f3
#include "AllJoynHelper.h"
#include "DeviceMain.h"
QStatus
......@@ -15,6 +16,9 @@ bridge::AllJoynHelper::SetMsgArg(IAdapterValue const& adapterValue, ajn::MsgArg&
switch (val.GetType())
{
case common::Variant::DataType::Invalid:
break;
case common::Variant::DataType::Boolean:
{
bool b = val.ToBoolean();
......@@ -141,7 +145,12 @@ bridge::AllJoynHelper::SetMsgArg(IAdapterValue const& adapterValue, ajn::MsgArg&
QStatus
bridge::AllJoynHelper::SetMsgArgFromAdapterObject(IAdapterValue const& adapterValue, ajn::MsgArg& msg, DeviceMain* deviceMain)
{
return ER_NOT_IMPLEMENTED;
// TODO:
QStatus st = ER_OK;
common::Variant const& val = adapterValue.GetData();
// std::string path = deviceMain->GetBusObjectPath(adapterValue);
return st;
}
QStatus
......@@ -186,9 +195,7 @@ bridge::AllJoynHelper::GetAdapterObject(IAdapterValue& adapterValue, ajn::MsgArg
QStatus
bridge::AllJoynHelper::GetSignature(common::Variant::DataType type, std::string& sig)
{
using namespace common;
#define setSignature(T, S) case Variant::DataType::T: sig = S; break
#define setSignature(T, S) case common::Variant::DataType::T: sig = S; break
QStatus status = ER_OK;
switch (type)
......
......@@ -40,10 +40,52 @@ namespace bridge
};
template<class T>
QStatus AllJoynHelper::SetMsgArg(ajn::MsgArg& msgArg, std::string const& sig, std::vector<T> const& arr)
QStatus AllJoynHelper::SetMsgArg(ajn::MsgArg& msg, std::string const& sig, std::vector<T> const& arr)
{
QStatus st = ER_OK;
if (!arr.empty())
{
st = msg.Set(sig.c_str(), arr.size(), &arr[0]);
msg.Stabilize();
}
else
{
T buff[1];
buff[0] = T();
st = msg.Set(sig.c_str(), 1, buff);
msg.Stabilize();
}
return st;
}
template<>
QStatus AllJoynHelper::SetMsgArg(ajn::MsgArg& msg, std::string const& sig, std::vector<std::string> const& arr)
{
QStatus st = ER_OK;
if (!arr.empty())
{
int n = static_cast<int>(arr.size());
typedef char const* value_type;
value_type* p = new value_type[n];
for (int i = 0; i < n; ++i)
p[i] = arr[i].c_str();
st = msg.Set(sig.c_str(), n, p);
msg.Stabilize();
}
else
{
st = msg.Set(sig.c_str(), 1, "");
msg.Stabilize();
}
return st;
}
}
#include "DeviceMain.h"
bridge::DeviceMain::DeviceMain()
: m_indexForSignal(1)
, m_indexForMethod(1)
, m_registeredOnAllJoyn(false)
{
}
bridge::DeviceMain::~DeviceMain()
{
Shutdown();
}
void
bridge::DeviceMain::Shutdown()
{
}
QStatus
bridge::DeviceMain::Initialize(shared_ptr<BridgeDevice> const& parent)
{
QStatus st = ER_OK;
return st;
}
bool
bridge::DeviceMain::IsMethodNameUnique(std::string const& name)
{
return m_deviceMethods.find(name) != m_deviceMethods.end();
}
bool
bridge::DeviceMain::IsSignalNameUnique(std::string const& name)
{
// TODO:
return false;
}
#ifndef __DEVICE_MAIN_H__
#define __DEVICE_MAIN_H__
#include "BridgeDevice.h"
#include <map>
#include <alljoyn/BusObject.h>
#include <alljoyn/InterfaceDescription.h>
namespace bridge
{
class DeviceMethod;
class DeviceSignal;
class DeviceMain
{
DeviceMain();
virtual ~DeviceMain();
QStatus Initialize(shared_ptr<BridgeDevice> const& parent);
bool IsMethodNameUnique(std::string const& name);
bool IsSignalNameUnique(std::string const& name);
void HandleSignal(IAdapterSignal const& adapterSignal);
inline shared_ptr<ajn::BusObject> GetBusObject() const
{ return m_busObject; }
inline int GetIndexForMethod()
{ return m_indexForMethod++; }
inline std::string GetBusObjectPath(IAdapterProperty const& prop)
{ return std::string(); }
private:
void Shutdown();
private:
int m_indexForSignal;
int m_indexForMethod;
shared_ptr<ajn::BusObject> m_busObject;
std::unique_ptr<ajn::InterfaceDescription> m_interfaceDescrtipion;
std::string m_busObjectPath;
std::string m_interfaceName;
std::shared_ptr<BridgeDevice> m_parent;
std::map<std::string, DeviceMethod* > m_deviceMethods;
std::map<std::string, DeviceSignal* > m_deviceSignals;
bool m_registeredOnAllJoyn;
};
}
#endif
#include "Variant.h"
namespace
{
}
common::Variant::Data::Data()
{
Type = DataType::Invalid;
......
......@@ -6,6 +6,7 @@ SRCS=DeviceProviders/AllJoynProvider.cpp \
Bridge/BridgeConfig.cpp \
Bridge/BridgeDevice.cpp \
Bridge/ConfigManager.cpp \
Bridge/DeviceMain.cpp \
Common/Log.cpp \
Common/Variant.cpp \
Adapters/MockAdapter/MockAdapter.cpp \
......
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