octave-maintainers
[Top][All Lists]
Advanced

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

Re: Graphics properties as objects


From: Michael Goffioul
Subject: Re: Graphics properties as objects
Date: Tue, 8 Jan 2008 10:57:30 +0100

Hi,

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);
    ...
};

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;
      }

    // 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 (); }

    void set_position (const octave_value& v) { position.set (v); }

    ...

  private:
    matrix_property position;
    ...
  };
};


reply via email to

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