[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Graphics properties as objects
From: |
John W. Eaton |
Subject: |
Re: Graphics properties as objects |
Date: |
Tue, 08 Jan 2008 08:47:37 -0500 |
On 8-Jan-2008, Michael Goffioul wrote:
| I thought again about possible implementation, trying to consider everything.
| So I'd like to propose the following scheme. Would this be acceptable?
|
| Note: I decided to write the direct access get_xxx methods such that they
| return the property value; the reason is that those accessors will mostly be
| used by the C++ backend, which is mainly interested in the values; this makes
| the code of the backend more intuitive.
|
| class base_property
| {
| public:
| ...
|
| void set_name (const std::string& name);
|
| void set_parent (const graphics_handle& h);
| };
|
| class matrix_property : public base_property
| {
| public:
| matrix_property (Matrix m)
| : base_property (), data (m) { }
|
| ...
|
| Matrix matrix_value (void) const { return data; }
|
| private:
| Matrix data;
| };
|
| class property
| {
| public:
| property (base_property *p, bool persist = false);
| ...
| };
What is the rest of this class? Does it include reference counting?
How is it expected to be used?
| class base_properties
| {
| public:
| ...
|
| // this method is to add dynamic properties into the map
| void insert_property (const std::string& name, property p)
| {
| p.set_name (name);
| p.set_parent (__myhandle__);
| all_props[name] = p;
| }
I'm surprised to see the property argument above not be a reference or
pointer. Doesn't this cause a copy to be made when insert_property is
called?
| // this method is to add fixed properties into the map
| // (could probably be "protected")
| void insert_static_property (const std::string& name, base_property& p)
| {
| p.set_name (name);
| p.set_parent (__myhandle__);
| all_props[name] = property (&p, true);
| }
| };
|
| class axes : public graphics_object
| {
| public:
| class properties : public base_properties
| {
| public:
| properties (...)
| : base_properties (...) ,
| position (Matrix ()),
| ...
| {
| insert_static_property ("position", position);
| ...
| }
|
| Matrix get_position (void) const { return position.matrix_value (); }
Would the backend never need access to the additional information
stored in the matrix_property object? If not then I think this is
OK. Otherwise, why not just return the matrix_property object
directly?
jwe
- Re: Graphics properties as objects, (continued)
- Re: Graphics properties as objects, Michael Goffioul, 2008/01/05
- Re: Graphics properties as objects, John Swensen, 2008/01/05
- Re: Graphics properties as objects, John W. Eaton, 2008/01/05
- Re: Graphics properties as objects, John W. Eaton, 2008/01/05
- Re: Graphics properties as objects, Michael Goffioul, 2008/01/06
- Re: Graphics properties as objects, John W. Eaton, 2008/01/06
- Re: Graphics properties as objects, Michael Goffioul, 2008/01/06
- Re: Graphics properties as objects, Michael Goffioul, 2008/01/08
- Re: Graphics properties as objects,
John W. Eaton <=
- Re: Graphics properties as objects, Michael Goffioul, 2008/01/08
- Re: Graphics properties as objects, Shai Ayal, 2008/01/08
- Re: Graphics properties as objects, Michael Goffioul, 2008/01/08
- Re: Graphics properties as objects, John W. Eaton, 2008/01/08
- Re: Graphics properties as objects, Michael Goffioul, 2008/01/08
- Re: Graphics properties as objects, Michael Goffioul, 2008/01/09
- Re: Graphics properties as objects, Shai Ayal, 2008/01/09
- Re: Graphics properties as objects, Michael Goffioul, 2008/01/09
- Re: Graphics properties as objects, Shai Ayal, 2008/01/09
- Re: Graphics properties as objects, Michael Goffioul, 2008/01/10