Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
portabledsb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
External Wiki
External Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
App_Technologies
portabledsb
Commits
2f3b73bb
Commit
2f3b73bb
authored
Aug 08, 2015
by
gladish
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added signal listener reg/unreg
parent
94dcadbe
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
107 additions
and
30 deletions
+107
-30
Adapters/MockAdapter/MockAdapter.cpp
Adapters/MockAdapter/MockAdapter.cpp
+43
-8
Adapters/MockAdapter/MockAdapter.h
Adapters/MockAdapter/MockAdapter.h
+20
-6
Adapters/MockAdapter/MockAdapterDevice.cpp
Adapters/MockAdapter/MockAdapterDevice.cpp
+31
-7
Adapters/MockAdapter/MockAdapterDevice.h
Adapters/MockAdapter/MockAdapterDevice.h
+7
-4
Bridge/IAdapter.h
Bridge/IAdapter.h
+6
-5
No files found.
Adapters/MockAdapter/MockAdapter.cpp
View file @
2f3b73bb
...
...
@@ -2,12 +2,21 @@
#include "Adapters/MockAdapter/MockDevices.h"
#include "Adapters/MockAdapter/MockAdapterDevice.h"
namespace
{
Bridge
::
IAdapter
::
RegistrationHandle
nextHandle
=
0
;
Bridge
::
IAdapter
::
RegistrationHandle
GetNextRegistrationHandle
()
{
return
++
nextHandle
;
}
}
AdapterLib
::
MockAdapter
::
MockAdapter
()
:
m_vendor
(
"Acme"
)
,
m_adapterName
(
"DSB Mock Adapter"
)
,
m_exposedAdapterPrefix
(
"com."
+
m_vendor
)
,
m_exposedApplicationGuid
(
"C27BC425-0058-4829-8775-441B5D8740C0"
)
,
m_exposedApplicationName
(
"DeviceSystemBridge"
)
,
m_exposedApplicationGuid
(
"C27BC425-0058-4829-8775-441B5D8740C0"
)
{
// TODO: get m_exposedApplicatioName and Prefix from config
}
...
...
@@ -127,18 +136,36 @@ QStatus AdapterLib::MockAdapter::CallMethod(
QStatus
AdapterLib
::
MockAdapter
::
RegisterSignalListener
(
s
hared_ptr
<
Bridge
::
IAdapterSignal
>
const
&
signal
,
s
td
::
string
const
&
signalName
,
shared_ptr
<
Bridge
::
IAdapterSignalListener
>
const
&
listener
,
void
*
argp
)
void
*
argp
,
Bridge
::
IAdapter
::
RegistrationHandle
&
handle
)
{
return
ER_NOT_IMPLEMENTED
;
RegisteredSignal
reg
;
reg
.
Listener
=
listener
;
reg
.
Context
=
argp
;
reg
.
RegHandle
=
GetNextRegistrationHandle
();
m_signalListeners
.
insert
(
SignalMap
::
value_type
(
signalName
,
reg
));
handle
=
reg
.
RegHandle
;
return
ER_OK
;
}
QStatus
AdapterLib
::
MockAdapter
::
UnregisterSignalListener
(
shared_ptr
<
Bridge
::
IAdapterSignal
>
const
&
signal
,
shared_ptr
<
Bridge
::
IAdapterSignalListener
>
const
&
listener
)
QStatus
AdapterLib
::
MockAdapter
::
UnregisterSignalListener
(
Bridge
::
IAdapter
::
RegistrationHandle
const
&
h
)
{
QStatus
st
=
ER_FAIL
;
for
(
SignalMap
::
iterator
begin
=
m_signalListeners
.
begin
(),
end
=
m_signalListeners
.
end
();
begin
!=
end
;
++
begin
)
{
if
(
begin
->
second
.
RegHandle
==
h
)
{
m_signalListeners
.
erase
(
begin
);
st
=
ER_OK
;
break
;
}
}
return
st
;
return
ER_NOT_IMPLEMENTED
;
}
...
...
@@ -150,7 +177,8 @@ void AdapterLib::MockAdapter::CreateMockDevices()
for
(
vector
::
const_iterator
begin
=
devices
.
begin
(),
end
=
devices
.
end
();
begin
!=
end
;
++
begin
)
{
shared_ptr
<
MockAdapterDevice
>
dev
(
new
MockAdapterDevice
(
*
begin
,
*
this
));
shared_ptr
<
MockAdapter
>
self
=
shared_from_this
();
shared_ptr
<
MockAdapterDevice
>
dev
(
new
MockAdapterDevice
(
*
begin
,
self
));
// TODO
}
}
...
...
@@ -159,4 +187,11 @@ void AdapterLib::MockAdapter::CreateSignals()
{
}
QStatus
AdapterLib
::
MockAdapter
::
NotifySignalListeners
(
shared_ptr
<
MockAdapterSignal
>
const
&
signal
)
{
QStatus
st
=
ER_OK
;
return
st
;
}
Adapters/MockAdapter/MockAdapter.h
View file @
2f3b73bb
...
...
@@ -3,11 +3,14 @@
#include "Bridge/IAdapter.h"
#include "Common/defines.h"
#include <map>
namespace
AdapterLib
{
class
MockAdapterDevice
;
class
MockAdapterSignal
;
class
MockAdapter
:
public
Bridge
::
IAdapter
,
public
enable_shared_from_this
<
Bridge
::
I
Adapter
>
class
MockAdapter
:
public
Bridge
::
IAdapter
,
public
enable_shared_from_this
<
Mock
Adapter
>
{
public:
MockAdapter
();
...
...
@@ -53,13 +56,14 @@ namespace AdapterLib
Bridge
::
IAdapterIoRequest
**
req
);
virtual
QStatus
RegisterSignalListener
(
s
hared_ptr
<
Bridge
::
IAdapterSignal
>
const
&
signal
,
s
td
::
string
const
&
signalName
,
shared_ptr
<
Bridge
::
IAdapterSignalListener
>
const
&
listener
,
void
*
argp
);
void
*
argp
,
Bridge
::
IAdapter
::
RegistrationHandle
&
handle
);
virtual
QStatus
UnregisterSignalListener
(
Bridge
::
IAdapter
::
RegistrationHandle
const
&
h
);
virtual
QStatus
UnregisterSignalListener
(
shared_ptr
<
Bridge
::
IAdapterSignal
>
const
&
signal
,
shared_ptr
<
Bridge
::
IAdapterSignalListener
>
const
&
listener
);
QStatus
NotifySignalListeners
(
shared_ptr
<
MockAdapterSignal
>
const
&
signal
);
private:
void
CreateMockDevices
();
...
...
@@ -74,6 +78,16 @@ namespace AdapterLib
std
::
string
m_exposedApplicationGuid
;
std
::
vector
<
shared_ptr
<
MockAdapterDevice
>
>
m_devices
;
struct
RegisteredSignal
{
shared_ptr
<
Bridge
::
IAdapterSignalListener
>
Listener
;
void
*
Context
;
Bridge
::
IAdapter
::
RegistrationHandle
RegHandle
;
};
typedef
std
::
multimap
<
std
::
string
,
RegisteredSignal
>
SignalMap
;
SignalMap
m_signalListeners
;
};
}
Adapters/MockAdapter/MockAdapterDevice.cpp
View file @
2f3b73bb
#include "Adapters/MockAdapter/MockAdapterDevice.h"
#include "Adapters/MockAdapter/MockAdapter.h"
using
namespace
AdapterLib
;
MockAdapterDevice
::
MockAdapterDevice
(
MockDeviceDescriptor
const
&
desc
,
Bridge
::
IAdapter
const
&
parent
)
MockAdapterDevice
::
MockAdapterDevice
(
MockDeviceDescriptor
const
&
desc
,
shared_ptr
<
MockAdapter
>
const
&
parent
)
:
m_name
(
desc
.
Name
)
,
m_parent
(
parent
)
,
m_vendor
(
desc
.
VendorName
)
...
...
@@ -61,16 +60,19 @@ QStatus MockAdapterDevice::DispatchMethod(
QStatus
MockAdapterDevice
::
SendSignal
(
std
::
string
const
&
signalName
,
shared_ptr
<
MockAdapterProperty
>
const
&
prop
,
shared_ptr
<
MockAdapterValue
>
const
&
attr
)
shared_ptr
<
MockAdapterValue
>
const
&
value
)
{
if
(
!
prop
)
return
ER_BAD_ARG_2
;
if
(
!
attr
)
if
(
!
value
)
return
ER_BAD_ARG_3
;
QStatus
st
=
ER_FAIL
;
shared_ptr
<
MockAdapterSignal
>
signal
;
shared_ptr
<
MockAdapter
>
parent
=
m_parent
.
lock
();
if
(
!
parent
)
return
ER_FAIL
;
typedef
Bridge
::
AdapterSignalVector
::
const_iterator
iterator
;
for
(
iterator
begin
=
m_signalPrototypes
.
begin
(),
end
=
m_signalPrototypes
.
end
();
...
...
@@ -78,20 +80,33 @@ QStatus MockAdapterDevice::SendSignal(
{
if
((
*
begin
)
->
GetName
()
==
signalName
)
{
// TODO: clone
signal
=
dynamic_pointer_cast
<
MockAdapterSignal
>
(
*
begin
);
DSB_ASSERT
(
signal
!=
NULL
);
if
(
signal
)
signal
=
signal
->
Clone
();
}
}
if
(
!
signal
)
return
st
;
// TODO: Continue here
if
(
signal
->
GetName
()
==
Bridge
::
kChangeOfValueSignal
)
{
Bridge
::
AdapterValueVector
params
;
shared_ptr
<
MockAdapterValue
>
p
(
new
MockAdapterValue
(
"PropertyName"
,
*
this
));
p
->
SetData
(
ajn
::
MsgArg
(
"s"
,
prop
->
GetName
().
c_str
(),
NULL
));
shared_ptr
<
MockAdapterValue
>
v
(
new
MockAdapterValue
(
"PropertyValue"
,
*
this
));
v
->
SetData
(
value
->
GetData
());
params
.
push_back
(
p
);
params
.
push_back
(
v
);
}
if
(
signal
)
parent
->
NotifySignalListeners
(
signal
);
return
st
;
}
...
...
@@ -277,6 +292,15 @@ MockAdapterSignal::MockAdapterSignal(
{
}
shared_ptr
<
MockAdapterSignal
>
MockAdapterSignal
::
Clone
()
{
shared_ptr
<
MockAdapterSignal
>
clone
(
new
MockAdapterSignal
(
m_name
,
m_parent
,
m_params
));
return
clone
;
}
std
::
string
MockAdapterSignal
::
GetName
()
const
{
...
...
Adapters/MockAdapter/MockAdapterDevice.h
View file @
2f3b73bb
...
...
@@ -9,6 +9,7 @@ namespace AdapterLib
std
::
string
const
kDeviceResetPropertyHandle
=
"Property_Handle"
;
std
::
string
const
kDsbMethodReturnValue
=
"Return_Value"
;
class
MockAdapter
;
class
MockAdapterDevice
;
class
MockAdapterSignal
:
public
Bridge
::
IAdapterSignal
...
...
@@ -22,6 +23,10 @@ namespace AdapterLib
virtual
std
::
string
GetName
()
const
;
virtual
Bridge
::
AdapterValueVector
const
&
GetParams
()
const
;
void
SetParams
(
Bridge
::
AdapterValueVector
const
&
params
);
shared_ptr
<
MockAdapterSignal
>
Clone
();
private:
std
::
string
m_name
;
Bridge
::
IAdapterDevice
const
&
m_parent
;
...
...
@@ -96,9 +101,7 @@ namespace AdapterLib
class
MockAdapterDevice
:
public
Bridge
::
IAdapterDevice
,
public
enable_shared_from_this
<
MockAdapterDevice
>
{
public:
MockAdapterDevice
(
MockDeviceDescriptor
const
&
desc
,
Bridge
::
IAdapter
const
&
parent
);
MockAdapterDevice
(
MockDeviceDescriptor
const
&
desc
,
shared_ptr
<
MockAdapter
>
const
&
parent
);
virtual
std
::
string
GetName
();
virtual
std
::
string
GetVendor
();
...
...
@@ -129,7 +132,7 @@ namespace AdapterLib
private:
std
::
string
m_name
;
Bridge
::
IAdapter
const
&
m_parent
;
weak_ptr
<
MockAdapter
>
m_parent
;
std
::
string
m_vendor
;
std
::
string
m_model
;
std
::
string
m_version
;
...
...
Bridge/IAdapter.h
View file @
2f3b73bb
...
...
@@ -115,6 +115,8 @@ namespace Bridge
protected:
IAdapter
()
{
}
public:
typedef
int32_t
RegistrationHandle
;
virtual
~
IAdapter
()
{
}
virtual
std
::
string
GetVendor
()
=
0
;
virtual
std
::
string
GetAdapterName
()
=
0
;
...
...
@@ -156,13 +158,12 @@ namespace Bridge
IAdapterIoRequest
**
req
)
=
0
;
virtual
QStatus
RegisterSignalListener
(
s
hared_ptr
<
IAdapterSignal
>
const
&
signal
,
s
td
::
string
const
&
signalName
,
shared_ptr
<
IAdapterSignalListener
>
const
&
listener
,
void
*
argp
)
=
0
;
void
*
argp
,
RegistrationHandle
&
handle
)
=
0
;
virtual
QStatus
UnregisterSignalListener
(
shared_ptr
<
IAdapterSignal
>
const
&
signal
,
shared_ptr
<
IAdapterSignalListener
>
const
&
listener
)
=
0
;
virtual
QStatus
UnregisterSignalListener
(
RegistrationHandle
const
&
h
)
=
0
;
};
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment