Skip to content

Commit 2955751

Browse files
committed
[core][dataflow] Fix some const. Revert data() constness for port.
1 parent 4673924 commit 2955751

5 files changed

Lines changed: 14 additions & 14 deletions

File tree

src/Core/Containers/VariableSet.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ auto VariableSet::insertVariable( const std::string& name, const T& value )
546546

547547
template <typename T>
548548
auto VariableSet::getVariable( const std::string& name ) -> T& {
549-
return const_cast<T&>( const_cast<const VariableSet*>( this )->getVariable<T>( name ) );
549+
return getVariableHandle<T>( name )->second;
550550
}
551551

552552
template <typename T>

src/Dataflow/Core/Functionals/TransformNode.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ bool TransformNode<coll_t, v_t>::execute() {
9999
m_result.clear();
100100
// m_elements.reserve( inData.size() ); // --> this is not a requirement of
101101
// SequenceContainer
102-
std::transform( inData.begin(), inData.end(), std::back_inserter( m_result ), f );
102+
std::transform( inData.cbegin(), inData.cend(), std::back_inserter( m_result ), f );
103103

104104
return true;
105105
}

src/Dataflow/Core/PortFactory.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ class RA_DATAFLOW_CORE_API PortFactory
6767
return &( casted->data() );
6868
};
6969
m_output_setter[type] = []( PortBaseOut* port, std::any any ) {
70-
const T* data = std::any_cast<const T*>( any );
71-
auto casted = dynamic_cast<PortOut<T>*>( port );
70+
T* data = std::any_cast<T*>( any );
71+
auto casted = dynamic_cast<PortOut<T>*>( port );
7272
casted->set_data( data );
7373
};
7474

src/Dataflow/Core/PortIn.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class RA_DATAFLOW_CORE_API PortBaseIn : public PortBase
4545
void set_default_value( const T& value );
4646

4747
template <typename T>
48-
const T& data();
48+
T& data();
4949

5050
protected:
5151
/**
@@ -106,7 +106,7 @@ class PortIn : public PortBaseIn,
106106
* Fails if note link nor has a default value, check with has_data beforehand if needed.
107107
* \return T& The reference to the data.
108108
*/
109-
const T& data();
109+
T& data();
110110

111111
/// \name Manage the connection with a PortOut.
112112
/// @{
@@ -197,12 +197,12 @@ void PortBaseIn::set_default_value( const T& value ) {
197197
}
198198

199199
template <typename T>
200-
const T& PortBaseIn::data() {
200+
T& PortBaseIn::data() {
201201
return static_cast<PortIn<T>*>( this )->data();
202202
}
203203

204204
template <typename T>
205-
const T& PortIn<T>::data() {
205+
T& PortIn<T>::data() {
206206
if ( is_linked() ) return m_from->data();
207207
if ( m_defaultValue ) return *m_defaultValue;
208208
CORE_ASSERT( false, "should not get here" );

src/Dataflow/Core/PortOut.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class RA_DATAFLOW_CORE_API PortBaseOut : public PortBase
3030
/// Get data stored at this outpute port
3131
/// Check if this port type it the same as T
3232
template <typename T>
33-
const T& data();
33+
T& data();
3434

3535
/// Set port data pointer.
3636
/// Check if this port type it the same as T
@@ -49,7 +49,7 @@ class RA_DATAFLOW_CORE_API PortBaseOut : public PortBase
4949
--m_linkCount;
5050
CORE_ASSERT( m_linkCount >= 0, "link count error" );
5151
}
52-
virtual int link_count() { return m_linkCount; }
52+
virtual int link_count() const { return m_linkCount; }
5353

5454
protected:
5555
/// Constructor.
@@ -95,10 +95,10 @@ class PortOut : public PortBaseOut
9595
/// @}
9696

9797
/// Gets a reference to the data this ports points to.
98-
const T& data() { return *m_data; }
98+
T& data() { return *m_data; }
9999
/// Takes a pointer to the data this port will point to.
100100
/// @param data The pointer to the data.
101-
void set_data( const T* data ) { m_data = data; }
101+
void set_data( T* data ) { m_data = data; }
102102
/// Returns true if the pointer to the data is not null.
103103
bool has_data() override { return ( m_data ); }
104104

@@ -107,7 +107,7 @@ class PortOut : public PortBaseOut
107107
*
108108
* Use raw ptr since data belongs to the node and can be plain stack variable
109109
*/
110-
const T* m_data { nullptr };
110+
T* m_data { nullptr };
111111

112112
}; // class PortOut<T>
113113

@@ -120,7 +120,7 @@ using PortBaseOutRawPtr = PortRawPtr<PortBaseOut>;
120120
using PortBaseOutPtr = PortPtr<PortBaseOut>;
121121

122122
template <typename T>
123-
const T& PortBaseOut::data() {
123+
T& PortBaseOut::data() {
124124
auto thisOut = dynamic_cast<PortOut<T>*>( this );
125125
if ( thisOut && thisOut->has_data() ) { return thisOut->data(); }
126126

0 commit comments

Comments
 (0)