NSCL DDAS  1.0
Support for XIA DDAS at the NSCL
 All Classes Namespaces Files Functions Variables Macros Pages
XMLCrateWriter.h
Go to the documentation of this file.
1 /*
2  This software is Copyright by the Board of Trustees of Michigan
3  State University (c) Copyright 2017.
4 
5  You may use this software under the terms of the GNU public license
6  (GPL). The terms of this license are described at:
7 
8  http://www.gnu.org/licenses/gpl.txt
9 
10  Authors:
11  Ron Fox
12  Giordano Cerriza
13  NSCL
14  Michigan State University
15  East Lansing, MI 48824-1321
16 */
17 
21 #ifndef XMLCRATEWRITER_H
22 #define XMLCRATEWRITER_H
23 #include "CrateWriter.h"
24 
25 #include <string>
26 #include <vector>
27 #include <tinyxml2.h>
28 
29 namespace DDAS {
59  class XMLCrateWriter : public CrateWriter {
60  public:
62 
63  // Mandatory things
64 
65  unsigned s_eventLength;
66  std::string s_moduleSettingsFile;
67 
68  // Optionals have a flage to specify an a value if the flag is true
69 
70  bool s_specifyFifoThreshold;
71  unsigned s_fifoThreshold;
72 
73  bool s_specifyTimestampScale;
74  double s_timestampScale;
75 
76  bool s_specifyInfinityClock;
77  bool s_infinityClock;
78 
79  bool s_specifyExternalClock;
80  bool s_externalClock;
81 
83  s_specifyFifoThreshold(false), s_specifyTimestampScale(false),
84  s_specifyInfinityClock(false),
85  s_specifyExternalClock(false) {}
86  };
87  private:
88  std::vector<ModuleInformation> m_additionalInfo;
89  std::string m_crateFile;
90  tinyxml2::XMLPrinter* m_pPrinter;
91  std::vector<unsigned short> m_slots;
92  public:
94  std::string crateFile,
95  const Crate& settings,
96  const std::vector<ModuleInformation>& metadata
97  );
98  virtual ~XMLCrateWriter();
99 
100  // The interface required by the strategy pattern:
101 
102  virtual void startCrate(
103  int id, const std::vector<unsigned short>& slots
104  );
105  virtual void endCrate(
106  int id, const std::vector<unsigned short>& slots
107  );
108  virtual SettingsWriter* getWriter(unsigned short slotNum);
109  private:
110  void writeSlotAttributes(const ModuleInformation& info);
111  unsigned slotId(unsigned short slotNumber);
112 
113  static void writeAttribute(
114  tinyxml2::XMLPrinter& p, const char* name, int value
115  );
116  static void writeAttribute(
117  tinyxml2::XMLPrinter& p, const char* name, bool value
118  );
119  static void writeAttribute(
120  tinyxml2::XMLPrinter& p, const char* name, double value
121  );
122  static void writeAttribute(
123  tinyxml2::XMLPrinter& p, const char* name, const char* value
124  );
125  static void writeAttribute(
126  tinyxml2::XMLPrinter& p, const char* name, unsigned value
127  );
128  };
129 }
130 
131 #endif
Definition: XMLCrateWriter.h:61
Definition: SettingsWriter.h:41
Definition: tinyxml2.h:2213
Definition: XMLCrateWriter.h:59
virtual SettingsWriter * getWriter(unsigned short slotNum)
Definition: XMLCrateWriter.cpp:139
XMLCrateWriter(std::string crateFile, const Crate &settings, const std::vector< ModuleInformation > &metadata)
Definition: XMLCrateWriter.cpp:38
virtual void startCrate(int id, const std::vector< unsigned short > &slots)
Definition: XMLCrateWriter.cpp:81
Definition: ModuleSettings.h:106
virtual ~XMLCrateWriter()
Definition: XMLCrateWriter.cpp:63
Definition: CrateWriter.h:31
virtual void endCrate(int id, const std::vector< unsigned short > &slots)
Definition: XMLCrateWriter.cpp:105
Definition: functions.h:26