@@ -39,6 +39,15 @@ class CANDatabase {
3939 */
4040 static CANDatabase fromString (const std::string& src_string);
4141
42+ public:
43+ using container_type = std::map<unsigned int , std::shared_ptr<CANFrame>>;
44+ using str_container_type = std::map<std::string, std::shared_ptr<CANFrame>>;
45+
46+ using iterator = container_type::iterator;
47+ using const_iterator = container_type::const_iterator;
48+ using reverse_iterator = container_type::reverse_iterator;
49+ using const_reverse_iterator = container_type::const_reverse_iterator;
50+
4251public:
4352 /* *
4453 * @brief Creates a CANDatabase object with no source file
@@ -51,6 +60,29 @@ class CANDatabase {
5160 */
5261 CANDatabase (const std::string& filename);
5362
63+ /* *
64+ * Creates a copy of the database: the individual frames are deep copied so there is no
65+ * shared memory betwwen the two databases.
66+ */
67+ CANDatabase (const CANDatabase&);
68+
69+ /* *
70+ * @brief Makes a copy of the given database
71+ * Note: the source database is passed-by-value for RVO
72+ * (see https://stackoverflow.com/a/3279550/8147455 for more info)
73+ */
74+ CANDatabase& operator =(CANDatabase);
75+
76+ /* *
77+ * @brief Moves a CANDatabase object. The CANFrame objects are NOT deep copied.
78+ */
79+ CANDatabase (CANDatabase&&);
80+
81+ /* *
82+ * @see CANDatabase(const CANDatabase&&)
83+ */
84+ CANDatabase& operator =(CANDatabase&&);
85+
5486public:
5587 /* *
5688 * @brief Get the frame with the given frame name
@@ -83,6 +115,10 @@ class CANDatabase {
83115 */
84116 bool contains (const std::string& frame_name) const ;
85117
118+ /* *
119+ * @brief Swaps the content of the two given databases
120+ */
121+ friend void swap (CANDatabase& first, CANDatabase& second);
86122 /* *
87123 * @return File name of the source file if the database was constructed from a file.
88124 * Otherwise, returns an empty string.
@@ -96,13 +132,6 @@ class CANDatabase {
96132
97133 The iterators have a random order. */
98134public:
99- using container_type = std::map<unsigned int , std::shared_ptr<CANFrame>>;
100- using str_container_type = std::map<std::string, std::shared_ptr<CANFrame>>;
101- using iterator = container_type::iterator;
102- using const_iterator = container_type::const_iterator;
103- using reverse_iterator = container_type::reverse_iterator;
104- using const_reverse_iterator = container_type::const_reverse_iterator;
105-
106135 iterator begin ();
107136 const_iterator begin () const ;
108137 const_iterator cbegin () const ;
0 commit comments