BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
util24.cxx File Reference
#include "eformat/BadVersionIssue.h"
#include "eformat/HeaderMarker.h"
#include "eformat/SourceIdentifier.h"
#include "eformat/Version.h"
#include "eformat/WrongMarkerIssue.h"
#include "eformat/old/FullEventFragment.h"
#include "eformat/old/ROBFragment.h"
#include "eformat/old/RODFragment.h"
#include "eformat/old/ROSFragment.h"
#include "eformat/old/SubDetectorFragment.h"
#include "eformat/old/UnboundSourceIdentifierIssue.h"
#include "eformat/old/util.h"
#include "eformat/write/FullEventFragment.h"
#include "ers/StreamFactory.h"

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 172 of file util24.cxx.

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

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