diff --git a/src/ant/ant/antService.cc b/src/ant/ant/antService.cc index e5d74cef7..f9666fd2c 100644 --- a/src/ant/ant/antService.cc +++ b/src/ant/ant/antService.cc @@ -1274,8 +1274,9 @@ Service::end_move (const db::DPoint &, lay::angle_constraint_type) // compute moved object and replace ant::Object *rnew = new ant::Object (*robj); rnew->transform (m_trans); + int new_id = rnew->id (); mp_view->annotation_shapes ().replace (s->first, db::DUserObject (rnew)); - annotation_changed_event (rnew->id ()); + annotation_changed_event (new_id); } diff --git a/src/db/db/dbBoxTree.h b/src/db/db/dbBoxTree.h index acd9c37a2..cc687ca54 100644 --- a/src/db/db/dbBoxTree.h +++ b/src/db/db/dbBoxTree.h @@ -760,6 +760,15 @@ public: // .. nothing else .. } + /** + * @brief Move constructor + */ + box_tree (box_tree &&b) + : m_objects (b.m_objects), m_elements (b.m_elements), mp_root (b.mp_root) + { + b.mp_root = 0; + } + /** * @brief Assignment */ @@ -774,6 +783,21 @@ public: return *this; } + /** + * @brief Assignment (move) + */ + box_tree &operator= (box_tree &&b) + { + clear (); + m_objects = b.m_objects; + m_elements = b.m_elements; + if (b.mp_root) { + mp_root = b.mp_root; + b.mp_root = 0; + } + return *this; + } + /** * @brief The destructor */ @@ -1729,6 +1753,15 @@ public: // .. nothing else .. } + /** + * @brief Move constructor + */ + unstable_box_tree (unstable_box_tree &&b) + : m_objects (b.m_objects), mp_root (b.mp_root) + { + b.mp_root = 0; + } + /** * @brief Assignment */ @@ -1742,6 +1775,20 @@ public: return *this; } + /** + * @brief Assignment (move) + */ + unstable_box_tree &operator= (unstable_box_tree &&b) + { + clear (); + m_objects = b.m_objects; + if (b.mp_root) { + mp_root = b.mp_root; + b.mp_root = 0; + } + return *this; + } + /** * @brief The destructor */ diff --git a/src/db/db/dbLayer.h b/src/db/db/dbLayer.h index 2f54619f6..453c8648f 100644 --- a/src/db/db/dbLayer.h +++ b/src/db/db/dbLayer.h @@ -107,6 +107,14 @@ struct layer operator= (d); } + /** + * @brief The move constructor + */ + layer (const layer &&d) + { + operator= (d); + } + /** * @brief The assignment operator * @@ -123,6 +131,20 @@ struct layer return *this; } + /** + * @brief The assignment operator (move semantics) + */ + layer &operator= (const layer &&d) + { + if (&d != this) { + m_box_tree = d.m_box_tree; + m_bbox = d.m_bbox; + m_bbox_dirty = d.m_bbox_dirty; + m_tree_dirty = d.m_tree_dirty; + } + return *this; + } + /** * @brief Get the iterator for an object given by a pointer */ @@ -207,6 +229,18 @@ struct layer return m_box_tree.insert (sh); } + /** + * @brief Insert a new shape object (move semantics) + */ + iterator insert (const Sh &&sh) + { + // inserting will make the bbox and the tree "dirty" - i.e. + // it will need to be updated. + m_bbox_dirty = true; + m_tree_dirty = true; + return m_box_tree.insert (sh); + } + /** * @brief Replace the given element with a new one * @@ -228,6 +262,19 @@ struct layer return *ncpos; } + /** + * @brief Replace the given element with a new one (move semantics) + */ + Sh &replace (iterator pos, const Sh &&sh) + { + m_bbox_dirty = true; + m_tree_dirty = true; + non_const_iterator ncpos; + to_non_const_box_tree_iter (pos, ncpos, StableTag ()); + *ncpos = sh; + return *ncpos; + } + /** * @brief Erasing of an element * diff --git a/src/db/db/dbUserObject.h b/src/db/db/dbUserObject.h index 8961480ba..f9a3c0b92 100644 --- a/src/db/db/dbUserObject.h +++ b/src/db/db/dbUserObject.h @@ -206,6 +206,18 @@ public: } } + /** + * @brief The move constructor + */ + user_object (user_object &&d) + : mp_obj (0) + { + if (d.mp_obj) { + set_ptr (d.mp_obj); + d.mp_obj = 0; + } + } + /** * @brief Assignment operator */ @@ -219,6 +231,20 @@ public: return *this; } + /** + * @brief Assignment operator (move) + */ + user_object &operator= (user_object &&d) + { + if (d.mp_obj) { + set_ptr (d.mp_obj); + d.mp_obj = 0; + } else { + set_ptr (0); + } + return *this; + } + /** * @brief The destructor */ diff --git a/src/laybasic/laybasic/layAnnotationShapes.cc b/src/laybasic/laybasic/layAnnotationShapes.cc index c7babddd1..10a43b865 100644 --- a/src/laybasic/laybasic/layAnnotationShapes.cc +++ b/src/laybasic/laybasic/layAnnotationShapes.cc @@ -89,6 +89,12 @@ AnnotationShapes::AnnotationShapes (const AnnotationShapes &d) operator= (d); } +AnnotationShapes::AnnotationShapes (const AnnotationShapes &&d) + : db::LayoutStateModel (true /*busy*/), db::Object (d) +{ + operator= (d); +} + AnnotationShapes::~AnnotationShapes () { clear (); @@ -106,7 +112,21 @@ AnnotationShapes::operator= (const AnnotationShapes &d) } return *this; } -void + +AnnotationShapes & +AnnotationShapes::operator= (const AnnotationShapes &&d) +{ + if (&d != this) { + clear (); + if (manager () && manager ()->transacting ()) { + manager ()->queue (this, new AnnotationLayerOp (true /*insert*/, d.m_layer.begin (), d.m_layer.end ())); + } + m_layer = d.m_layer; + } + return *this; +} + +void AnnotationShapes::clear () { if (manager () && manager ()->transacting ()) { @@ -126,7 +146,17 @@ AnnotationShapes::insert (const shape_type &sh) return *m_layer.insert (sh); } -void +const AnnotationShapes::shape_type & +AnnotationShapes::insert (const shape_type &&sh) +{ + if (manager () && manager ()->transacting ()) { + manager ()->queue (this, new AnnotationLayerOp (true /*insert*/, sh)); + } + invalidate_state (); // HINT: must come before the change is done! + return *m_layer.insert (sh); +} + +void AnnotationShapes::reserve (size_t n) { m_layer.reserve (n); @@ -156,7 +186,21 @@ AnnotationShapes::replace (iterator pos, const shape_type &sh) return *pos; } -void +const AnnotationShapes::shape_type & +AnnotationShapes::replace (iterator pos, const shape_type &&sh) +{ + if (&*pos != &sh && *pos != sh) { + if (manager () && manager ()->transacting ()) { + manager ()->queue (this, new AnnotationLayerOp (false /*not insert*/, *pos)); + manager ()->queue (this, new AnnotationLayerOp (true /*insert*/, sh)); + } + invalidate_state (); // HINT: must come before the change is done! + m_layer.replace (pos, sh); + } + return *pos; +} + +void AnnotationShapes::redo (db::Op *op) { AnnotationLayerOp *layop = dynamic_cast (op); diff --git a/src/laybasic/laybasic/layAnnotationShapes.h b/src/laybasic/laybasic/layAnnotationShapes.h index f715c8597..c60abb5e5 100644 --- a/src/laybasic/laybasic/layAnnotationShapes.h +++ b/src/laybasic/laybasic/layAnnotationShapes.h @@ -135,16 +135,37 @@ public: */ AnnotationShapes (const AnnotationShapes &d); + /** + * @brief Copy ctor + */ + AnnotationShapes (const AnnotationShapes &&d); + /** * @brief Assignment operator */ AnnotationShapes &operator= (const AnnotationShapes &d); + /** + * @brief Assignment operator (move) + */ + AnnotationShapes &operator= (const AnnotationShapes &&d); + /** * @brief Insert a shape_type */ const shape_type &insert (const shape_type &sh); + /** + * @brief Insert a sequence of DUserObject shapes + * + * Inserts a sequence of shapes [from,to) + */ + + /** + * @brief Insert a shape_type (move semantics) + */ + const shape_type &insert (const shape_type &&sh); + /** * @brief Insert a sequence of DUserObject shapes * @@ -212,6 +233,11 @@ public: */ const shape_type &replace (iterator pos, const shape_type &sh); + /** + * @brief Replace an element at the given position with another shape (move semantics) + */ + const shape_type &replace (iterator pos, const shape_type &&sh); + /** * @brief updates the bbox * diff --git a/src/tl/tl/tlReuseVector.h b/src/tl/tl/tlReuseVector.h index 5a2eb6435..d9ff78cda 100644 --- a/src/tl/tl/tlReuseVector.h +++ b/src/tl/tl/tlReuseVector.h @@ -535,6 +535,19 @@ public: } } + /** + * @brief Move constructor + * + * See operator= for a description of the copy operation. + */ + reuse_vector (reuse_vector &&d) + { + mp_start = d.mp_start; d.mp_start = 0; + mp_finish = d.mp_finish; d.mp_finish = 0; + mp_capacity = d.mp_capacity; d.mp_capacity = 0; + mp_rdata = d.mp_rdata; d.mp_rdata = 0; + } + /** * @brief Destructor */ @@ -562,6 +575,20 @@ public: return *this; } + /** + * @brief Assignment (move) + */ + reuse_vector &operator= (reuse_vector &&d) + { + if (&d != this) { + mp_start = d.mp_start; d.mp_start = 0; + mp_finish = d.mp_finish; d.mp_finish = 0; + mp_capacity = d.mp_capacity; d.mp_capacity = 0; + mp_rdata = d.mp_rdata; d.mp_rdata = 0; + } + return *this; + } + /** * @brief Assignment * diff --git a/src/tl/tl/tlVector.h b/src/tl/tl/tlVector.h index b4ce0e5a1..0bbd77803 100644 --- a/src/tl/tl/tlVector.h +++ b/src/tl/tl/tlVector.h @@ -60,6 +60,11 @@ public: */ explicit vector (const tl::vector &d) : base (d) { } + /** + * @brief Move constructor + */ + explicit vector (const tl::vector &&d) : base (d) { } + /** * @brief Assignment */ @@ -71,6 +76,17 @@ public: return *this; } + /** + * @brief Assignment (Move) + */ + vector &operator= (const tl::vector &&d) + { + if (&d != this) { + base::operator= (d); + } + return *this; + } + /** * @brief Initialization with value and length */