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

Generated on Mon Nov 23 04:45:24 2009 for NOvA Offline by  doxygen 1.3.9.1