BOSS 7.0.8
BESIII Offline Software System
Loading...
Searching...
No Matches
util24.cxx File Reference

Go to the source code of this file.

Functions

uint32_t convert_ros (const uint32_t *src, uint32_t *dest, uint32_t max)
 

Function Documentation

◆ convert_ros()

uint32_t convert_ros ( const uint32_t *  src,
uint32_t *  dest,
uint32_t  max 
)

Converts a ROS fragment, from the old to new format, using the space of contiguous memory storage area given. If the event given is already on v3.0 format, no conversion takes place.

Parameters
srcA pointer to the first word of the fragment, lying in a contiguous area of memory.
destThe destination area of memory, preallocated
maxThe maximum number of words that fit in the preallocated memory area "dest".
Returns
A counter, for the number of words copied from the source to the destination. If that number is zero, something wrong happened.

Definition at line 176 of file util24.cxx.

177{
178 using namespace eformat;
179
180 if (src[0] != ROS) {
181 throw EFORMAT_WRONG_MARKER(src[0], ROS);
182 }
183
184 //check version
185 helper::Version version(src[3]);
186 if (version.major2() == MAJOR_DEFAULT_VERSION) {
187 memcpy(dest, src, sizeof(uint32_t)*src[1]);
188 return src[1];
189 }
190 if (version.major2() != MAJOR_OLD_VERSION)
191 throw EFORMAT_BAD_VERSION(version.major2(), MAJOR_DEFAULT_VERSION);
192
193 //this is from the old major version of eformat, proceed with conversion
194 old::ROSFragment ros(src);
195 ros.check_tree(); //this may throw
196/**********renzy edit***/
197// write::ROSFragment nros(old::convert_source(ros.source_id()),
198 eformat::write::ROSFragment nros(old::convert_source(ros.source_id()),
199/**********renzy edit***/
200 ros.run_no(), ros.lvl1_id(), ros.bc_id());
201 nros.status(ros.nstatus(), ros.status());
202 helper::Version ros_version(ros.version());
203 nros.minor_version(ros_version.minor2());
204
205/**********renzy edit***/
206 //std::vector<write::ROBFragment*> acc_rob;
207 std::vector<eformat::write::ROBFragment*> acc_rob;
208/**********renzy edit***/
209 for (size_t k=0; k<ros.noffset(); ++k) {
210 old::ROBFragment rob(ros.child(k));
211 uint32_t source_id = rob.source_id();
212
213 for (size_t l=0; l<rob.noffset(); ++l) {
214 old::RODFragment rod(rob.rod(l));
215 if (rob.noffset() != 1) source_id = rod.source_id();
216/**********renzy edit***/
217 //write::ROBFragment* nrob = new write::ROBFragment
219/**********renzy edit***/
220 (old::convert_source(source_id), rod.run_no(), rod.lvl1_id(),
221 rod.bc_id(), rod.lvl1_trigger_type(), rod.detev_type(),
222 rod.ndata(), rod.data(), rod.status_position());
223 nrob->status(rob.nstatus(), rob.status());
224 nrob->rod_status(rod.nstatus(), rod.status());
225 helper::Version rob_version(rob.version());
226 nrob->minor_version(rob_version.minor2());
227 helper::Version rod_version(rod.version());
228 nrob->rod_minor_version(rod_version.minor2());
229
230 //make this new ROB part of the new ROS
231 nros.append(nrob);
232 //make sure we don't forget to delete this guy
233 acc_rob.push_back(nrob);
234 }
235 }
236
237 //now the ROS is in `nros', bind
238 const eformat::write::node_t* top = nros.bind();
239 //memcpy the list of pages into contiguous memory
240 uint32_t retval = eformat::write::copy(*top, dest, max);
241
242 //delete the dynamically allocated stuff
243 for (size_t i=0; i<acc_rob.size(); ++i) delete acc_rob[i];
244
245 return retval;
246}
#define EFORMAT_BAD_VERSION(current, supported)
#define EFORMAT_WRONG_MARKER(current, expected)
void status(uint32_t n, const uint32_t *status)
void rod_status(uint32_t n, const uint32_t *status)
void rod_minor_version(uint16_t v)
uint32_t copy(const node_t &list, uint32_t *dest, size_t max)
Definition: node.cxx:64

Referenced by eformat::old::convert().