BOSS 7.0.3
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:[email protected]">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{
18 i.base = const_cast<uint32_t*>(b);
19 i.size_word = l;
20 i.next = n;
21}
22
23void eformat::write::set (node_t& i, const struct iovec& v, node_t* n)
24{
25 i.base = reinterpret_cast<uint32_t*>(v.iov_base);
26 i.size_word = v.iov_len/4;
27 i.next = n;
28}
29
30void eformat::write::cat (node_t* n, const struct iovec* v, uint32_t count)
31{
32 for (size_t i=0; i<(count-1); ++i) set(n[i], v[i], &n[i+1]);
33 set(n[count-1], v[count-1], 0);
34}
35
37{
38 for (size_t i=0; i<(count-1); ++i) n[i].next = &n[i+1];
39 n[count-1].next = 0;
40}
41
42uint32_t eformat::write::count (const node_t& list)
43{
44 const eformat::write::node_t* current = &list;
45 uint32_t retval = 0;
46 while (current) {
47 ++retval;
48 current = current->next;
49 }
50 return retval;
51}
52
53uint32_t eformat::write::count_words (const node_t& list)
54{
55 const eformat::write::node_t* current = &list;
56 uint32_t retval = 0;
57 while (current) {
58 retval += current->size_word;
59 current = current->next;
60 }
61 return retval;
62}
63
64uint32_t eformat::write::copy (const node_t& list, uint32_t* dest,
65 size_t max)
66{
67 const eformat::write::node_t* current = &list;
68 uint32_t cpos = 0;
69 while (current) {
70 if (cpos + current->size_word > max) return 0;
71 if (current->size_word > 0 && current->base) {
72 memcpy(&dest[cpos], current->base, sizeof(uint32_t)*current->size_word);
73 cpos += current->size_word;
74 }
75 current = current->next;
76 }
77 return cpos;
78}
79
80uint32_t eformat::write::shallow_copy (const node_t& list, struct iovec* dest,
81 uint32_t max)
82{
83 const eformat::write::node_t* current = &list;
84 uint32_t cpos = 0;
85 while (current) {
86 if (cpos > max) return 0;
87 if (current->size_word > 0 && current->base) {
88 dest[cpos].iov_base =
89 reinterpret_cast<void*>(const_cast<uint32_t*>(current->base));
90 dest[cpos].iov_len = sizeof(uint32_t)*current->size_word;
91 ++cpos;
92 }
93 current = current->next;
94 }
95 return cpos;
96}
97
const Int_t n
DOUBLE_PRECISION count[3]
**********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:42
uint32_t shallow_copy(const node_t &list, struct iovec *dest, uint32_t max)
Definition: node.cxx:80
uint32_t copy(const node_t &list, uint32_t *dest, size_t max)
Definition: node.cxx:64
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:53
void cat(node_t *n, const struct iovec *v, uint32_t count)
Definition: node.cxx:30
uint32_t * base
The base address for this page.
size_t size_word
The size, in 4-byte words for this page.