Merge lp:~marcustomlinson/dspatch/get_return_ptr into lp:dspatch

Proposed by Marcus Tomlinson
Status: Superseded
Proposed branch: lp:~marcustomlinson/dspatch/get_return_ptr
Merge into: lp:dspatch
Diff against target: 124 lines (+67/-0)
4 files modified
include/dspatch/DspComponent.h (+1/-0)
include/dspatch/DspSignal.h (+18/-0)
include/dspatch/DspSignalBus.h (+38/-0)
src/DspComponent.cpp (+10/-0)
To merge this branch: bzr merge lp:~marcustomlinson/dspatch/get_return_ptr
Reviewer Review Type Date Requested Status
Marcus Tomlinson Pending
Review via email: mp+228387@code.launchpad.net

Commit message

Added alternative Get* methods that return const pointers rather than expecting a reference parameter.

To post a comment you must log in.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/dspatch/DspComponent.h'
2--- include/dspatch/DspComponent.h 2014-06-16 15:31:48 +0000
3+++ include/dspatch/DspComponent.h 2014-07-26 08:04:03 +0000
4@@ -120,6 +120,7 @@
5 std::string GetParameterName( unsigned short index );
6
7 bool GetParameter( std::string const& paramName, DspParameter& param );
8+ DspParameter const* GetParameter( std::string const& paramName );
9 bool SetParameter( std::string const& paramName, DspParameter const& param );
10
11 void Tick();
12
13=== modified file 'include/dspatch/DspSignal.h'
14--- include/dspatch/DspSignal.h 2014-04-08 13:23:50 +0000
15+++ include/dspatch/DspSignal.h 2014-07-26 08:04:03 +0000
16@@ -59,6 +59,9 @@
17 template< class ValueType >
18 bool GetValue( ValueType& returnValue ) const;
19
20+ template< class ValueType >
21+ ValueType const* GetValue() const;
22+
23 bool SetSignal( DspSignal const* newSignal );
24
25 void ClearValue();
26@@ -107,6 +110,21 @@
27 }
28 }
29
30+//-------------------------------------------------------------------------------------------------
31+
32+template< class ValueType >
33+ValueType const* DspSignal::GetValue() const
34+{
35+ if( _valueAvailable )
36+ {
37+ return DspRunType::RunTypeCast< ValueType >( &_signalValue );
38+ }
39+ else
40+ {
41+ return NULL; // no value available
42+ }
43+}
44+
45 //=================================================================================================
46
47 #endif // DSPSIGNAL_H
48
49=== modified file 'include/dspatch/DspSignalBus.h'
50--- include/dspatch/DspSignalBus.h 2014-04-08 13:23:50 +0000
51+++ include/dspatch/DspSignalBus.h 2014-07-26 08:04:03 +0000
52@@ -68,6 +68,12 @@
53 template< class ValueType >
54 bool GetValue( std::string const& signalName, ValueType& returnValue ) const;
55
56+ template< class ValueType >
57+ ValueType const* GetValue( unsigned short signalIndex ) const;
58+
59+ template< class ValueType >
60+ ValueType const* GetValue( std::string const& signalName ) const;
61+
62 void ClearValue( unsigned short signalIndex );
63 void ClearValue( std::string const& signalName );
64
65@@ -149,6 +155,38 @@
66 }
67 }
68
69+//-------------------------------------------------------------------------------------------------
70+
71+template< class ValueType >
72+ValueType const* DspSignalBus::GetValue( unsigned short signalIndex ) const
73+{
74+ if( signalIndex < _signals.size() )
75+ {
76+ return _signals[signalIndex].GetValue< ValueType >();
77+ }
78+ else
79+ {
80+ return NULL;
81+ }
82+}
83+
84+//-------------------------------------------------------------------------------------------------
85+
86+template< class ValueType >
87+ValueType const* DspSignalBus::GetValue( std::string const& signalName ) const
88+{
89+ unsigned short signalIndex;
90+
91+ if( FindSignal( signalName, signalIndex ) )
92+ {
93+ return _signals[signalIndex].GetValue< ValueType >();
94+ }
95+ else
96+ {
97+ return NULL;
98+ }
99+}
100+
101 //=================================================================================================
102
103 #endif // DSPSIGNALBUS_H
104
105=== modified file 'src/DspComponent.cpp'
106--- src/DspComponent.cpp 2014-06-16 14:33:10 +0000
107+++ src/DspComponent.cpp 2014-07-26 08:04:03 +0000
108@@ -251,6 +251,16 @@
109
110 //-------------------------------------------------------------------------------------------------
111
112+DspParameter const* DspComponent::GetParameter( std::string const& paramName )
113+{
114+ PauseAutoTick();
115+ DspParameter const* result = GetParameter_( paramName );
116+ ResumeAutoTick();
117+ return result;
118+}
119+
120+//-------------------------------------------------------------------------------------------------
121+
122 bool DspComponent::SetParameter( std::string const& paramName, DspParameter const& param )
123 {
124 PauseAutoTick();

Subscribers

People subscribed via source and target branches

to all changes: