Sierra Toolkit Version of the Day
WriterRegistry.cpp
00001 #include <stk_util/diag/WriterRegistry.hpp>
00002 #include <stk_util/diag/Option.hpp>
00003 
00004 namespace sierra {
00005 namespace Diag {
00006 
00007 WriterThrowSafe::WriterThrowSafe()
00008 {
00009   for (Diag::WriterRegistry::iterator it = Diag::getWriterRegistry().begin(); it != Diag::getWriterRegistry().end(); ++it)
00010     m_writerVector.push_back(new stk::diag::WriterThrowSafe(*(*it).second.first));
00011 }
00012 
00013 
00014 WriterThrowSafe::~WriterThrowSafe()
00015 {
00016   for (std::vector<stk::diag::WriterThrowSafe *>::iterator it = m_writerVector.begin(); it != m_writerVector.end(); ++it)
00017     delete (*it);
00018 }
00019 
00020 
00021 WriterRegistry::WriterRegistry()
00022 {}
00023 
00024 
00025 WriterRegistry::~WriterRegistry()
00026 {}
00027 
00028 
00029 WriterRegistry &
00030 getWriterRegistry()
00031 {
00032   static WriterRegistry s_writerRegistry;
00033 
00034   return s_writerRegistry;
00035 }
00036 
00037 
00038 void
00039 registerWriter(
00040   const std::string & name,
00041   Writer &    diag_writer,
00042   OptionMaskParser &    option_parser)
00043 {
00044   getWriterRegistry().insert(std::make_pair(name, std::make_pair(&diag_writer, &option_parser)));
00045 }
00046 
00047 
00048 void
00049 unregisterWriter(
00050   const std::string & name,
00051   Writer &    writer)
00052 {
00053   WriterRegistry::iterator it = getWriterRegistry().find(name);
00054   if (it != getWriterRegistry().end() && (*it).second.first == &writer)
00055     getWriterRegistry().erase(it);
00056 }
00057 
00058 } // namespace Diag
00059 } // namespace sierra
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines