@@ -44,17 +44,50 @@ using namespace std;
44
44
/* *
45
45
* Default constructor.
46
46
*/
47
- Controller::Controller ()
47
+ Controller::Controller () :
48
+ ModelComponent{},
49
+ _numControls{0 },
50
+ _actuatorSet{}
48
51
{
49
52
constructProperties ();
50
53
}
51
54
55
+ Controller::Controller (Controller const & src) :
56
+ ModelComponent{src},
57
+ PropertyIndex_enabled{src.PropertyIndex_enabled },
58
+ PropertyIndex_actuator_list{src.PropertyIndex_actuator_list },
59
+ _numControls{src._numControls },
60
+ _actuatorSet{}
61
+ {
62
+ // care: the reason this custom copy constructor exists is to prevent
63
+ // a memory leak (#3247)
64
+ _actuatorSet.setMemoryOwner (false );
65
+ }
66
+
67
+ Controller& Controller::operator =(Controller const & src)
68
+ {
69
+ // care: the reason this custom copy assignment exists is to prevent
70
+ // a memory leak (#3247)
71
+
72
+ if (&src != this )
73
+ {
74
+ static_cast <ModelComponent&>(*this ) = static_cast <ModelComponent const &>(src);
75
+ PropertyIndex_enabled = src.PropertyIndex_enabled ;
76
+ PropertyIndex_actuator_list = src.PropertyIndex_actuator_list ;
77
+ _numControls = src._numControls ;
78
+ _actuatorSet.setSize (0 );
79
+ }
80
+ return *this ;
81
+ }
82
+
83
+ Controller::~Controller () noexcept = default ;
52
84
53
85
// =============================================================================
54
86
// CONSTRUCTION
55
87
// =============================================================================
56
88
// _____________________________________________________________________________
57
89
// _____________________________________________________________________________
90
+
58
91
/* *
59
92
* Connect properties to local pointers.
60
93
*/
@@ -63,8 +96,6 @@ void Controller::constructProperties()
63
96
setAuthors (" Ajay Seth, Frank Anderson, Chand John, Samuel Hamner" );
64
97
constructProperty_enabled (true );
65
98
constructProperty_actuator_list ();
66
-
67
- // Set is only a reference list, not ownership
68
99
_actuatorSet.setMemoryOwner (false );
69
100
}
70
101
@@ -125,8 +156,8 @@ void Controller::extendConnectToModel(Model& model)
125
156
// if we use a list Socket<Actuator>
126
157
127
158
// make sure controller does not take ownership
128
- _actuatorSet.setMemoryOwner (false );
129
159
_actuatorSet.setSize (0 );
160
+ _actuatorSet.setMemoryOwner (false );
130
161
131
162
int nac = getProperty_actuator_list ().size ();
132
163
if (nac == 0 )
@@ -172,9 +203,9 @@ void Controller::setActuators(const Set<Actuator>& actuators)
172
203
// TODO this needs to be setting a Socket list of Actuators
173
204
174
205
// make sure controller does NOT assume ownership
206
+ _actuatorSet.setSize (0 );
175
207
_actuatorSet.setMemoryOwner (false );
176
208
// Rebuild consistent set of actuator lists
177
- _actuatorSet.setSize (0 );
178
209
updProperty_actuator_list ().clear ();
179
210
for (int i = 0 ; i< actuators.getSize (); i++){
180
211
addActuator (actuators[i]);
0 commit comments