Developer forums (C::B DEVELOPMENT STRICTLY!) > Compiler Framework Redesign

cbProperty class

(1/1)

rickg22:
The cbProperty class will (along with cbVariant) form part of the SDK for the general and plugins development.

I'm planning to release these basic classes with the wxWidgets license, as all people can use them without licensing problems.

The idea.

The idea behind cbProperty is to have an extensible, serializable, and flexible class for holding configuration data - NO MATTER the complexity of the data itself. Being an certified expert in XML, i thought: Why not make it a tree?

And here's what I came up with:


--- Code: ---class cbProperty;
class cbVariant; // See the other thread
typedef map<wxString, cbVariant, less<wxString> > cbAttributes;
typedef map<wxString, cbProperty*, less<wxString> > cbProperties;

class cbProperty
{
    virtual wxString className() { return _T("cbProperty"); }
    wxString TagName;
    cbAttributes m_Attrs;
    cbProperties m_Children;
};

--- End code ---

The Explanation.
In other words, a cbProperty consists of associative arrays of cbAttributes (a map of variants, accessible by a string name) and of *cbProperty's, so it can be recursive.

The cbProperty destructor will dispose all of the class' children and attributes. By adding XML serialization, we only have to serialize the top node to serialize all the data.

Notice that the cbProperty class CAN BE subclassed, so you can add functions to query specific properties.

The sky's the limit!

In other words, when our compiler configuration can have UNLIMITED PROPERTIES, and is extensible, there will be no need to redesign it again. :)

Perhaps we could rewrite the CompilerOptionsBase and similar classes, as subclasses of cbProperty.
Opinions, ideas, criticisms?

Michael:

--- Quote from: rickg22 on December 30, 2005, 02:02:39 am ---
--- Code: ---class cbProperty;
class cbVariant; // See the other thread
typedef map<wxString, cbVariant, less<wxString> > cbAttributes;
typedef map<wxString, cbProperty*, less<wxString> > cbProperties;

class cbProperty
{
    virtual wxString className() { return _T("cbProperty"); }
    wxString TagName;
    cbAttributes m_Attrs;
    cbProperties m_Children;
};

--- End code ---

Opinions, ideas, criticisms?

--- End quote ---

Hello,

just a suggestion.

IMHO here the use a generic Comparator would be a better idea:


--- Code: ---typedef map<wxString, cbVariant, less<wxString> > cbAttributes;
typedef map<wxString, cbProperty*, less<wxString> > cbProperties;

--- End code ---

Michael

rickg22:
generic huh?

Navigation

[0] Message Index

Go to full version