示例#1
0
// build a display
static void builder(const char* const testFileName)
{
    // Read the description file
    int errors = 0;
    Eaagles::Basic::Object* q1 = Eaagles::Basic::lcParser(testFileName, factory, &errors);
    if (errors > 0) {
        std::cerr << "Errors in reading file: " << errors << std::endl;
        std::exit(EXIT_FAILURE);
    }

    // Set 'station' to our basic description object.
    station = nullptr;
    if (q1 != nullptr) {

        // When we were given a Pair, get the pointer to its object.
        Eaagles::Basic::Pair* pp = dynamic_cast<Eaagles::Basic::Pair*>(q1);
        if (pp != nullptr) {
           std::cout << "Form: " << *pp->slot() << std::endl;
           q1 = pp->object();
        }

        // What we should have here is the description object and
        // it should be of type 'Station'.
        station = dynamic_cast<Station*>(q1);
    }

    // Make sure we did get a valid object (we must have one!)
    if (station == nullptr) {
        std::cout << "Invalid description file!" << std::endl;
        std::exit(EXIT_FAILURE);
    }

    //station->serialize(std::cout);
}
示例#2
0
 // build a station
 static Eaagles::Simulation::Station* builder(const char* const fileName)   {
   Eaagles::Simulation::Station* p = 0;
   // Read the description file
   int errors = 0;
   Eaagles::Basic::Object* q1 = Eaagles::Basic::lcParser(fileName, Eaagles::Factory::createObj, &errors);
   if (errors > 0) {
     std::cerr << "File: " << fileName << ", errors: " << errors << std::endl;
     return 0;
   }
   if (q1 != 0) {
     // When we were given a Basic::Pair, get the pointer to its object.
     Eaagles::Basic::Pair* pp = dynamic_cast<Eaagles::Basic::Pair*>(q1);
     if (pp != 0) {
       q1 = pp->object();
     }
     // What we should have here is the Station object
     p = dynamic_cast<Eaagles::Simulation::Station*>(q1);
   }
   return p;
 }