@@ -152,30 +152,39 @@ AttributableImpl::flushAttributes()
152152}
153153
154154void
155- AttributableImpl::readAttributes ( bool reread )
155+ AttributableImpl::readAttributes ( ReadMode mode )
156156{
157+ auto & attri = get ();
157158 Parameter< Operation::LIST_ATTS > aList;
158159 IOHandler ()->enqueue (IOTask (this , aList));
159160 IOHandler ()->flush ();
160161 std::vector< std::string > written_attributes = attributes ();
161162
163+ /* std::set_difference requires sorted ranges */
164+ std::sort (aList.attributes ->begin (), aList.attributes ->end ());
165+ std::sort (written_attributes.begin (), written_attributes.end ());
166+
162167 std::set< std::string > tmpAttributes;
163- if ( reread )
164- {
165- tmpAttributes = std::set< std::string >(
166- aList.attributes ->begin (),
167- aList.attributes ->end () );
168- }
169- else
168+ switch ( mode )
170169 {
171- /* std::set_difference requires sorted ranges */
172- std::sort (aList.attributes ->begin (), aList.attributes ->end ());
173- std::sort (written_attributes.begin (), written_attributes.end ());
174-
170+ case ReadMode::IgnoreExisting:
171+ // reread: aList - written_attributes
175172 std::set_difference (
176173 aList.attributes ->begin (), aList.attributes ->end (),
177174 written_attributes.begin (), written_attributes.end (),
178175 std::inserter (tmpAttributes, tmpAttributes.begin ()));
176+ break ;
177+ case ReadMode::OverrideExisting:
178+ tmpAttributes = std::set< std::string >(
179+ aList.attributes ->begin (),
180+ aList.attributes ->end () );
181+ break ;
182+ case ReadMode::FullyReread:
183+ attri.m_attributes .clear ();
184+ tmpAttributes = std::set< std::string >(
185+ aList.attributes ->begin (),
186+ aList.attributes ->end () );
187+ break ;
179188 }
180189
181190 using DT = Datatype;
0 commit comments