#include "eformat/old/util.h"
#include "eformat/old/UnboundSourceIdentifierIssue.h"
#include "eformat/old/FullEventFragment.h"
#include "eformat/old/SubDetectorFragment.h"
#include "eformat/old/ROSFragment.h"
#include "eformat/old/ROBFragment.h"
#include "eformat/old/RODFragment.h"
#include "eformat/SourceIdentifier.h"
#include "eformat/HeaderMarker.h"
#include "eformat/WrongMarkerIssue.h"
#include "eformat/Version.h"
#include "eformat/BadVersionIssue.h"
#include "ers/StreamFactory.h"
#include "eformat/write/FullEventFragment.h"
Go to the source code of this file.
Functions | |
uint32_t | eformat::old::convert_source (uint32_t old_id) |
uint32_t | convert_ros (const uint32_t *src, uint32_t *dest, uint32_t max) |
uint32_t | eformat::old::convert (const uint32_t *src, uint32_t *dest, uint32_t max) |
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.
src | A pointer to the first word of the fragment, lying in a contiguous area of memory. | |
dest | The destination area of memory, preallocated | |
max | The maximum number of words that fit in the preallocated memory area "dest". |
Definition at line 176 of file util24.cxx.
References eformat::old::convert_source(), eformat::write::copy(), EFORMAT_BAD_VERSION, EFORMAT_WRONG_MARKER, genRecEmupikp::i, eformat::MAJOR_DEFAULT_VERSION, eformat::MAJOR_OLD_VERSION, eformat::write::ROBFragment::minor_version(), eformat::write::ROBFragment::rod_minor_version(), eformat::write::ROBFragment::rod_status(), eformat::ROS, and eformat::write::ROBFragment::status().
Referenced by eformat::old::convert().
00177 { 00178 using namespace eformat; 00179 00180 if (src[0] != ROS) { 00181 throw EFORMAT_WRONG_MARKER(src[0], ROS); 00182 } 00183 00184 //check version 00185 helper::Version version(src[3]); 00186 if (version.major2() == MAJOR_DEFAULT_VERSION) { 00187 memcpy(dest, src, sizeof(uint32_t)*src[1]); 00188 return src[1]; 00189 } 00190 if (version.major2() != MAJOR_OLD_VERSION) 00191 throw EFORMAT_BAD_VERSION(version.major2(), MAJOR_DEFAULT_VERSION); 00192 00193 //this is from the old major version of eformat, proceed with conversion 00194 old::ROSFragment ros(src); 00195 ros.check_tree(); //this may throw 00196 /**********renzy edit***/ 00197 // write::ROSFragment nros(old::convert_source(ros.source_id()), 00198 eformat::write::ROSFragment nros(old::convert_source(ros.source_id()), 00199 /**********renzy edit***/ 00200 ros.run_no(), ros.lvl1_id(), ros.bc_id()); 00201 nros.status(ros.nstatus(), ros.status()); 00202 helper::Version ros_version(ros.version()); 00203 nros.minor_version(ros_version.minor2()); 00204 00205 /**********renzy edit***/ 00206 //std::vector<write::ROBFragment*> acc_rob; 00207 std::vector<eformat::write::ROBFragment*> acc_rob; 00208 /**********renzy edit***/ 00209 for (size_t k=0; k<ros.noffset(); ++k) { 00210 old::ROBFragment rob(ros.child(k)); 00211 uint32_t source_id = rob.source_id(); 00212 00213 for (size_t l=0; l<rob.noffset(); ++l) { 00214 old::RODFragment rod(rob.rod(l)); 00215 if (rob.noffset() != 1) source_id = rod.source_id(); 00216 /**********renzy edit***/ 00217 //write::ROBFragment* nrob = new write::ROBFragment 00218 eformat::write::ROBFragment* nrob = new eformat::write::ROBFragment 00219 /**********renzy edit***/ 00220 (old::convert_source(source_id), rod.run_no(), rod.lvl1_id(), 00221 rod.bc_id(), rod.lvl1_trigger_type(), rod.detev_type(), 00222 rod.ndata(), rod.data(), rod.status_position()); 00223 nrob->status(rob.nstatus(), rob.status()); 00224 nrob->rod_status(rod.nstatus(), rod.status()); 00225 helper::Version rob_version(rob.version()); 00226 nrob->minor_version(rob_version.minor2()); 00227 helper::Version rod_version(rod.version()); 00228 nrob->rod_minor_version(rod_version.minor2()); 00229 00230 //make this new ROB part of the new ROS 00231 nros.append(nrob); 00232 //make sure we don't forget to delete this guy 00233 acc_rob.push_back(nrob); 00234 } 00235 } 00236 00237 //now the ROS is in `nros', bind 00238 const eformat::write::node_t* top = nros.bind(); 00239 //memcpy the list of pages into contiguous memory 00240 uint32_t retval = eformat::write::copy(*top, dest, max); 00241 00242 //delete the dynamically allocated stuff 00243 for (size_t i=0; i<acc_rob.size(); ++i) delete acc_rob[i]; 00244 00245 return retval; 00246 }