Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
testhddm.cpp
Go to the documentation of this file.
1 #include <iostream>
2 #include <fstream>
3 using namespace std;
4 #include "hddm_v.h"
5 #include "hddm_v.hpp"
6 
9 
10 int main()
11 {
12  // the following two output files should be identical
13  test_hddm_c_interface("test.hddm");
14  test_hddm_cpp_interface("test2.hddm");
15  return 0;
16 }
17 
19 {
20  v_iostream_t *outputfp = init_v_HDDM(outfile);
21  if (!outputfp) {
22  cerr << "Test failed: error opening output file\n";
23  exit(1);
24  }
25 
26  v_HDDM_t *event;
27  v_GenericTag_t *tag;
28  event = make_v_HDDM();
29  tag = make_v_GenericTag();
30  tag->floatTag = make_v_FloatTag();
31  tag->doubleTag = make_v_DoubleTag();
32  tag->particleTag = make_v_ParticleTag();
33  tag->stringTag = make_v_StringTag();
34  tag->intTag = make_v_IntTag();
35  tag->longTag = make_v_LongTag();
36  tag->booleanTag = make_v_BooleanTag();
37  tag->anyURITag = make_v_AnyURITag();
38  tag->floatTag->pi = 3.141593;
39  tag->doubleTag->pi = 3.141592592636;
40  tag->particleTag->pi = PiPlus;
41 
42  tag->stringTag->quote = (char*)malloc(100);
43  strcpy(tag->stringTag->quote,"pass the red quarks, please");
44  tag->intTag->magic = 133557799;
45  tag->longTag->magic = 133557799002244668LL;
46  tag->booleanTag->truth = 1;
47  tag->anyURITag->uri = (char*)malloc(100);
48  strcpy(tag->anyURITag->uri,"http://portal.gluex.org");
49  event->genericTag = tag;
50 
51  flush_v_HDDM(event,outputfp);
52  close_v_HDDM(outputfp);
53 }
54 
56 {
57  ofstream ofs(outfile);
58  if (!ofs.is_open()) {
59  cerr << "Test failed: error opening output file\n";
60  exit(1);
61  }
62 
63  hddm_v::HDDM record;
64  hddm_v::GenericTagList generics = record.addGenericTags();
65  hddm_v::FloatTagList floats = generics().addFloatTags();
66  hddm_v::DoubleTagList doubles = generics().addDoubleTags();
67  hddm_v::ParticleTagList particles = generics().addParticleTags();
68  hddm_v::StringTagList strings = generics().addStringTags();
69  hddm_v::IntTagList ints = generics().addIntTags();
70  hddm_v::LongTagList longs = generics().addLongTags();
71  hddm_v::BooleanTagList booleans = generics().addBooleanTags();
72  hddm_v::AnyURITagList anyURIs = generics().addAnyURITags();
73  floats().setPi(3.141593);
74  doubles().setPi(3.141592592636);
75  particles().setPi(PiPlus);
76  strings().setQuote("pass the red quarks, please");
77  ints().setMagic(133557799);
78  longs().setMagic(133557799002244668LL);
79  booleans().setTruth(1);
80  anyURIs().setUri("http://portal.gluex.org");
81 
82  hddm_v::ostream ostr(ofs);
83  ostr << record;
84 }
void test_hddm_cpp_interface(char *outfile)
Definition: testhddm.cpp:55
TFile * outfile
Definition: tw_corr.C:46
void test_hddm_c_interface(char *outfile)
Definition: testhddm.cpp:18
int main(int argc, char *argv[])
Definition: gendoc.cc:6