CHROMA
inline_erase_mg_proto_space.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Inline task to erase an object from a named buffer
3  *
4  * Named object writing
5  */
6 
10 
12 
13 
14 namespace Chroma
15 {
16  namespace InlineEraseMGProtoSpaceEnv
17  {
18  namespace
19  {
20  AbsInlineMeasurement* createMeasurement(XMLReader& xml_in,
21  const std::string& path)
22  {
23  return new InlineMeas(Params(xml_in, path));
24  }
25 
26  //! Local registration flag
27  bool registered = false;
28 
29  const std::string name = "ERASE_MG_PROTO_SUBSPACE";
30  }
31 
32  //! Register all the factories
33  bool registerAll()
34  {
35  bool success = true;
36  if (! registered)
37  {
38  success &= TheInlineMeasurementFactory::Instance().registerObject(name, createMeasurement);
39  registered = true;
40  }
41  return success;
42  }
43 
44 
45  //! Object buffer
46  void write(XMLWriter& xml, const std::string& path, const Params::NamedObject_t& input)
47  {
48  push(xml, path);
49 
50  write(xml, "object_id", input.object_id);
51 
52  pop(xml);
53  }
54 
55 
56  //! Object buffer
57  void read(XMLReader& xml, const std::string& path, Params::NamedObject_t& input)
58  {
59  XMLReader inputtop(xml, path);
60 
61  read(inputtop, "object_id", input.object_id);
62  }
63 
64 
65  // Param stuff
67 
68  Params::Params(XMLReader& xml_in, const std::string& path)
69  {
70  try
71  {
72  XMLReader paramtop(xml_in, path);
73 
74  if (paramtop.count("Frequency") == 1)
75  read(paramtop, "Frequency", frequency);
76  else
77  frequency = 1;
78 
79  // Ids
80  read(paramtop, "NamedObject", named_obj);
81  }
82  catch(const std::string& e)
83  {
84  QDPIO::cerr << __func__ << ": caught Exception reading XML: " << e << std::endl;
85  QDP_abort(1);
86  }
87  }
88 
89 
90  void
91  Params::writeXML(XMLWriter& xml_out, const std::string& path)
92  {
93  push(xml_out, path);
94 
95  // Ids
96  write(xml_out, "NamedObject", named_obj);
97 
98  pop(xml_out);
99  }
100 
101 
102  void
103  InlineMeas::operator()(unsigned long update_no,
104  XMLWriter& xml_out)
105  {
106  START_CODE();
107 
108  push(xml_out, "erase_mg_proto_subspace");
109  write(xml_out, "update_no", update_no);
110 
111  QDPIO::cout << name << ": object erase" << std::endl;
112 
113  // Erase the object
114  QDPIO::cout << "Attempt to erase object name = " << params.named_obj.object_id << std::endl;
115  write(xml_out, "object_id", params.named_obj.object_id);
117  QDPIO::cout << "MG PROTO Subspace: " << params.named_obj.object_id << " found. " << std::endl;
119  QDPIO::cout << "... deleted" << std::endl;
120  }
121  else {
122  QDPIO::cout << "MG PROTO Subspace Not Found. Aborting" <<std::endl;
123  QDP_abort(1);
124  }
125 
126  END_CODE();
127  }
128 
129  }
130 
131 }
Inline measurement factory.
void operator()(const unsigned long update_no, XMLWriter &xml_out)
Do the writing.
static T & Instance()
Definition: singleton.h:432
Inline task to erase a named mg space.
Named object function std::map.
static bool registered
Local registration flag.
const std::string name
Name to be used.
bool registerAll()
Register all the factories.
void write(XMLWriter &xml, const std::string &path, const Params::NamedObject_t &input)
Object buffer.
void read(XMLReader &xml, const std::string &path, Params::NamedObject_t &input)
Object buffer.
void deleteMGPreconditioner(const std::string &subspaceId)
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
push(xml_out,"Condensates")
pop(xml_out)
START_CODE()
::std::string string
Definition: gtest.h:1979
struct Chroma::InlineEraseMGProtoSpaceEnv::Params::NamedObject_t named_obj
void writeXML(XMLWriter &xml_out, const std::string &path)