CHROMA
map_obj_disk_w.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 /*! \file
3  * \brief Disk based std::map object, factory registration
4  */
5 
6 #include "chromabase.h"
7 #include "qdp_map_obj_disk.h"
11 #include <string>
12 
13 namespace Chroma
14 {
15 
16  namespace MapObjectDiskEnv
17  {
18 
19  namespace
20  {
21  // Parameter structure
22  struct Params
23  {
24  Params() {}
25  Params(XMLReader& xml_in, const std::string& path);
26 
28  };
29 
30  // Reader for input parameters
31  Params::Params(XMLReader& xml, const std::string& path)
32  {
33  XMLReader paramtop(xml, path);
34 
35  read(paramtop, "FileName", file_name);
36  }
37 
38 
39 
40  //! Callback function
41  QDP::MapObject<int,EVPair<LatticeColorVector> >* createMapObjIntKeyCV(XMLReader& xml_in,
42  const std::string& path,
43  const std::string& user_data)
44  {
45  // Needs parameters...
46  Params params(xml_in, path);
47 
48  auto obj = new QDP::MapObjectDisk<int,EVPair<LatticeColorVector> >();
49  obj->insertUserdata(user_data);
50  obj->open(params.file_name, std::ios_base::in | std::ios_base::out | std::ios_base::trunc);
51 
52  return obj;
53  }
54 
55  //! Callback function
56  QDP::MapObject<KeyPropColorVec_t,LatticeFermion>* createMapObjKeyPropColorVecLF(XMLReader& xml_in,
57  const std::string& path,
58  const std::string& user_data)
59  {
60  // Needs parameters...
61  Params params(xml_in, path);
62 
63  auto obj = new QDP::MapObjectDisk<KeyPropColorVec_t,LatticeFermion>();
64  obj->insertUserdata(user_data);
65  obj->open(params.file_name, std::ios_base::in | std::ios_base::out | std::ios_base::trunc);
66 
67  return obj;
68  }
69 
70  //! Local registration flag
71  bool registered = false;
72 
73  //! Name to be used
74  const std::string name = "MAP_OBJECT_DISK";
75  } // namespace anontmous
76 
77  std::string getName() {return name;}
78 
79  //! Register all the factories
80  bool registerAll()
81  {
82  bool success = true;
83  if (! registered)
84  {
85  QDPIO::cout << __PRETTY_FUNCTION__ << ": registering map obj key colorvec" << std::endl;
86  success &= Chroma::TheMapObjIntKeyColorEigenVecFactory::Instance().registerObject(name, createMapObjIntKeyCV);
87  success &= Chroma::TheMapObjKeyPropColorVecFactory::Instance().registerObject(name, createMapObjKeyPropColorVecLF);
88  registered = true;
89  }
90  return success;
91  }
92  } // Namespace MapObjectDiskEnv
93 
94 
95 } // Chroma
Primary include file for CHROMA library code.
static T & Instance()
Definition: singleton.h:432
void read(XMLReader &xml, const std::string &path, AsqtadFermActParams &param)
Read parameters.
Params params
Handle< MapObject< int, EVPair< LatticeColorVector > > > obj
Key for propagator colorstd::vector sources.
std::string file_name
Header file for std::map obj aggregate registrations.
static bool registered
Local registration flag.
const std::string name
Name to be used.
bool registerAll()
Register all the factories.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
static QDP_ColorVector * out
Constructor.
static QDP_ColorVector * in
::std::string string
Definition: gtest.h:1979