CHROMA
xml_write_obj_funcmap.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Write object function std::map
3  */
4 
5 #include "named_obj.h"
8 #include "util/ferm/eigeninfo.h"
9 
10 namespace Chroma
11 {
12 
13  //! IO function std::map environment
14  /*! \ingroup inlineio */
15  namespace XMLWriteObjCallMapEnv
16  {
17  // Anonymous namespace
18  namespace
19  {
20  //! Write a propagator
21  void XMLWriteLatProp(const std::string& buffer_id,
22  const std::string& file)
23  {
24  LatticePropagator obj;
25  XMLBufferWriter file_xml, record_xml;
26 
27  obj = TheNamedObjMap::Instance().getData<LatticePropagator>(buffer_id);
28  TheNamedObjMap::Instance().get(buffer_id).getFileXML(file_xml);
29  TheNamedObjMap::Instance().get(buffer_id).getRecordXML(record_xml);
30 
31  XMLFileWriter to(file);
32  push(to,"LatticePropagator");
33  write(to,"FileXML",file_xml);
34  write(to,"RecordXML",record_xml);
35  write(to,"Object",obj);
36  pop(to);
37  to.close();
38  }
39 
40 
41  //! Write a fermion
42  void XMLWriteLatFerm(const std::string& buffer_id,
43  const std::string& file)
44  {
45  LatticeFermion obj;
46  XMLBufferWriter file_xml, record_xml;
47 
48  obj = TheNamedObjMap::Instance().getData<LatticeFermion>(buffer_id);
49  TheNamedObjMap::Instance().get(buffer_id).getFileXML(file_xml);
50  TheNamedObjMap::Instance().get(buffer_id).getRecordXML(record_xml);
51 
52  XMLFileWriter to(file);
53  push(to,"LatticeFermion");
54  write(to,"FileXML",file_xml);
55  write(to,"RecordXML",record_xml);
56  write(to,"Object",obj);
57  pop(to);
58  to.close();
59  }
60 
61 
62  //! Write a propagator
63  void XMLWriteLatStagProp(const std::string& buffer_id,
64  const std::string& file)
65  {
66  LatticeStaggeredPropagator obj;
67  XMLBufferWriter file_xml, record_xml;
68 
69  obj = TheNamedObjMap::Instance().getData<LatticeStaggeredPropagator>(buffer_id);
70  TheNamedObjMap::Instance().get(buffer_id).getFileXML(file_xml);
71  TheNamedObjMap::Instance().get(buffer_id).getRecordXML(record_xml);
72 
73  XMLFileWriter to(file);
74  push(to,"LatticeStaggeredPropagator");
75  write(to,"FileXML",file_xml);
76  write(to,"RecordXML",record_xml);
77  write(to,"Object",obj);
78  pop(to);
79  to.close();
80  }
81 
82 
83  //! Write a gauge field in floating precision
84  void XMLWriteArrayLatColMat(const std::string& buffer_id,
85  const std::string& file)
86  {
87  multi1d<LatticeColorMatrix> obj;
88  XMLBufferWriter file_xml, record_xml;
89 
90  obj = TheNamedObjMap::Instance().getData< multi1d<LatticeColorMatrix> >(buffer_id);
91  TheNamedObjMap::Instance().get(buffer_id).getFileXML(file_xml);
92  TheNamedObjMap::Instance().get(buffer_id).getRecordXML(record_xml);
93 
94  XMLFileWriter to(file);
95  push(to,"Multi1dLatticeColorMatrix");
96  write(to,"FileXML",file_xml);
97  write(to,"RecordXML",record_xml);
98  write(to,"Object",obj);
99  pop(to);
100  to.close();
101  }
102 
103  //! Local registration flag
104  bool registered = false;
105 
106  } // end anonymous namespace
107 
108 
109  //! Register all the factories
110  bool registerAll()
111  {
112  bool success = true;
113  if (! registered)
114  {
115  success &= TheXMLWriteObjFuncMap::Instance().registerFunction(std::string("LatticePropagator"),
116  XMLWriteLatProp);
117  success &= TheXMLWriteObjFuncMap::Instance().registerFunction(std::string("LatticeFermion"),
118  XMLWriteLatFerm);
119  success &= TheXMLWriteObjFuncMap::Instance().registerFunction(std::string("LatticeStaggeredPropagator"),
120  XMLWriteLatStagProp);
121  success &= TheXMLWriteObjFuncMap::Instance().registerFunction(std::string("Multi1dLatticeColorMatrix"),
122  XMLWriteArrayLatColMat);
123 
124  registered = true;
125  }
126  return success;
127  }
128  }
129 
130 }
static T & Instance()
Definition: singleton.h:432
Hold eigenvalues and eigenvectors.
void write(XMLWriter &xml, const std::string &path, const AsqtadFermActParams &param)
Writer parameters.
Handle< MapObject< int, EVPair< LatticeColorVector > > > obj
Named object support.
Named object function std::map.
static bool registered
Local registration flag.
bool registerAll()
Register all the factories.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
push(xml_out,"Condensates")
pop(xml_out)
::std::string string
Definition: gtest.h:1979
Write object function std::map.