KSquare Utilities
KKB::XmlFactoryManager Class Reference

#include <XmlStream.h>

Public Member Functions

 XmlFactoryManager (const KKStr &_name)
 
 ~XmlFactoryManager ()
 summary>Give the FactoryManager instance ownership of this factory; the name of the factory must be unique. More...
 
XmlFactoryFactoryLookUp (const KKStr &className) const
 
void RegisterFactory (XmlFactory *factory)
 

Detailed Description

Definition at line 357 of file XmlStream.h.

Constructor & Destructor Documentation

XmlFactoryManager::XmlFactoryManager ( const KKStr _name)

Definition at line 939 of file XmlStream.cpp.

References KKB::KKStr::KKStr(), and XmlFactoryManager().

Referenced by KKB::XmlFactory::FactoryLookUp(), KKB::XmlFactory::RegisterFactory(), and XmlFactoryManager().

939  :
940  factories (),
941  name (_name)
942 {
943 }
XmlFactoryManager::~XmlFactoryManager ( )

summary>Give the FactoryManager instance ownership of this factory; the name of the factory must be unique.

Definition at line 946 of file XmlStream.cpp.

947 {
948  map<KKStr, XmlFactory*>::iterator idx;
949  for (idx = factories.begin (); idx != factories.end (); ++idx)
950  {
951  XmlFactory* f = idx->second;
952  delete f;
953  }
954  factories.clear ();
955 }

Member Function Documentation

XmlFactory * XmlFactoryManager::FactoryLookUp ( const KKStr className) const

Definition at line 979 of file XmlStream.cpp.

References KKB::GlobalGoalKeeper::EndBlock(), and KKB::GlobalGoalKeeper::StartBlock().

Referenced by KKB::XmlFactory::FactoryLookUp(), and RegisterFactory().

980 {
982  XmlFactory* result = NULL;
983 
984  map<KKStr, XmlFactory*>::const_iterator idx;
985  idx = factories.find (className);
986  if (idx == factories.end ())
987  result = NULL;
988  else
989  result = idx->second;
990 
992  return result;
993 } /* FactoryLookUp */
void XmlFactoryManager::RegisterFactory ( XmlFactory factory)

Definition at line 959 of file XmlStream.cpp.

References KKB::XmlFactory::ClassName(), KKB::KKStr::Concat(), KKB::GlobalGoalKeeper::EndBlock(), FactoryLookUp(), KKB::KKException::KKException(), KKB::KKStr::KKStr(), and KKB::GlobalGoalKeeper::StartBlock().

Referenced by KKB::XmlFactory::RegisterFactory().

960 {
962  XmlFactory* existingFactory = FactoryLookUp (factory->ClassName ());
963  if (existingFactory)
964  {
966  KKStr errMsg (200);
967  errMsg << "XmlFactoryManager::RegisterFactory FactoryManager[" << name << "] Factory[" << factory->ClassName () << "] already exists." ;
968  cerr << endl << errMsg << endl << endl;
969  throw KKException (errMsg);
970  }
971  else
972  {
973  factories.insert (pair<KKStr, XmlFactory*> (factory->ClassName (), factory));
974  }
976 }
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
XmlFactory * FactoryLookUp(const KKStr &className) const
Definition: XmlStream.cpp:979
virtual const KKStr & ClassName() const
Definition: XmlStream.h:387

The documentation for this class was generated from the following files: