[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

extensible ozone API



Hello Falko,

the Virtual Constructor is e.g. in Scott Meyers More Effective C++: Item 25 
described. In C++ this looks like:

class NLComponent {     // Abstract class
public:
         ...
}

class TextBlock: public NLComponent {
public:
         ...
}

class Graphic: public NLComponent {
public:
         ...
}

class NewsLetter {
public:
         NewsLetter(istream& str);
         ...
private:
         static NLComponent * readComponent(istream& str);
         list<NLComponent *> components;
}

NewsLetter::NewsLetter(istream& str) {
         while (str) {
                 // add the pointer returned by readComponent to the
                 // end of the components list; "push_back" is a list
                 // member function that inserts at the end of the list
                 components.push_back(readComponent(str));
         }
}

The main point is, that the static method readComponent() returns 
components of the different types.

After a day thinking about the tagging interface. It seems not so clever. 
The interface Serializable has no methods defined and is called as tagging 
interface because the object stream classes uses the interface to determine 
that the class should be serialized. For this purpose the interface should 
not define any methods. But then one must define two structures in 
parallel. There are to many possibilities to make errors.

Regards

Thomas

-------------------------------------------------------------------------------
Thomas Strauß                                             Tel: +49 40 3861 4876
Gerichtstraße 43                   email (privat): thomas.strauss@germanynet.de
22765 Hamburg                        email (office): thomas.strauss@philips.com
GERMANY
-------------------------------------------------------------------------------