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

BuilderFac.cxx

Go to the documentation of this file.
00001 
00002 // $Id: BuilderFac.cxx,v 1.1 2007/02/09 04:44:14 fmwk Exp $
00003 //
00005 //
00006 // messier@indiana.edu
00008 #include <iostream>
00009 #include "XMLInterface/BuilderFac.h"
00010 
00011 xmli::BuilderFac* xmli::BuilderFac::fInstance = 0;
00012 
00013 //......................................................................
00014 
00015 xmli::BuilderFac& xmli::BuilderFac::Instance() 
00016 {
00017 //======================================================================
00018 // Return the sole instance of the factory
00019 //======================================================================
00020   if (fInstance == 0) fInstance = new xmli::BuilderFac;
00021   return *fInstance;
00022 }
00023 
00024 //......................................................................
00025 
00026 void xmli::BuilderFac::Register(const char* name, xmli::Builder* b) 
00027 {
00028 //======================================================================
00029 // Insert a builder b into the table.
00030 //   name - XML tag the builder handles
00031 //   b    - builder which handles tag
00032 //======================================================================
00033   std::string n(name);
00034   if (fBuilders[n] == 0) { fBuilders[n] = b; return; }
00035   // else
00036   std::cerr << "Builder for type '" << name << "' doublely defined.\n";
00037   abort();
00038 }
00039 
00040 //......................................................................
00041 
00042 xmli::Builder* xmli::BuilderFac::Get(const char* name) 
00043 {
00044 //======================================================================
00045 // Pull builder for tag out of table
00046 //   name - XML tag we need a builder for
00047 //======================================================================
00048   return this->Get(std::string(name));
00049 }
00050 
00051 //......................................................................
00052 
00053 xmli::Builder* xmli::BuilderFac::Get(const std::string& name) 
00054 {
00055 //======================================================================
00056 // Pull builder for tag out of table
00057 //   name - XML tag we need a builder for
00058 //======================================================================
00059   return fBuilders[name];
00060 }
00061 
00062 //......................................................................  
00063 
00064 xmli::BuilderFac::BuilderFac() { }
00065 

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