BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
node.cxx
Go to the documentation of this file.
1// Dear emacs, this is -*- c++ -*-
2
3/**
4 * @file node.cxx
5 * @author <a href="mailto:Andre.dos.Anjos@cern.ch">Andre DOS ANJOS</a>
6 * $Author: zhangy $
7 * $Revision: 1.1.1.1 $
8 * $Date: 2009/06/19 07:35:41 $
9 *
10 * Implements IOV node functionality
11 */
12
13#include "eformat/write/node.h"
14#include <cstring>
15
16void eformat::write::set( node_t& i, const uint32_t* b, size_t l, node_t* n ) {
17 i.base = const_cast<uint32_t*>( b );
18 i.size_word = l;
19 i.next = n;
20}
21
22void eformat::write::set( node_t& i, const struct iovec& v, node_t* n ) {
23 i.base = reinterpret_cast<uint32_t*>( v.iov_base );
24 i.size_word = v.iov_len / 4;
25 i.next = n;
26}
27
28void eformat::write::cat( node_t* n, const struct iovec* v, uint32_t count ) {
29 for ( size_t i = 0; i < ( count - 1 ); ++i ) set( n[i], v[i], &n[i + 1] );
30 set( n[count - 1], v[count - 1], 0 );
31}
32
33void eformat::write::cat( node_t* n, uint32_t count ) {
34 for ( size_t i = 0; i < ( count - 1 ); ++i ) n[i].next = &n[i + 1];
35 n[count - 1].next = 0;
36}
37
38uint32_t eformat::write::count( const node_t& list ) {
39 const eformat::write::node_t* current = &list;
40 uint32_t retval = 0;
41 while ( current )
42 {
43 ++retval;
44 current = current->next;
45 }
46 return retval;
47}
48
49uint32_t eformat::write::count_words( const node_t& list ) {
50 const eformat::write::node_t* current = &list;
51 uint32_t retval = 0;
52 while ( current )
53 {
54 retval += current->size_word;
55 current = current->next;
56 }
57 return retval;
58}
59
60uint32_t eformat::write::copy( const node_t& list, uint32_t* dest, size_t max ) {
61 const eformat::write::node_t* current = &list;
62 uint32_t cpos = 0;
63 while ( current )
64 {
65 if ( cpos + current->size_word > max ) return 0;
66 if ( current->size_word > 0 && current->base )
67 {
68 memcpy( &dest[cpos], current->base, sizeof( uint32_t ) * current->size_word );
69 cpos += current->size_word;
70 }
71 current = current->next;
72 }
73 return cpos;
74}
75
76uint32_t eformat::write::shallow_copy( const node_t& list, struct iovec* dest, uint32_t max ) {
77 const eformat::write::node_t* current = &list;
78 uint32_t cpos = 0;
79 while ( current )
80 {
81 if ( cpos > max ) return 0;
82 if ( current->size_word > 0 && current->base )
83 {
84 dest[cpos].iov_base = reinterpret_cast<void*>( const_cast<uint32_t*>( current->base ) );
85 dest[cpos].iov_len = sizeof( uint32_t ) * current->size_word;
86 ++cpos;
87 }
88 current = current->next;
89 }
90 return cpos;
91}
const Int_t n
#define max(a, b)
**********Class see also m_nmax DOUBLE PRECISION m_amel DOUBLE PRECISION m_x2 DOUBLE PRECISION m_alfinv DOUBLE PRECISION m_Xenph INTEGER m_KeyWtm INTEGER m_idyfs DOUBLE PRECISION m_zini DOUBLE PRECISION m_q2 DOUBLE PRECISION m_Wt_KF DOUBLE PRECISION m_WtCut INTEGER m_KFfin *COMMON c_KarLud $ !Input CMS energy[GeV] $ !CMS energy after beam spread beam strahlung[GeV] $ !Beam energy spread[GeV] $ !z boost due to beam spread $ !electron beam mass *ff pair spectrum $ !minimum v
Definition KarLud.h:35
uint32_t count(const node_t &list)
Definition node.cxx:38
uint32_t shallow_copy(const node_t &list, struct iovec *dest, uint32_t max)
Definition node.cxx:76
uint32_t copy(const node_t &list, uint32_t *dest, size_t max)
Definition node.cxx:60
void set(node_t &i, const uint32_t *b, size_t l, node_t *n=0)
Definition node.cxx:16
uint32_t count_words(const node_t &list)
Definition node.cxx:49
void cat(node_t *n, const struct iovec *v, uint32_t count)
Definition node.cxx:28
uint32_t * base
The base address for this page.
size_t size_word
The size, in 4-byte words for this page.