Commit 9e404d45 authored by gladish's avatar gladish

namespace/witespace changes.

parent 68cbc6e3
......@@ -7,14 +7,14 @@
namespace
{
Bridge::IAdapter::RegistrationHandle nextHandle = 0;
Bridge::IAdapter::RegistrationHandle GetNextRegistrationHandle()
bridge::IAdapter::RegistrationHandle nextHandle = 0;
bridge::IAdapter::RegistrationHandle GetNextRegistrationHandle()
{
return ++nextHandle;
}
}
AdapterLib::MockAdapter::MockAdapter()
adapters::mock::MockAdapter::MockAdapter()
: m_vendor("Acme")
, m_adapterName("DSB Mock Adapter")
, m_exposedAdapterPrefix("com." + m_vendor)
......@@ -24,47 +24,54 @@ AdapterLib::MockAdapter::MockAdapter()
// TODO: get m_exposedApplicatioName and Prefix from config
}
AdapterLib::MockAdapter::~MockAdapter()
adapters::mock::MockAdapter::~MockAdapter()
{
}
std::string AdapterLib::MockAdapter::GetVendor()
std::string
adapters::mock::MockAdapter::GetVendor()
{
return m_vendor;
}
std::string AdapterLib::MockAdapter::GetAdapterName()
std::string
adapters::mock::MockAdapter::GetAdapterName()
{
return m_adapterName;
}
std::string AdapterLib::MockAdapter::GetVersion()
std::string
adapters::mock::MockAdapter::GetVersion()
{
return m_version;
}
std::string AdapterLib::MockAdapter::GetExposedAdapterPrefix()
std::string
adapters::mock::MockAdapter::GetExposedAdapterPrefix()
{
return m_exposedAdapterPrefix;
}
std::string AdapterLib::MockAdapter::GetExposedApplicationName()
std::string
adapters::mock::MockAdapter::GetExposedApplicationName()
{
return m_exposedApplicationName;
}
std::string AdapterLib::MockAdapter::GetExposedApplicationGuid()
std::string
adapters::mock::MockAdapter::GetExposedApplicationGuid()
{
return m_exposedApplicationGuid;
}
Bridge::AdapterSignalVector AdapterLib::MockAdapter::GetSignals()
bridge::AdapterSignalVector adapters::mock::MockAdapter::GetSignals()
{
return Bridge::AdapterSignalVector();
return bridge::AdapterSignalVector();
}
int32_t AdapterLib::MockAdapter::Initialize()
int32_t
adapters::mock::MockAdapter::Initialize()
{
CreateMockDevices();
CreateSignals();
......@@ -72,16 +79,18 @@ int32_t AdapterLib::MockAdapter::Initialize()
}
int32_t AdapterLib::MockAdapter::Shutdown()
int32_t
adapters::mock::MockAdapter::Shutdown()
{
return ER_NOT_IMPLEMENTED;
}
int32_t AdapterLib::MockAdapter::EnumDevices(
Bridge::EnumDeviceOptions /*opts*/,
Bridge::AdapterDeviceVector& deviceList,
shared_ptr<Bridge::IAdapterIoRequest>* req)
int32_t
adapters::mock::MockAdapter::EnumDevices(
bridge::EnumDeviceOptions /*opts*/,
bridge::AdapterDeviceVector& deviceList,
shared_ptr<bridge::IAdapterIoRequest>* req)
{
if (req)
req->reset();
......@@ -94,9 +103,10 @@ int32_t AdapterLib::MockAdapter::EnumDevices(
}
int32_t AdapterLib::MockAdapter::GetProperty(
shared_ptr<Bridge::IAdapterProperty>& prop,
shared_ptr<Bridge::IAdapterIoRequest>* req)
int32_t
adapters::mock::MockAdapter::GetProperty(
shared_ptr<bridge::IAdapterProperty>& prop,
shared_ptr<bridge::IAdapterIoRequest>* req)
{
if (req)
req->reset();
......@@ -119,9 +129,10 @@ int32_t AdapterLib::MockAdapter::GetProperty(
}
int32_t AdapterLib::MockAdapter::SetProperty(
shared_ptr<Bridge::IAdapterProperty> const& prop,
shared_ptr<Bridge::IAdapterIoRequest>* req)
int32_t
adapters::mock::MockAdapter::SetProperty(
shared_ptr<bridge::IAdapterProperty> const& prop,
shared_ptr<bridge::IAdapterIoRequest>* req)
{
if (req)
req ->reset();
......@@ -144,11 +155,12 @@ int32_t AdapterLib::MockAdapter::SetProperty(
}
int32_t AdapterLib::MockAdapter::GetPropertyValue(
shared_ptr<Bridge::IAdapterProperty> const& prop,
int32_t
adapters::mock::MockAdapter::GetPropertyValue(
shared_ptr<bridge::IAdapterProperty> const& prop,
std::string const& attributeName,
shared_ptr<Bridge::IAdapterValue>& value,
shared_ptr<Bridge::IAdapterIoRequest>* req)
shared_ptr<bridge::IAdapterValue>& value,
shared_ptr<bridge::IAdapterIoRequest>* req)
{
if (req)
req->reset();
......@@ -161,16 +173,17 @@ int32_t AdapterLib::MockAdapter::GetPropertyValue(
if (!attr)
return ER_INVALID_ADDRESS;
value = dynamic_pointer_cast<Bridge::IAdapterValue>(attr);
value = dynamic_pointer_cast<bridge::IAdapterValue>(attr);
return ER_OK;
}
int32_t AdapterLib::MockAdapter::SetPropertyValue(
shared_ptr<Bridge::IAdapterProperty> const& prop,
shared_ptr<Bridge::IAdapterValue> const& value,
shared_ptr<Bridge::IAdapterIoRequest>* req)
int32_t
adapters::mock::MockAdapter::SetPropertyValue(
shared_ptr<bridge::IAdapterProperty> const& prop,
shared_ptr<bridge::IAdapterValue> const& value,
shared_ptr<bridge::IAdapterIoRequest>* req)
{
if (req)
req->reset();
......@@ -189,9 +202,10 @@ int32_t AdapterLib::MockAdapter::SetPropertyValue(
}
int32_t AdapterLib::MockAdapter::CallMethod(
shared_ptr<Bridge::IAdapterMethod>& method,
shared_ptr<Bridge::IAdapterIoRequest>* req)
int32_t
adapters::mock::MockAdapter::CallMethod(
shared_ptr<bridge::IAdapterMethod>& method,
shared_ptr<bridge::IAdapterIoRequest>* req)
{
shared_ptr<MockAdapterMethod> m = dynamic_pointer_cast<MockAdapterMethod>(method);
if (!m)
......@@ -205,11 +219,12 @@ int32_t AdapterLib::MockAdapter::CallMethod(
}
int32_t AdapterLib::MockAdapter::RegisterSignalListener(
int32_t
adapters::mock::MockAdapter::RegisterSignalListener(
std::string const& signalName,
shared_ptr<Bridge::IAdapterSignalListener> const& listener,
shared_ptr<bridge::IAdapterSignalListener> const& listener,
void* argp,
Bridge::IAdapter::RegistrationHandle& handle)
bridge::IAdapter::RegistrationHandle& handle)
{
RegisteredSignal reg;
reg.Listener = listener;
......@@ -220,7 +235,8 @@ int32_t AdapterLib::MockAdapter::RegisterSignalListener(
return ER_OK;
}
int32_t AdapterLib::MockAdapter::UnregisterSignalListener(Bridge::IAdapter::RegistrationHandle const& h)
int32_t
adapters::mock::MockAdapter::UnregisterSignalListener(bridge::IAdapter::RegistrationHandle const& h)
{
int32_t st = ER_FAIL;
for (SignalMap::iterator begin = m_signalListeners.begin(), end = m_signalListeners.end();
......@@ -236,13 +252,14 @@ int32_t AdapterLib::MockAdapter::UnregisterSignalListener(Bridge::IAdapter::Regi
return st;
}
void AdapterLib::MockAdapter::CreateMockDevices()
void
adapters::mock::MockAdapter::CreateMockDevices()
{
shared_ptr<MockAdapter> self = dynamic_pointer_cast<MockAdapter>(shared_from_this());
typedef std::vector<AdapterLib::MockDeviceDescriptor> vector;
typedef std::vector<adapters::mock::MockDeviceDescriptor> vector;
vector devices = AdapterLib::GetMockDevices();
vector devices = adapters::mock::GetMockDevices();
for (vector::const_iterator begin = devices.begin(), end = devices.end();
begin != end; ++begin)
{
......@@ -251,19 +268,21 @@ void AdapterLib::MockAdapter::CreateMockDevices()
}
}
void AdapterLib::MockAdapter::CreateSignals()
void
adapters::mock::MockAdapter::CreateSignals()
{
shared_ptr<MockAdapterDevice> parent;
Bridge::AdapterValueVector values;
bridge::AdapterValueVector values;
shared_ptr<MockAdapterValue> val(new MockAdapterValue(Bridge::kDeviceArravalHandle));
shared_ptr<MockAdapterSignal> signal(new MockAdapterSignal(Bridge::kDeviceArrivalSignal,
shared_ptr<MockAdapterValue> val(new MockAdapterValue(bridge::kDeviceArravalHandle));
shared_ptr<MockAdapterSignal> signal(new MockAdapterSignal(bridge::kDeviceArrivalSignal,
parent, values));
m_signals.push_back(signal);
}
int32_t AdapterLib::MockAdapter::NotifySignalListeners(shared_ptr<MockAdapterSignal> const& signal)
int32_t
adapters::mock::MockAdapter::NotifySignalListeners(shared_ptr<MockAdapterSignal> const& signal)
{
int32_t st = ER_FAIL;
if (!signal)
......
......@@ -5,12 +5,14 @@
#include <map>
namespace AdapterLib
namespace adapters
{
namespace mock
{
class MockAdapterDevice;
class MockAdapterSignal;
class MockAdapter : public Bridge::IAdapter, public enable_shared_from_this<Bridge::IAdapter>
class MockAdapter : public bridge::IAdapter, public enable_shared_from_this<bridge::IAdapter>
{
public:
MockAdapter();
......@@ -22,46 +24,46 @@ namespace AdapterLib
virtual std::string GetExposedAdapterPrefix();
virtual std::string GetExposedApplicationName();
virtual std::string GetExposedApplicationGuid();
virtual Bridge::AdapterSignalVector GetSignals();
virtual bridge::AdapterSignalVector GetSignals();
virtual int32_t Initialize();
virtual int32_t Shutdown();
virtual int32_t EnumDevices(
Bridge::EnumDeviceOptions opts,
Bridge::AdapterDeviceVector& deviceList,
shared_ptr<Bridge::IAdapterIoRequest>* req);
bridge::EnumDeviceOptions opts,
bridge::AdapterDeviceVector& deviceList,
shared_ptr<bridge::IAdapterIoRequest>* req);
virtual int32_t GetProperty(
shared_ptr<Bridge::IAdapterProperty>& prop,
shared_ptr<Bridge::IAdapterIoRequest>* req);
shared_ptr<bridge::IAdapterProperty>& prop,
shared_ptr<bridge::IAdapterIoRequest>* req);
virtual int32_t SetProperty(
shared_ptr<Bridge::IAdapterProperty> const& prop,
shared_ptr<Bridge::IAdapterIoRequest>* req);
shared_ptr<bridge::IAdapterProperty> const& prop,
shared_ptr<bridge::IAdapterIoRequest>* req);
virtual int32_t GetPropertyValue(
shared_ptr<Bridge::IAdapterProperty> const& prop,
shared_ptr<bridge::IAdapterProperty> const& prop,
std::string const& attributeName,
shared_ptr<Bridge::IAdapterValue>& value,
shared_ptr<Bridge::IAdapterIoRequest>* req);
shared_ptr<bridge::IAdapterValue>& value,
shared_ptr<bridge::IAdapterIoRequest>* req);
virtual int32_t SetPropertyValue(
shared_ptr<Bridge::IAdapterProperty> const& prop,
shared_ptr<Bridge::IAdapterValue> const& value,
shared_ptr<Bridge::IAdapterIoRequest>* req);
shared_ptr<bridge::IAdapterProperty> const& prop,
shared_ptr<bridge::IAdapterValue> const& value,
shared_ptr<bridge::IAdapterIoRequest>* req);
virtual int32_t CallMethod(
shared_ptr<Bridge::IAdapterMethod>& method,
shared_ptr<Bridge::IAdapterIoRequest>* req);
shared_ptr<bridge::IAdapterMethod>& method,
shared_ptr<bridge::IAdapterIoRequest>* req);
virtual int32_t RegisterSignalListener(
std::string const& signalName,
shared_ptr<Bridge::IAdapterSignalListener> const& listener,
shared_ptr<bridge::IAdapterSignalListener> const& listener,
void* argp,
Bridge::IAdapter::RegistrationHandle& handle);
bridge::IAdapter::RegistrationHandle& handle);
virtual int32_t UnregisterSignalListener(Bridge::IAdapter::RegistrationHandle const& h);
virtual int32_t UnregisterSignalListener(bridge::IAdapter::RegistrationHandle const& h);
int32_t NotifySignalListeners(shared_ptr<MockAdapterSignal> const& signal);
......@@ -82,13 +84,14 @@ namespace AdapterLib
struct RegisteredSignal
{
shared_ptr<Bridge::IAdapterSignalListener> Listener;
shared_ptr<bridge::IAdapterSignalListener> Listener;
void* Context;
Bridge::IAdapter::RegistrationHandle RegHandle;
bridge::IAdapter::RegistrationHandle RegHandle;
};
typedef std::multimap<std::string, RegisteredSignal> SignalMap;
SignalMap m_signalListeners;
};
}
}
#include "Adapters/MockAdapter/MockAdapterDevice.h"
#include "Adapters/MockAdapter/MockAdapter.h"
using namespace AdapterLib;
using namespace adapters::mock;
shared_ptr<MockAdapterDevice> MockAdapterDevice::Create(
MockDeviceDescriptor const& desc,
......@@ -15,7 +15,7 @@ shared_ptr<MockAdapterDevice> MockAdapterDevice::Create(
if (descriptor.Id == kLastDescriptorId)
break;
device->m_properties.push_back(shared_ptr<Bridge::IAdapterProperty>(
device->m_properties.push_back(shared_ptr<bridge::IAdapterProperty>(
new MockAdapterProperty(descriptor, device)));
}
......@@ -40,9 +40,9 @@ MockAdapterDevice::MockAdapterDevice(MockDeviceDescriptor const& desc, weak_ptr<
void MockAdapterDevice::CreateSignals()
{
Bridge::AdapterValueVector params;
bridge::AdapterValueVector params;
m_signalPrototypes.push_back(shared_ptr<MockAdapterSignal>(new MockAdapterSignal(
Bridge::kChangeOfValueSignal, shared_from_this(), params)));
bridge::kChangeOfValueSignal, shared_from_this(), params)));
// TODO: This is incomplete, re-visit once signal emit is worked on
}
......@@ -52,13 +52,13 @@ void MockAdapterDevice::CreateMethods()
shared_ptr<MockAdapterDevice> self = shared_from_this();
shared_ptr<MockAdapterMethod> m(new MockAdapterMethod(kDeviceResetMethod, self));
m->AddInputParam(shared_ptr<Bridge::IAdapterValue>(new MockAdapterValue(kDeviceResetPropertyHandle)));
m->AddInputParam(shared_ptr<bridge::IAdapterValue>(new MockAdapterValue(kDeviceResetPropertyHandle)));
m_methods.push_back(m);
}
int32_t MockAdapterDevice::DispatchMethod(
shared_ptr<MockAdapterMethod>& method,
shared_ptr<Bridge::IAdapterIoRequest>* req)
shared_ptr<bridge::IAdapterIoRequest>* req)
{
if (req)
req->reset();
......@@ -87,7 +87,7 @@ int32_t MockAdapterDevice::SendSignal(
if (!parent)
return ER_FAIL;
typedef Bridge::AdapterSignalVector::const_iterator iterator;
typedef bridge::AdapterSignalVector::const_iterator iterator;
for (iterator begin = m_signalPrototypes.begin(), end = m_signalPrototypes.end();
((begin != end) && !signal); ++begin)
{
......@@ -103,14 +103,14 @@ int32_t MockAdapterDevice::SendSignal(
if (!signal)
return st;
if (signal->GetName() == Bridge::kChangeOfValueSignal)
if (signal->GetName() == bridge::kChangeOfValueSignal)
{
Bridge::AdapterValueVector params;
bridge::AdapterValueVector params;
shared_ptr<MockAdapterDevice> self = shared_from_this();
shared_ptr<MockAdapterValue> p(new MockAdapterValue("PropertyName"));
p->SetData(Common::Variant(prop->GetName()));
p->SetData(common::Variant(prop->GetName()));
shared_ptr<MockAdapterValue> v(new MockAdapterValue("PropertyValue"));
v->SetData(value->GetData());
......@@ -129,7 +129,7 @@ int32_t MockAdapterDevice::Reset(shared_ptr<MockAdapterMethod>& method)
{
int32_t st = ER_OK;
Bridge::AdapterValueVector const& inParams = method->GetInputParams();
bridge::AdapterValueVector const& inParams = method->GetInputParams();
if (inParams.size() == 0)
{
// reset device
......@@ -137,7 +137,7 @@ int32_t MockAdapterDevice::Reset(shared_ptr<MockAdapterMethod>& method)
else if (inParams.size() == 1)
{
// reset property by name
shared_ptr<Bridge::IAdapterValue> arg1 = inParams[0];
shared_ptr<bridge::IAdapterValue> arg1 = inParams[0];
if (!arg1)
return ER_BAD_ARG_1;
}
......@@ -182,17 +182,17 @@ std::string MockAdapterDevice::GetDescription()
return m_description;
}
Bridge::AdapterPropertyVector const& MockAdapterDevice::GetProperties() const
bridge::AdapterPropertyVector const& MockAdapterDevice::GetProperties() const
{
return m_properties;
}
Bridge::AdapterMethodVector const& MockAdapterDevice::GetMethods() const
bridge::AdapterMethodVector const& MockAdapterDevice::GetMethods() const
{
return m_methods;
}
Bridge::AdapterSignalVector const& MockAdapterDevice::GetSignals() const
bridge::AdapterSignalVector const& MockAdapterDevice::GetSignals() const
{
return m_signalPrototypes;
}
......@@ -211,7 +211,7 @@ std::string MockAdapterProperty::GetName()
shared_ptr<MockAdapterValue> MockAdapterProperty::GetAttributeByName(std::string const& name)
{
typedef Bridge::AdapterValueVector::const_iterator iterator;
typedef bridge::AdapterValueVector::const_iterator iterator;
for (iterator begin = m_attributes.begin(), end = m_attributes.end(); begin != end; ++begin)
{
if ((*begin)->GetName() == name)
......@@ -221,7 +221,7 @@ shared_ptr<MockAdapterValue> MockAdapterProperty::GetAttributeByName(std::string
}
Bridge::AdapterValueVector MockAdapterProperty::GetAttributes()
bridge::AdapterValueVector MockAdapterProperty::GetAttributes()
{
return m_attributes;
}
......@@ -247,32 +247,32 @@ std::string MockAdapterMethod::GetDescription()
return m_description;
}
Bridge::AdapterValueVector const& MockAdapterMethod::GetInputParams() const
bridge::AdapterValueVector const& MockAdapterMethod::GetInputParams() const
{
return m_inputParams;
}
Bridge::AdapterValueVector const& MockAdapterMethod::GetOutputParams() const
bridge::AdapterValueVector const& MockAdapterMethod::GetOutputParams() const
{
return m_outputParams;
}
void MockAdapterMethod::SetInputParams(Bridge::AdapterValueVector const& params)
void MockAdapterMethod::SetInputParams(bridge::AdapterValueVector const& params)
{
m_inputParams = params;
}
void MockAdapterMethod::SetOutputParams(Bridge::AdapterValueVector const& params)
void MockAdapterMethod::SetOutputParams(bridge::AdapterValueVector const& params)
{
m_outputParams = params;
}
void MockAdapterMethod::AddInputParam(shared_ptr<Bridge::IAdapterValue> const& p)
void MockAdapterMethod::AddInputParam(shared_ptr<bridge::IAdapterValue> const& p)
{
m_inputParams.push_back(p);
}
void MockAdapterMethod::AddOutputParam(shared_ptr<Bridge::IAdapterValue> const& p)
void MockAdapterMethod::AddOutputParam(shared_ptr<bridge::IAdapterValue> const& p)
{
m_outputParams.push_back(p);
}
......@@ -298,12 +298,12 @@ std::string MockAdapterValue::GetName()
return m_name;
}
Common::Variant MockAdapterValue::GetData()
common::Variant MockAdapterValue::GetData()
{
return m_data;
}
void MockAdapterValue::SetData(Common::Variant const& v)
void MockAdapterValue::SetData(common::Variant const& v)
{
m_data = v;
}
......@@ -311,7 +311,7 @@ void MockAdapterValue::SetData(Common::Variant const& v)
MockAdapterSignal::MockAdapterSignal(
std::string const& name,
weak_ptr<MockAdapterDevice> const& parent,
Bridge::AdapterValueVector const& params)
bridge::AdapterValueVector const& params)
: m_name(name)
, m_parent(parent)
, m_params(params)
......@@ -333,7 +333,7 @@ std::string MockAdapterSignal::GetName() const
return m_name;
}
Bridge::AdapterValueVector const& MockAdapterSignal::GetParams() const
bridge::AdapterValueVector const& MockAdapterSignal::GetParams() const
{
return m_params;
}
......
......@@ -3,7 +3,9 @@
#include "Adapters/MockAdapter/MockDevices.h"
#include "Bridge/IAdapter.h"
namespace AdapterLib
namespace adapters
{
namespace mock
{
std::string const kDeviceResetMethod = "Device_Reset";
std::string const kDeviceResetPropertyHandle = "Property_Handle";
......@@ -13,26 +15,26 @@ namespace AdapterLib
class MockAdapterDevice;
class MockAdapterValue;
class MockAdapterSignal : public Bridge::IAdapterSignal
class MockAdapterSignal : public bridge::IAdapterSignal
{
public:
MockAdapterSignal(
std::string const& name,
weak_ptr<MockAdapterDevice> const& parent,
Bridge::AdapterValueVector const& params);
bridge::AdapterValueVector const& params);
virtual std::string GetName() const;
virtual Bridge::AdapterValueVector const& GetParams() const;
virtual bridge::AdapterValueVector const& GetParams() const;
shared_ptr<MockAdapterSignal> Clone();
private:
std::string m_name;
weak_ptr<MockAdapterDevice> m_parent;
Bridge::AdapterValueVector m_params;
bridge::AdapterValueVector m_params;
};
class MockAdapterMethod : public Bridge::IAdapterMethod
class MockAdapterMethod : public bridge::IAdapterMethod
{
friend class MockAdapter;
......@@ -42,14 +44,14 @@ namespace AdapterLib
virtual std::string GetName() const;
virtual std::string GetDescription();
virtual Bridge::AdapterValueVector const& GetInputParams() const;
virtual Bridge::AdapterValueVector const& GetOutputParams() const;
virtual bridge::AdapterValueVector const& GetInputParams() const;
virtual bridge::AdapterValueVector const& GetOutputParams() const;
virtual void SetInputParams(Bridge::AdapterValueVector const& params);
virtual void SetOutputParams(Bridge::AdapterValueVector const& params);
virtual void SetInputParams(bridge::AdapterValueVector const& params);
virtual void SetOutputParams(bridge::AdapterValueVector const& params);
void AddInputParam(shared_ptr<Bridge::IAdapterValue> const& p);
void AddOutputParam(shared_ptr<Bridge::IAdapterValue> const& p);
void AddInputParam(shared_ptr<bridge::IAdapterValue> const& p);
void AddOutputParam(shared_ptr<bridge::IAdapterValue> const& p);
virtual int32_t GetResult();
void SetResult(int32_t st);
......@@ -61,19 +63,19 @@ namespace AdapterLib
private:
std::string m_name;
std::string m_description;
Bridge::AdapterValueVector m_inputParams;
Bridge::AdapterValueVector m_outputParams;
bridge::AdapterValueVector m_inputParams;
bridge::AdapterValueVector m_outputParams;
weak_ptr<MockAdapterDevice> m_parent;
int32_t m_result;
};
class MockAdapterProperty : public