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 ////////////////////////////////////////////////////////////////////////
8 #include "nutools/EventDisplayBase/Printable.h"
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 
static QCString name
Definition: declinfo.cpp:673
intermediate_table::iterator iterator
static void RemoveFromListOfPrintables(evdb::Printable *p)
Definition: Printable.cxx:47
Base class for printable objects.
Definition: Printable.h:15
std::string string
Definition: nybbler.cc:12
static std::map< std::string, evdb::Printable * > gsPrintables
Definition: Printable.cxx:14
Manage all things related to colors for the event display.
static std::map< std::string, evdb::Printable * > & GetPrintables()
Definition: Printable.cxx:61
virtual ~Printable()
Definition: Printable.cxx:22
p
Definition: test.py:223
static void AddToListOfPrintables(const char *name, evdb::Printable *p)
Definition: Printable.cxx:29
static QCString * s
Definition: config.cpp:1042