LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
Printable.cxx
Go to the documentation of this file.
1 // $Id: Printable.cxx,v 1.2 2011-01-23 16:08:50 p-nusoftart Exp $
3 //
4 // Base class for printable objects
5 //
6 // messier@indiana.edu
9 #include <iostream>
10 #include <cstdlib>
11 
12 namespace evdb{
13 
14  static std::map<std::string,evdb::Printable*> gsPrintables;
15 
16  //......................................................................
17 
19 
20  //......................................................................
21 
23  {
25  }
26 
27  //......................................................................
28 
29  void Printable::AddToListOfPrintables(const char* name,
30  Printable* p)
31  {
32  std::string s(name);
33 
34  if (gsPrintables[s] == 0) {
35  gsPrintables[s] = p;
36  }
37  else {
38  if (gsPrintables[s] != p) {
39  std::cerr << "Printable: Name " << name << " reused.\n";
40  std::abort();
41  }
42  }
43  }
44 
45  //......................................................................
46 
48  {
49  std::map<std::string,Printable*>::iterator itr(gsPrintables.begin());
50  std::map<std::string,Printable*>::iterator itrEnd(gsPrintables.end());
51  for (; itr!=itrEnd; ++itr) {
52  if ( itr->second == p) {
53  gsPrintables.erase(itr);
54  return;
55  }
56  }
57  }
58 
59  //......................................................................
60 
61  std::map<std::string,evdb::Printable*>& Printable::GetPrintables()
62  {
63  return gsPrintables;
64  }
65 
66 }
68 
intermediate_table::iterator iterator
static void RemoveFromListOfPrintables(evdb::Printable *p)
Definition: Printable.cxx:47
Base class for printable objects.
Definition: Printable.h:15
static std::map< std::string, evdb::Printable * > gsPrintables
Definition: Printable.cxx:14
Manage all things related to colors for the event display.
Base class for printable objects.
static std::map< std::string, evdb::Printable * > & GetPrintables()
Definition: Printable.cxx:61
virtual ~Printable()
Definition: Printable.cxx:22
static void AddToListOfPrintables(const char *name, evdb::Printable *p)
Definition: Printable.cxx:29