Printable.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // $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
7 ////////////////////////////////////////////////////////////////////////
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 
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 }
67 ////////////////////////////////////////////////////////////////////////
68 
const XML_Char * name
Definition: expat.h:151
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
const char * p
Definition: xmltok.h:285
OStream cerr
Definition: OStream.cxx:7
Manage all things related to colors for the event display.
Definition: Display3DPad.h:11
Base class for printable objects.
const XML_Char * s
Definition: expat.h:262
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
enum BeamMode string