oopapidocs  2.0
customerfactory.cpp
00001 #include "customerfactory.h"
00002 #include "customerlist.h"
00003 #include "address.h"
00004 #include <QDebug>
00005 
00006 #include <QApplication>
00007 
00008 //start id="singleton"
00009 CustomerFactory* CustomerFactory::instance() {
00010     static CustomerFactory* retval = 0;
00011     if (retval == 0) retval = new CustomerFactory(qApp); /* Ensures this object and all its children are cleaned up when the QApplication exits. */
00012     return retval;
00013 }
00014 //end
00015 
00016 Address* CustomerFactory::newAddress(QString countryType, QObject* parent) {
00017     if (parent ==0) parent = this;
00018     if (countryType == "USA") {
00019         return new UsAddress(QString(), parent);
00020     }
00021     if (countryType == "Canada") {
00022         return new CanadaAddress(QString(), parent);
00023     }
00024     return new UsAddress(QString(), parent);
00025 }
00026 
00027 Customer* CustomerFactory::newCustomer(QString name, QObject* parent) {
00028     if (parent ==0) parent = this;
00029 
00030     Customer* retval = new Customer (name, parent);
00031     return retval;
00032 }
00033 
00034 //start id="ctor"
00035 
00036 CustomerFactory::CustomerFactory(QObject* parent) : QObject(parent) {
00037     m_knownClasses["Customer"] = Customer::staticMetaObject;
00038     m_knownClasses["CustomerList"] = Customer::staticMetaObject;
00039 }
00040 
00041 //end
 All Classes Namespaces Functions Enumerations