@@ -123,6 +123,78 @@ class Concore{
123123#endif
124124 }
125125
126+ /* *
127+ * @brief Concore is not copyable as it owns shared memory handles.
128+ */
129+ Concore (const Concore&) = delete ;
130+ Concore& operator =(const Concore&) = delete ;
131+
132+ /* *
133+ * @brief Move constructor. Transfers SHM handle ownership to the new instance.
134+ */
135+ Concore (Concore&& other) noexcept
136+ : s(std::move(other.s)), olds(std::move(other.olds)),
137+ inpath (std::move(other.inpath)), outpath(std::move(other.outpath)),
138+ shmId_create(other.shmId_create), shmId_get(other.shmId_get),
139+ sharedData_create(other.sharedData_create), sharedData_get(other.sharedData_get),
140+ communication_iport(other.communication_iport), communication_oport(other.communication_oport),
141+ delay(other.delay), retrycount(other.retrycount), simtime(other.simtime),
142+ maxtime(other.maxtime), iport(std::move(other.iport)), oport(std::move(other.oport)),
143+ params(std::move(other.params))
144+ {
145+ other.shmId_create = -1 ;
146+ other.shmId_get = -1 ;
147+ other.sharedData_create = nullptr ;
148+ other.sharedData_get = nullptr ;
149+ other.communication_iport = 0 ;
150+ other.communication_oport = 0 ;
151+ }
152+
153+ /* *
154+ * @brief Move assignment. Cleans up current SHM resources, then takes ownership from other.
155+ */
156+ Concore& operator =(Concore&& other) noexcept
157+ {
158+ if (this == &other)
159+ return *this ;
160+
161+ #ifdef __linux__
162+ if (communication_oport == 1 && sharedData_create != nullptr )
163+ shmdt (sharedData_create);
164+ if (communication_iport == 1 && sharedData_get != nullptr )
165+ shmdt (sharedData_get);
166+ if (shmId_create != -1 )
167+ shmctl (shmId_create, IPC_RMID, nullptr );
168+ #endif
169+
170+ s = std::move (other.s );
171+ olds = std::move (other.olds );
172+ inpath = std::move (other.inpath );
173+ outpath = std::move (other.outpath );
174+ shmId_create = other.shmId_create ;
175+ shmId_get = other.shmId_get ;
176+ sharedData_create = other.sharedData_create ;
177+ sharedData_get = other.sharedData_get ;
178+ communication_iport = other.communication_iport ;
179+ communication_oport = other.communication_oport ;
180+ delay = other.delay ;
181+ retrycount = other.retrycount ;
182+ simtime = other.simtime ;
183+ maxtime = other.maxtime ;
184+ iport = std::move (other.iport );
185+ oport = std::move (other.oport );
186+ params = std::move (other.params );
187+
188+ other.shmId_create = -1 ;
189+ other.shmId_get = -1 ;
190+ other.sharedData_create = nullptr ;
191+ other.sharedData_get = nullptr ;
192+ other.communication_iport = 0 ;
193+ other.communication_oport = 0 ;
194+
195+ return *this ;
196+ }
197+
126198 /* *
127199 * @brief Extracts the numeric part from a string.
128200 * @param str The input string.
0 commit comments