next up previous
Beispiel:
Streaming der Objekte;
gemeinsamer Stream für Daten und Typbeschreibungen

 
// File: mGeoFacG.cc

#include <fstream.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;
  ifstream ITypesAndDataIn("practdat.in");
  ofstream ITypesAndDataOut("practdat.out");
  IOFactory Factory(&Prototypes,
                    &ITypesAndDataIn,
                    &ITypesAndDataOut);

  Prototypes["[Rechteck]"] = new Rechteck;
  Prototypes["[RechteckRund]"] = new RechteckRund;
  Prototypes["[Dreieck]"] = new Dreieck;
  Prototypes["[Kreis]"] = new Kreis;
  Prototypes["[ZGeoObj]"] = new ZGeoObj(&Factory);

  GeoObj *pz2 = Factory.CreateGeoObj();
  if(pz2) {
    cout << pz2->GetTypeString() << " created." << endl;
    cout << "Now reading data ... ";
    ITypesAndDataIn >> (*pz2);
    cout << "finished." << endl;
    cout << "Flaeche: " << pz2->flaeche() << endl;
    Factory.CollectGeoObj(pz2);
    cout << "Pointer after collection is: "
         << hex << pz2 << endl;
  }
}



next up previous