Commit 081516d8 authored by jacobgladish's avatar jacobgladish

Re-factored some MockAdapter source files.

parent 98e53134
......@@ -2,6 +2,7 @@
#include "MockDevices.h"
#include "MockAdapterDevice.h"
#include "MockAdapterSignal.h"
#include "Common/Log.h"
#include <algorithm>
......
#include "Adapters/MockAdapter/MockAdapterDevice.h"
#include "Adapters/MockAdapter/MockAdapterSignal.h"
#include "Adapters/MockAdapter/MockAdapter.h"
using namespace adapters::mock;
......@@ -201,146 +202,3 @@ bridge::AdapterSignalVector const& MockAdapterDevice::GetSignals() const
{
return m_signalPrototypes;
}
MockAdapterProperty::MockAdapterProperty( MockPropertyDescriptor const& desc,
std::weak_ptr<MockAdapterDevice> const& parent)
: m_name(desc.Name)
, m_parent(parent)
{
}
std::string MockAdapterProperty::GetName()
{
return m_name;
}
std::shared_ptr<MockAdapterValue> MockAdapterProperty::GetAttributeByName(std::string const& name)
{
typedef bridge::AdapterValueVector::const_iterator iterator;
for (iterator begin = m_attributes.begin(), end = m_attributes.end(); begin != end; ++begin)
{
if ((*begin)->GetName() == name)
return std::dynamic_pointer_cast<MockAdapterValue>(*begin);
}
return std::shared_ptr<MockAdapterValue>();
}
bridge::AdapterValueVector MockAdapterProperty::GetAttributes()
{
return m_attributes;
}
// MockAdapterMethod
MockAdapterMethod::MockAdapterMethod(
std::string const& name,
std::weak_ptr<MockAdapterDevice> const& parent)
: m_name(name)
, m_parent(parent)
{
}
std::string MockAdapterMethod::GetName() const
{
return m_name;
}
std::string MockAdapterMethod::GetDescription()
{
return m_description;
}
bridge::AdapterValueVector const& MockAdapterMethod::GetInputParams() const
{
return m_inputParams;
}
bridge::AdapterValueVector const& MockAdapterMethod::GetOutputParams() const
{
return m_outputParams;
}
void MockAdapterMethod::SetInputParams(bridge::AdapterValueVector const& params)
{
m_inputParams = params;
}
void MockAdapterMethod::SetOutputParams(bridge::AdapterValueVector const& params)
{
m_outputParams = params;
}
void MockAdapterMethod::AddInputParam(std::shared_ptr<bridge::IAdapterValue> const& p)
{
m_inputParams.push_back(p);
}
void MockAdapterMethod::AddOutputParam(std::shared_ptr<bridge::IAdapterValue> const& p)
{
m_outputParams.push_back(p);
}
int32_t MockAdapterMethod::GetResult()
{
return m_result;
}
void MockAdapterMethod::SetResult(int32_t st)
{
m_result = st;
}
MockAdapterValue::MockAdapterValue(std::string const& name)
: m_name(name)
{
}
std::string MockAdapterValue::GetName()
{
return m_name;
}
common::Variant const& MockAdapterValue::GetData() const
{
return m_data;
}
void MockAdapterValue::SetData(common::Variant const& v)
{
m_data = v;
}
MockAdapterSignal::MockAdapterSignal(
std::string const& name,
std::weak_ptr<MockAdapterDevice> const& parent,
bridge::AdapterValueVector const& params)
: m_name(name)
, m_parent(parent)
, m_params(params)
{
}
std::shared_ptr<MockAdapterSignal> MockAdapterSignal::Clone()
{
std::shared_ptr<MockAdapterSignal> clone(new MockAdapterSignal(
m_name,
m_parent,
m_params));
return clone;
}
std::string MockAdapterSignal::GetName() const
{
return m_name;
}
bridge::AdapterValueVector const& MockAdapterSignal::GetParams() const
{
return m_params;
}
#pragma once
#include "Adapters/MockAdapter/MockDevices.h"
#include "Adapters/MockAdapter/MockAdapterMethod.h"
#include "Adapters/MockAdapter/MockAdapterProperty.h"
#include "Adapters/MockAdapter/MockAdapterSignal.h"
#include "Adapters/MockAdapter/MockAdapterValue.h"
#include "Bridge/IAdapter.h"
#include <memory>
......@@ -17,96 +22,6 @@ namespace mock
class MockAdapterDevice;
class MockAdapterValue;
class MockAdapterSignal : public bridge::IAdapterSignal
{
public:
MockAdapterSignal(
std::string const& name,
std::weak_ptr<MockAdapterDevice> const& parent,
bridge::AdapterValueVector const& params);
virtual std::string GetName() const;
virtual bridge::AdapterValueVector const& GetParams() const;
std::shared_ptr<MockAdapterSignal> Clone();
private:
std::string m_name;
std::weak_ptr<MockAdapterDevice> m_parent;
bridge::AdapterValueVector m_params;
};
class MockAdapterMethod : public bridge::IAdapterMethod
{
friend class MockAdapter;
public:
MockAdapterMethod(std::string const& name, std::weak_ptr<MockAdapterDevice> const& parent);
virtual std::string GetName() const;
virtual std::string GetDescription();
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);
void AddInputParam(std::shared_ptr<bridge::IAdapterValue> const& p);
void AddOutputParam(std::shared_ptr<bridge::IAdapterValue> const& p);
virtual int32_t GetResult();
void SetResult(int32_t st);
private:
std::shared_ptr<MockAdapterDevice> GetParent() const
{ return m_parent.lock(); }
private:
std::string m_name;
std::string m_description;
bridge::AdapterValueVector m_inputParams;
bridge::AdapterValueVector m_outputParams;
std::weak_ptr<MockAdapterDevice> m_parent;
int32_t m_result;
};
class MockAdapterProperty : public bridge::IAdapterProperty
{
public:
MockAdapterProperty(MockPropertyDescriptor const& desc, std::weak_ptr<MockAdapterDevice> const& parent);
virtual std::string GetName();
virtual std::string GetInterfaceHint()
{ return std::string(""); }
virtual bridge::AdapterValueVector GetAttributes();
std::shared_ptr<MockAdapterDevice> GetParent()
{ return m_parent.lock(); }
std::shared_ptr<MockAdapterValue> GetAttributeByName(std::string const& name);
private:
std::string m_name;
bridge::AdapterValueVector m_attributes;
std::weak_ptr<MockAdapterDevice> m_parent;
};
class MockAdapterValue : public bridge::IAdapterValue
{
public:
MockAdapterValue(std::string const& name);
virtual std::string GetName();
virtual common::Variant const& GetData() const;
virtual void SetData(common::Variant const& v);
private:
std::string m_name;
common::Variant m_data;
};
class MockAdapterDevice : public bridge::IAdapterDevice, public std::enable_shared_from_this<MockAdapterDevice>
{
public:
......
#include "Adapters/MockAdapter/MockAdapterMethod.h"
using namespace adapters::mock;
MockAdapterMethod::MockAdapterMethod(
std::string const& name,
std::weak_ptr<MockAdapterDevice> const& parent)
: m_name(name)
, m_parent(parent)
{
}
std::string
MockAdapterMethod::GetName() const
{
return m_name;
}
std::string
MockAdapterMethod::GetDescription()
{
return m_description;
}
bridge::AdapterValueVector const&
MockAdapterMethod::GetInputParams() const
{
return m_inputParams;
}
bridge::AdapterValueVector const&
MockAdapterMethod::GetOutputParams() const
{
return m_outputParams;
}
void
MockAdapterMethod::SetInputParams(bridge::AdapterValueVector const& params)
{
m_inputParams = params;
}
void
MockAdapterMethod::SetOutputParams(bridge::AdapterValueVector const& params)
{
m_outputParams = params;
}
void
MockAdapterMethod::AddInputParam(std::shared_ptr<bridge::IAdapterValue> const& p)
{
m_inputParams.push_back(p);
}
void
MockAdapterMethod::AddOutputParam(std::shared_ptr<bridge::IAdapterValue> const& p)
{
m_outputParams.push_back(p);
}
int32_t
MockAdapterMethod::GetResult()
{
return m_result;
}
void
MockAdapterMethod::SetResult(int32_t st)
{
m_result = st;
}
#pragma once
#include "Bridge/IAdapter.h"
namespace adapters
{
namespace mock
{
class MockAdapterDevice;
class MockAdapterMethod : public bridge::IAdapterMethod
{
friend class MockAdapter;
public:
MockAdapterMethod(std::string const& name, std::weak_ptr<MockAdapterDevice> const& parent);
virtual std::string GetName() const;
virtual std::string GetDescription();
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);
void AddInputParam(std::shared_ptr<bridge::IAdapterValue> const& p);
void AddOutputParam(std::shared_ptr<bridge::IAdapterValue> const& p);
virtual int32_t GetResult();
void SetResult(int32_t st);
private:
std::shared_ptr<MockAdapterDevice> GetParent() const
{ return m_parent.lock(); }
private:
std::string m_name;
std::string m_description;
bridge::AdapterValueVector m_inputParams;
bridge::AdapterValueVector m_outputParams;
std::weak_ptr<MockAdapterDevice> m_parent;
int32_t m_result;
};
}
}
#include "Adapters/MockAdapter/MockAdapterProperty.h"
#include "Adapters/MockAdapter/MockAdapterValue.h"
#include "Adapters/MockAdapter/MockDevices.h"
using namespace adapters::mock;
MockAdapterProperty::MockAdapterProperty( MockPropertyDescriptor const& desc,
std::weak_ptr<MockAdapterDevice> const& parent)
: m_name(desc.Name)
, m_parent(parent)
{
}
std::string
MockAdapterProperty::GetName()
{
return m_name;
}
std::shared_ptr<MockAdapterValue>
MockAdapterProperty::GetAttributeByName(std::string const& name)
{
typedef bridge::AdapterValueVector::const_iterator iterator;
for (iterator begin = m_attributes.begin(), end = m_attributes.end(); begin != end; ++begin)
{
if ((*begin)->GetName() == name)
return std::dynamic_pointer_cast<MockAdapterValue>(*begin);
}
return std::shared_ptr<MockAdapterValue>();
}
bridge::AdapterValueVector
MockAdapterProperty::GetAttributes()
{
return m_attributes;
}
#pragma once
#include "Bridge/IAdapter.h"
namespace adapters
{
namespace mock
{
class MockAdapterValue;
class MockPropertyDescriptor;
class MockAdapterDevice;
class MockAdapterProperty : public bridge::IAdapterProperty
{
public:
MockAdapterProperty(MockPropertyDescriptor const& desc, std::weak_ptr<MockAdapterDevice> const& parent);
virtual std::string GetName();
virtual std::string GetInterfaceHint()
{ return std::string(""); }
virtual bridge::AdapterValueVector GetAttributes();
std::shared_ptr<MockAdapterDevice> GetParent()
{ return m_parent.lock(); }
std::shared_ptr<MockAdapterValue> GetAttributeByName(std::string const& name);
private:
std::string m_name;
bridge::AdapterValueVector m_attributes;
std::weak_ptr<MockAdapterDevice> m_parent;
};
}
}
#include "Adapters/MockAdapter/MockAdapterSignal.h"
using namespace adapters::mock;
MockAdapterSignal::MockAdapterSignal(
std::string const& name,
std::weak_ptr<MockAdapterDevice> const& parent,
bridge::AdapterValueVector const& params)
: m_name(name)
, m_parent(parent)
, m_params(params)
{
}
std::shared_ptr<MockAdapterSignal>
MockAdapterSignal::Clone()
{
std::shared_ptr<MockAdapterSignal> clone(new MockAdapterSignal(
m_name,
m_parent,
m_params));
return clone;
}
std::string
MockAdapterSignal::GetName() const
{
return m_name;
}
bridge::AdapterValueVector const&
MockAdapterSignal::GetParams() const
{
return m_params;
}
#pragma once
#include "Bridge/IAdapter.h"
#include <memory>
#include <string>
namespace adapters
{
namespace mock
{
class MockAdapterDevice;
class MockAdapterSignal : public bridge::IAdapterSignal
{
public:
MockAdapterSignal(
std::string const& name,
std::weak_ptr<MockAdapterDevice> const& parent,
bridge::AdapterValueVector const& params);
virtual std::string GetName() const;
virtual bridge::AdapterValueVector const& GetParams() const;
std::shared_ptr<MockAdapterSignal> Clone();
private:
std::string m_name;
std::weak_ptr<MockAdapterDevice> m_parent;
bridge::AdapterValueVector m_params;
};
}
}
#include "Adapters/MockAdapter/MockAdapterValue.h"
using namespace adapters::mock;
MockAdapterValue::MockAdapterValue(std::string const& name)
: m_name(name)
{
}
std::string
MockAdapterValue::GetName()
{
return m_name;
}
common::Variant const&
MockAdapterValue::GetData() const
{
return m_data;
}
void
MockAdapterValue::SetData(common::Variant const& v)
{
m_data = v;
}
#pragma once
#include "Bridge/IAdapter.h"
namespace adapters
{
namespace mock
{
class MockAdapterValue : public bridge::IAdapterValue
{
public:
MockAdapterValue(std::string const& name);
virtual std::string GetName();
virtual common::Variant const& GetData() const;
virtual void SetData(common::Variant const& v);
private:
std::string m_name;
common::Variant m_data;
};
}
}
......@@ -17,6 +17,10 @@ SRCS=DeviceProviders/AllJoynProvider.cpp \
Adapters/MockAdapter/MockAdapter.cpp \
Adapters/MockAdapter/MockDevices.cpp \
Adapters/MockAdapter/MockAdapterDevice.cpp \
Adapters/MockAdapter/MockAdapterMethod.cpp \
Adapters/MockAdapter/MockAdapterProperty.cpp \
Adapters/MockAdapter/MockAdapterSignal.cpp \
Adapters/MockAdapter/MockAdapterValue.cpp \
Adapters/ZigBeeAdapter/ZigBeeAdapter.cpp \
main.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