[xsde-users] Re: Determine whether an object model supports
polymorphism
Thomas Frenzel (TomSun)
tftomsun at streamteam.de
Wed Oct 21 13:25:30 EDT 2009
Hello Boris,
first of all, thanks for your positive reply.
Quote:
Yes, it could be useful but it would also complicate things since
there should be error handling (with and without exceptions), etc.
I will keep it minimal for now and see how it goes.
Maybe you could reduce the effort in the generated code if you provide in your lib a static method... something like
static int ParseEnum(char* value, const char*[] enumNames)
{
// TODO do the error handling and getting the integer representation of the enum value here.
}
and you could just generated the constructor like this
inline color:
color (char* enumName)
v_ ((value)::ParseEnum(enumName,color_str_))
{
}
_____
From: Boris Kolpackov [mailto:boris at codesynthesis.com]
To: Thomas Frenzel (TomSun) [mailto:tftomsun at streamteam.de]
Cc: xsde-users at codesynthesis.com
Sent: Wed, 21 Oct 2009 16:41:09 +0200
Subject: Re: Determine whether an object model supports polymorphism
Hi Thomas,
Thomas Frenzel (TomSun) <tftomsun at streamteam.de> writes:
> Within the XmlManager template class i need the information whether
> the given object model class uses polymorphism or not in 3 cases
> (currently the boolean m_polymorphic indicates if the object model
> uses polymorphism):
Thanks for the explanation, it makes sense. I will add the boolean member
to the *_paggs and *_saggr classes.
> Yes the implementation looks sufficient for my needs. I am happy as long
> as i can convert from the string representation to the numeric
> representation and vice versa.
Ok, I will go ahead and implement this then. Should have something for
you to try in a few days unless I get sidetracked.
> Maybe an constructor overload that takes the string/char* would be
> useful, too.
Yes, it could be useful but it would also complicate things since
there should be error handling (with and without exceptions), etc.
I will keep it minimal for now and see how it goes.
> It would be nice if you could post the cpp file of your color example.
It will be something along these lines:
inline color:
color ()
v_ (red)
{
}
inline color:
color (value v)
v_ (v)
{
}
inline color:
operator value () const
{
return v_;
}
static const char* color_str_[] = {"red", "green", "blue"};
const char* color:
string () const
{
return color_str_[v_];
}
Boris
More information about the xsde-users
mailing list