[Graphics] More convenient backend access

John W. Eaton jwe at bevo.che.wisc.edu
Sat Feb 2 01:56:59 CST 2008


On  2-Feb-2008, Shai Ayal wrote:

| On Feb 1, 2008 12:58 PM, Shai Ayal <shaiay at gmail.com> wrote:
| >
| > On Feb 1, 2008 12:11 PM, Michael Goffioul <michael.goffioul at gmail.com> wrote:
| > > On Fri, Feb 1, 2008 at 8:07 AM, Shai Ayal <shaiay at gmail.com> wrote:
| > > > Attached is a patch which adds the figure.__backend__ property and
| > > > relevant set method
| > > > Michael, can you please have a look and approve -- I'm not sure I
| > > > understood the interaction between graphics_backend and figure.
| > > >
| > > > Shai
| > > >
| > > > 2008-02-01  Shai Ayal  <shaiay at users.sourceforge.net>
| > > >
| > > >        * graphics.h.in (figure): add __backend__ property and set method
| > > >        (class graphics_backend): add find_backend method
| > > >
| > >
| > > It looks OK (although I don't understand why you call find_backend
| > > twice; you could re-use "b", no?).
| >
| > you are correct -- it is a typo.
| 
| The corrected patch attached
| Shai
| 
| 2008-02-01  Shai Ayal  <shaiay at users.sourceforge.net>
| 
|        * graphics.h.in (figure): add __backend__ property and set method
|        (class graphics_backend): add find_backend method

I applied this patch and checked it in but changed

| +  static graphics_backend find_backend (const std::string& name)
| +  {
| +    if (available_backends.find (name) != available_backends.end ())
| +      return available_backends[name];
| +    else
| +      return default_backend ();
| +  }

to be

  static graphics_backend find_backend (const std::string& name)
  {
    const_available_backends_iterator p = available_backends.find (name);

    if (p != available_backends.end ())
      return p->second;
    else
      return default_backend ();
  }

(along with adding some typedefs for the iterators).  I know that this
change is not terribly important, but we might as well only do the map
lookup once.

Thanks,

jwe


More information about the Octave-maintainers mailing list