Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

Printable.cxx

Go to the documentation of this file.
00001 
00002 // $Id: Printable.cxx,v 1.1 2007/02/09 04:44:13 fmwk Exp $
00003 //
00004 // Base class for printable objects
00005 //
00006 // messier@indiana.edu
00008 #include "EventDisplayBase/Printable.h"
00009 #include <iostream>
00010 using namespace evdb;
00011 
00012 // ClassImp(evdb::Printable)
00013 
00014 static std::map<std::string,Printable*> gsPrintables;
00015 
00016 //......................................................................
00017 
00018 Printable::Printable() { }
00019 
00020 //......................................................................
00021 
00022 Printable::~Printable() 
00023 {
00024   Printable::RemoveFromListOfPrintables(this);
00025 }
00026 
00027 //......................................................................
00028 
00029 void Printable::AddToListOfPrintables(const char* name, 
00030                                          Printable* p) 
00031  {
00032   std::string s(name);
00033 
00034   if (gsPrintables[s] == 0) {
00035     gsPrintables[s] = p;
00036   }
00037   else {
00038     if (gsPrintables[s] != p) {
00039       std::cerr << "Printable: Name " << name << " reused.\n";
00040       abort();
00041     }
00042   }
00043 }
00044 
00045 //......................................................................
00046 
00047 void Printable::RemoveFromListOfPrintables(Printable* p) 
00048 {
00049   std::map<std::string,Printable*>::iterator itr(gsPrintables.begin());
00050   std::map<std::string,Printable*>::iterator itrEnd(gsPrintables.end());
00051   for (; itr!=itrEnd; ++itr) {
00052     if ( itr->second == p) {
00053       gsPrintables.erase(itr);
00054       return;
00055     }
00056   }
00057 }
00058 
00059 //......................................................................
00060 
00061 std::map<std::string,Printable*>& Printable::GetPrintables() 
00062 {
00063   return gsPrintables;
00064 }
00065 
00067 

Generated on Sat Oct 11 02:35:28 2008 for NOvA Offline by  doxygen 1.3.9.1