next up previous
Objektpersistenz und ERZEUGER-Pattern


Beispiel:
Test der IOFactory: Typbeschreibungen aus benanntem File

 
// File: mFctTstF.cc

#include <iostream.h>
#include <IOFactry.h>
#include <PunktV.h>
#include <Rechteck.h>
#include <RchtckRn.h>
#include <Dreieck.h>
#include <Kreis.h>
#include <ZGeoObj.h>

int main()
{
  MapOfPrototypes Prototypes;
  IOFactory Factory(&Prototypes, "mFctTstF.in");
  Prototypes["[Rechteck]"] = new Rechteck;
  Prototypes["[RechteckRund]"] = new RechteckRund;
  Prototypes["[Dreieck]"] = new Dreieck;
  Prototypes["[Kreis]"] = new Kreis;
  Prototypes["[ZGeoObj]"] = new ZGeoObj(&Factory);

  while(Factory)
  {
    GeoObj *pNewGeoObj = Factory.CreateGeoObj();
    if(pNewGeoObj)
      cout << pNewGeoObj->GetTypeString()
           << " created." << endl;
  }
}


next up previous