HighLAND
DocStringManager.cxx
1 #include "DocStringManager.hxx"
2 
3 
4 //********************************************************************
5 DocStringManager::DocStringManager(): HLClonesArray("config","DocString","DocString",1000){
6 //********************************************************************
7 
8 }
9 
10 //********************************************************************
11 void DocStringManager::ReadDocStrings(const std::string& file){
12 //********************************************************************
13 
14  ReadClonesArray(file);
15 }
16 
17 //********************************************************************
18 void DocStringManager::ExplainVar(const std::string& name, const std::string& tree_name) {
19 //********************************************************************
20  for (int i = 0; i < _NObjects; i++) {
21  DocString* doc = (DocString*) _objects->At(i);
22  if (!doc) {
23  std::cout << "Unable to read docstring " << i << std::endl;
24  continue;
25  }
26  if (doc->Name() == name && doc->Tree() == tree_name) {
27  doc->Explain();
28  return;
29  }
30  }
31 
32  std::cout << "Unable to find requested variable" << std::endl;
33 }
34 
35 //********************************************************************
36 void DocStringManager::ListVars(const std::string& tree_name) {
37 //********************************************************************
38  std::vector<std::string> vars;
39 
40  for (int i = 0; i < _NObjects; i++) {
41  DocString* doc = (DocString*) _objects->At(i);
42  if (!doc) {
43  std::cout << "Unable to read docstring " << i << std::endl;
44  continue;
45  }
46  if (doc->Tree() == tree_name) {
47  vars.push_back(doc->Name());
48  }
49  }
50 
51  std::sort(vars.begin(), vars.end());
52 
53  for (unsigned int i = 0; i < vars.size(); i++) {
54  std::cout << vars[i] << std::endl;
55  }
56 }
void Explain()
Definition: DocString.cxx:29
std::string Name()
Get the name of this variable.
Definition: DocString.hxx:33
void ExplainVar(const std::string &name, const std::string &tree_name)
Print the details of the specified variable in the given tree.
void ListVars(const std::string &tree_name)
List all the variables that were stored in this tree.
std::string Tree()
Get the name of the tree this variable was stored in.
Definition: DocString.hxx:36
void ReadDocStrings(const std::string &file)