octave-maintainers
[Top][All Lists]
Advanced

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

Re: Graphics properties as objects


From: Shai Ayal
Subject: Re: Graphics properties as objects
Date: Wed, 2 Jan 2008 20:41:53 +0200

On Jan 2, 2008 8:10 PM, Michael Goffioul <address@hidden> wrote:
> On 1/2/08, Shai Ayal <address@hidden> wrote:
> > I'm a bit reluctant to ask (maybe I'm showing my lack of c++
> > knowledge), but can you explain what problem this code tries to solve,
> > and what is the method of solution?
>
> This is just a skeleton, to illustrate what I had in mind. It does not
> contain all features. For the things I'm trying to address, I'd refer to
> my initial mail in this thread: if you want to have states in your
> properties (like hidden state), or if you want to have property-specific
> data (like listeners), or if you want to create list of properties (like
> for dynamic properties), my opinion is that it would be much easier
> to create property classes, with a common base class. This is
> what my proposal is trying to address: formalizing the concept of
> "property".
>
> What the proposed code does not show yet, is the fact that some
> features could be implemented in a more elegant way: for instance
> the get method, that could be common for all graphics objects
>
> octave_value base_properties::get (const caseless_str& name)
> {
>   std::map<caseless_str,property>::iterator it = all_props.find (name);
>   if (it != all_props.end ())
>     return (*it).get ();
>   else
>     {
>       warning ("unknown property: %s", name.c_str ());
>       return octave_value ();
>     }
> }

Thanks for the explanation. So, if I understand right, this approach
would allow very elegant ways to implement get/set by using virtual
functions and the all_props map, while still maintaining the ability
for c++ code (e.g. the renderer) to access the properties using their
"native" type, not going through some dynamic_cast ?

Shai


reply via email to

[Prev in Thread] Current Thread [Next in Thread]