CHROMA
inline_list_obj.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Inline task to list an object from a named buffer
3  *
4  * Named object writing
5  */
6 
10 
11 namespace Chroma
12 {
13  namespace InlineListNamedObjEnv
14  {
15  namespace
16  {
17  AbsInlineMeasurement* createMeasurement(XMLReader& xml_in,
18  const std::string& path)
19  {
20  return new InlineListNamedObj(InlineListNamedObjParams(xml_in, path));
21  }
22 
23  //! Local registration flag
24  bool registered = false;
25  }
26 
27  const std::string name = "LIST_NAMED_OBJECT";
28 
29  //! Register all the factories
30  bool registerAll()
31  {
32  bool success = true;
33  if (! registered)
34  {
35  success &= TheInlineMeasurementFactory::Instance().registerObject(name, createMeasurement);
36  registered = true;
37  }
38  return success;
39  }
40  }
41 
42 
43  // Param stuff
45 
47  {
48  try
49  {
50  XMLReader paramtop(xml_in, path);
51 
52  if (paramtop.count("Frequency") == 1)
53  read(paramtop, "Frequency", frequency);
54  else
55  frequency = 1;
56  }
57  catch(const std::string& e)
58  {
59  QDPIO::cerr << __func__ << ": caught Exception reading XML: " << e << std::endl;
60  QDP_abort(1);
61  }
62  }
63 
64 
65  void
66  InlineListNamedObjParams::write(XMLWriter& xml_out, const std::string& path)
67  {
68  push(xml_out, path);
69 
70  pop(xml_out);
71  }
72 
73 
74  void
75  InlineListNamedObj::operator()(unsigned long update_no,
76  XMLWriter& xml_out)
77  {
78  START_CODE();
79 
80  push(xml_out, "list_named_obj");
81  write(xml_out, "update_no", update_no);
82 
83  QDPIO::cout << InlineListNamedObjEnv::name << ": object list" << std::endl;
84 
85  // List the object
86  QDPIO::cout << "Attempt to list all object names" << std::endl;
87  try
88  {
89  TheNamedObjMap::Instance().dump();
90  }
91  catch( std::bad_cast )
92  {
93  QDPIO::cerr << InlineListNamedObjEnv::name << ": cast error"
94  << std::endl;
95  QDP_abort(1);
96  }
97  catch (const std::string& e)
98  {
99  QDPIO::cerr << InlineListNamedObjEnv::name << ": error message: " << e
100  << std::endl;
101  QDP_abort(1);
102  }
103 
104  QDPIO::cout << InlineListNamedObjEnv::name << ": ran successfully" << std::endl;
105 
106  pop(xml_out); // list_named_obj
107 
108  END_CODE();
109  }
110 
111 }
Inline measurement factory.
Inline writing of memory objects.
void operator()(const unsigned long update_no, XMLWriter &xml_out)
Do the writing.
static T & Instance()
Definition: singleton.h:432
void read(XMLReader &xml, const std::string &path, AsqtadFermActParams &param)
Read parameters.
void write(XMLWriter &xml, const std::string &path, const AsqtadFermActParams &param)
Writer parameters.
Inline task to write an object from a named buffer.
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)
START_CODE()
::std::string string
Definition: gtest.h:1979
void write(XMLWriter &xml_out, const std::string &path)