Revision: 4440
          http://pd-gem.svn.sourceforge.net/pd-gem/?rev=4440&view=rev
Author:   zmoelnig
Date:     2011-08-08 14:32:56 +0000 (Mon, 08 Aug 2011)

Log Message:
-----------
add virtual dtors; reorder methods

Modified Paths:
--------------
    trunk/Gem/src/plugins/film.cpp
    trunk/Gem/src/plugins/film.h
    trunk/Gem/src/plugins/imageloader.h
    trunk/Gem/src/plugins/imagesaver.h
    trunk/Gem/src/plugins/record.cpp
    trunk/Gem/src/plugins/record.h
    trunk/Gem/src/plugins/video.cpp
    trunk/Gem/src/plugins/video.h

Modified: trunk/Gem/src/plugins/film.cpp
===================================================================
--- trunk/Gem/src/plugins/film.cpp      2011-08-08 14:32:15 UTC (rev 4439)
+++ trunk/Gem/src/plugins/film.cpp      2011-08-08 14:32:56 UTC (rev 4440)
@@ -17,6 +17,8 @@
 #include "film.h"
 #include "plugins/PluginFactory.h"
 
+gem::plugins::film :: ~film(void) {}
+
 gem::plugins::film*gem::plugins::film::getInstance(void) {
  return NULL;
 }

Modified: trunk/Gem/src/plugins/film.h
===================================================================
--- trunk/Gem/src/plugins/film.h        2011-08-08 14:32:15 UTC (rev 4439)
+++ trunk/Gem/src/plugins/film.h        2011-08-08 14:32:56 UTC (rev 4440)
@@ -39,26 +39,18 @@
 class GEM_EXTERN film
 {
  public:
+
+  //////////
+  // returns an instance wrapping all plugins or NULL
+  // if NULL is returned, you might still try your luck with manually 
accessing the 
+  // PluginFactory
   static film*getInstance(void);
 
-  ////////
-  // returns true if instance can be used in thread
-  virtual bool isThreadable(void) = 0;
+  /////////
+  // dtor must be virtual
+  virtual ~film(void);
 
   //////////
-  // set the wanted color-space
-  /* could be used for switching the colourspace on the fly 
-   * normally the colour-space of a film could be set when opening a movie
-   */
-  virtual void requestColor(GLenum format) = 0;
-  //////////
-  // get the actual color-space
-  /* what colour-space is in use ?
-   * returns 0 for none
-   */    
-  virtual int getColor(void) = 0;
-
-  //////////
   // open a movie up
   /* open the film "filename" (think better about URIs ?)
    * try to open the film in the colourspace requested by "format"
@@ -72,17 +64,23 @@
    */
   /* returns TRUE if loading was successfull, FALSE otherwise */
   virtual bool open(const std::string, int format=0) = 0;
-  //////////
-  // close the movie file
-  /* close the file and clean up temporary things */
-  virtual void close(void) = 0;
 
+  /* some error codes */
+  enum errCode { SUCCESS = 0,
+                FAILURE = 1,
+                DONTKNOW= 2 };
+
   //////////
-  // do we have a film loaded ?
-  /* returns TRUE if it is possible to read frames without any more open()
+  // Change which image to display
+  /* this is the second core function of this class:
+   * most decoding-libraries can set the frame-number on a random-access basis.
+   * some cannot, then this might do nothing
+   * you could also switch between various tracks of a file (if the format 
supports it)
+   * specifying trackNum as -1 means "same track as before"
    */
-  virtual bool haveFilm(void) = 0;
+  virtual errCode changeImage(int imgNum, int trackNum=-1) = 0;
 
+
   //////////
   // get the next frame
   /* this is the core-function of this class !!!!
@@ -98,6 +96,35 @@
   virtual pixBlock* getFrame(void) = 0;
 
   //////////
+  // close the movie file
+  /* close the file and clean up temporary things */
+  virtual void close(void) = 0;
+
+
+  //////////
+  // do we have a film loaded ?
+  /* returns TRUE if it is possible to read frames without any more open()
+   */
+  virtual bool haveFilm(void) = 0;
+
+  ////////
+  // returns true if instance can be used in thread
+  virtual bool isThreadable(void) = 0;
+
+  //////////
+  // set the wanted color-space
+  /* could be used for switching the colourspace on the fly 
+   * normally the colour-space of a film could be set when opening a movie
+   */
+  virtual void requestColor(GLenum format) = 0;
+  //////////
+  // get the actual color-space
+  /* what colour-space is in use ?
+   * returns 0 for none
+   */    
+  virtual int getColor(void) = 0;
+
+  //////////
   // get the number of frames
   /* the number of frames can depend on the track
    * so this will return the framenum of the current track
@@ -112,23 +139,7 @@
   // get ysize of the frame
   virtual int getHeight(void) = 0;
 
-
   virtual void setAuto(double) = 0;
-
-  /* some error codes */
-  enum errCode { SUCCESS = 0,
-                FAILURE = 1,
-                DONTKNOW= 2 };
-
-  //////////
-  // Change which image to display
-  /* this is the second core function of this class:
-   * most decoding-libraries can set the frame-number on a random-access basis.
-   * some cannot, then this might do nothing
-   * you could also switch between various tracks of a file (if the format 
supports it)
-   * specifying trackNum as -1 means "same track as before"
-   */
-  virtual errCode changeImage(int imgNum, int trackNum=-1) = 0;
 };
 
 };}; // namespace gem::plugins

Modified: trunk/Gem/src/plugins/imageloader.h
===================================================================
--- trunk/Gem/src/plugins/imageloader.h 2011-08-08 14:32:15 UTC (rev 4439)
+++ trunk/Gem/src/plugins/imageloader.h 2011-08-08 14:32:56 UTC (rev 4440)
@@ -18,52 +18,51 @@
 
 #include <string>
 
-   /*-----------------------------------------------------------------
-     -------------------------------------------------------------------
-     CLASS
-     imageloader
+/*-----------------------------------------------------------------
+  -------------------------------------------------------------------
+  CLASS
+  imageloader
     
-     interface for the system- and library-dependent imageloader classes
+  interface for the system- and library-dependent imageloader classes
     
-     KEYWORDS
-     pix load an image
+  KEYWORDS
+  pix load an image
     
-     DESCRIPTION
+  DESCRIPTION
 
-     -----------------------------------------------------------------*/
-   namespace gem { namespace plugins {
-  class GEM_EXTERN imageloader
-  {
-  public:
+  -----------------------------------------------------------------*/
+namespace gem { namespace plugins {
+    class GEM_EXTERN imageloader
+    {
+    public:
 
-  //////////
-  // returns an instance wrapping all plugins or NULL
-  // if NULL is returned, you might still try your luck with manually 
accessing the 
-  // PluginFactory
-  static imageloader*getInstance(void);
+      //////////
+      // returns an instance wrapping all plugins or NULL
+      // if NULL is returned, you might still try your luck with manually 
accessing the 
+      // PluginFactory
+      static imageloader*getInstance(void);
 
-  /////////
-  // dtor must be virtual
-  virtual ~imageloader(void);
+      ////////
+      // dtor must be virtual
+      virtual ~imageloader(void);
 
-    /* read a image
-     *
-     * props can be filled by the loader with additional information on the 
image
-     * e.g. EXIF tags,...
-     */
-    /* returns TRUE if loading was successfull, FALSE otherwise */
-    virtual bool load(std::string filename, 
-                     imageStruct&result, 
-                     gem::Properties&props) = 0;
+      /* read a image
+       *
+       * props can be filled by the loader with additional information on the 
image
+       * e.g. EXIF tags,...
+       */
+      /* returns TRUE if loading was successfull, FALSE otherwise */
+      virtual bool load(std::string filename, 
+                       imageStruct&result, 
+                       gem::Properties&props) = 0;
 
+      /* returns TRUE if this object can be used from within a thread */
+      virtual bool isThreadable(void) = 0;
+    };
 
-    /* returns TRUE if this object can be used from within a thread */
-    virtual bool isThreadable(void) = 0;
-  };
+  };}; // namespace gem
 
-};}; // namespace gem
 
-
 /**
  * \fn REGISTER_IMAGELOADERFACTORY(const char *id, Class imageloaderClass)
  * registers a new class "imageloaderClass" with the imageloader-factory
@@ -79,7 +78,7 @@
  * initialized the factory
  * \note call this before any externals register themselves
  */
-#define INIT_IMAGELOADERFACTORY()                                         \
+#define INIT_IMAGELOADERFACTORY()                                      \
   static gem::PluginFactoryRegistrar::dummy<gem::plugins::imageloader> 
fac_imageloaderdummy
 
 

Modified: trunk/Gem/src/plugins/imagesaver.h
===================================================================
--- trunk/Gem/src/plugins/imagesaver.h  2011-08-08 14:32:15 UTC (rev 4439)
+++ trunk/Gem/src/plugins/imagesaver.h  2011-08-08 14:32:56 UTC (rev 4440)
@@ -19,99 +19,99 @@
 #include <string>
 
 
-   /*-----------------------------------------------------------------
-     -------------------------------------------------------------------
-     CLASS
-     imagesaver
+/*-----------------------------------------------------------------
+  -------------------------------------------------------------------
+  CLASS
+  imagesaver
     
-     interface for the system- and library-dependent imagesaver classes
+  interface for the system- and library-dependent imagesaver classes
     
-     KEYWORDS
-     save a pix to disk
+  KEYWORDS
+  save a pix to disk
     
-     DESCRIPTION
+  DESCRIPTION
 
-     -----------------------------------------------------------------*/
-   namespace gem { namespace plugins {
-  class GEM_EXTERN imagesaver
-  {
-  public:
+  -----------------------------------------------------------------*/
+namespace gem { namespace plugins {
+    class GEM_EXTERN imagesaver
+    {
+    public:
 
-  //////////
-  // returns an instance wrapping all plugins or NULL
-  // if NULL is returned, you might still try your luck with manually 
accessing the 
-  // PluginFactory
-  static imagesaver*getInstance(void);
+      //////////
+      // returns an instance wrapping all plugins or NULL
+      // if NULL is returned, you might still try your luck with manually 
accessing the 
+      // PluginFactory
+      static imagesaver*getInstance(void);
 
-  /////////
-  // dtor must be virtual
-  virtual ~imagesaver(void);
+      ////////
+      // dtor must be virtual
+      virtual ~imagesaver(void);
 
-    /* save the image 'img' under the filename 'filename', respecting as many 
'props' as possible
-     *
-     * returns TRUE if saving was successfull, FALSE otherwise */
-    virtual bool save(const imageStruct&img, const std::string&filename, const 
std::string&mimetype, const gem::Properties&props) = 0;
+      /* save the image 'img' under the filename 'filename', respecting as 
many 'props' as possible
+       *
+       * returns TRUE if saving was successfull, FALSE otherwise */
+      virtual bool save(const imageStruct&img, const std::string&filename, 
const std::string&mimetype, const gem::Properties&props) = 0;
 
-    /* estimate how 'well' we could save the 'img'
-     *  this is used to rate the different backends for a given image
-     *
-     *  e.g. if the user requests saving of an image as <filename>, virtually 
all backends will have a way to to as requested
-     *        however, if filename was "bla.jpg", a TIFF-backend might save as 
a TIFF-image with a .jpg extension, 
-     *        which is probably not what the user expected (esp. if there _is_ 
a JPEG-backend, which for whatever reasons 
-     *        would only have been called after the TIFF-backend)
-     *
-     * the solution is quite simple: each backend is first asked, how well it 
could save a given image according to properties
-     *  the backend that returns the highest value, will be chosen first; if 
it fails to save the image 
-     *  (returning FALSE in the save() function), the backend with the next 
higher rating will be chosen and so on
-     *
-     * 
-     * mimetype and properties are the main factors for rating; 
-     *                'mimetype' (string): mimetype of the image; e.g. 
'image/jpeg' means 'write the image as JPEG'
-     *                                     if not empty, the mimetype will 
override all other ways to set the output format (like filename)
-     *                                     even though we only expect 
mimetypes of type 'image/*', the prefix ('image/') is mandatory
-     * a predefined properties (for legacy reasons) is:
-     *                'quality'  (float) : for lossy formats, this is the 
quality (in percent)
-     *
-     * expected return values:
-     *     <=0: 'USE ME IF YOU MUST (but rather not)'
-     *          0 is returned, if the backend expects to be able to save the 
given image under the given 
-     *          filename to disk, but it will ignore all properties (including 
the mimetype!) and will 
-     *          ignore all file extensions
-     *          it is hoped that '0' is never the winner (for any feasible 
format)
-     *         example: saves a TIFF-image as /tmp/foo.doc
-     *     100: 'YES'
-     *          100 is returned, if the plugin knows how to handle the given 
'mimetype' property
-     *          if 'mimetype' is empty and the plugin has performed an 
heuristic based on the filename
-     *          to determine that the user wants a format that is provided by 
this very plugin, it can return 100 as well.
-     *          however, if 'mimetype' and file extension contradict each 
other, 'mimetype' wins!
-     *     100+: 'YES, ABSOLUTELY'
-     *          every additional property that can be applied, gains an extra 
point
-     *         example: both the JPG and the JPEG2K backend provide saving of 
jpegs, but only JPG can set the quality
-     *            the user requests: 
filename=img.jpg,mimetype='image/jpeg',quality=20 
-     *            JPG returns 101, whereas JPEG2K returns 100, so JPG wins and 
writes
-     *    0..50: the backend knows how to handle some of the properties (but 
it has no clue about the output format requested
-     *         example: filename=img.tif,mimetype='image/tiff',quality=20 
-     *            JPG knows how to handle the 'quality' property, but not the 
'mimetype', so it scores 1 point
-     *            TIFF knows how to handle the 'mimetype' but not the 
'quality', so it scores 100 points
-     */
-    virtual float estimateSave( const imageStruct&img, const 
std::string&filename, const std::string&mimetype, const gem::Properties&props) 
= 0;
+      /* estimate how 'well' we could save the 'img'
+       *  this is used to rate the different backends for a given image
+       *
+       *  e.g. if the user requests saving of an image as <filename>, 
virtually all backends will have a way to to as requested
+       *        however, if filename was "bla.jpg", a TIFF-backend might save 
as a TIFF-image with a .jpg extension, 
+       *        which is probably not what the user expected (esp. if there 
_is_ a JPEG-backend, which for whatever reasons 
+       *        would only have been called after the TIFF-backend)
+       *
+       * the solution is quite simple: each backend is first asked, how well 
it could save a given image according to properties
+       *  the backend that returns the highest value, will be chosen first; if 
it fails to save the image 
+       *  (returning FALSE in the save() function), the backend with the next 
higher rating will be chosen and so on
+       *
+       * 
+       * mimetype and properties are the main factors for rating; 
+       *                'mimetype' (string): mimetype of the image; e.g. 
'image/jpeg' means 'write the image as JPEG'
+       *                                     if not empty, the mimetype will 
override all other ways to set the output format (like filename)
+       *                                     even though we only expect 
mimetypes of type 'image/*', the prefix ('image/') is mandatory
+       * a predefined properties (for legacy reasons) is:
+       *                'quality'  (float) : for lossy formats, this is the 
quality (in percent)
+       *
+       * expected return values:
+       *     <=0: 'USE ME IF YOU MUST (but rather not)'
+       *          0 is returned, if the backend expects to be able to save the 
given image under the given 
+       *          filename to disk, but it will ignore all properties 
(including the mimetype!) and will 
+       *          ignore all file extensions
+       *          it is hoped that '0' is never the winner (for any feasible 
format)
+       *         example: saves a TIFF-image as /tmp/foo.doc
+       *     100: 'YES'
+       *          100 is returned, if the plugin knows how to handle the given 
'mimetype' property
+       *          if 'mimetype' is empty and the plugin has performed an 
heuristic based on the filename
+       *          to determine that the user wants a format that is provided 
by this very plugin, it can return 100 as well.
+       *          however, if 'mimetype' and file extension contradict each 
other, 'mimetype' wins!
+       *     100+: 'YES, ABSOLUTELY'
+       *          every additional property that can be applied, gains an 
extra point
+       *         example: both the JPG and the JPEG2K backend provide saving 
of jpegs, but only JPG can set the quality
+       *            the user requests: 
filename=img.jpg,mimetype='image/jpeg',quality=20 
+       *            JPG returns 101, whereas JPEG2K returns 100, so JPG wins 
and writes
+       *    0..50: the backend knows how to handle some of the properties (but 
it has no clue about the output format requested
+       *         example: filename=img.tif,mimetype='image/tiff',quality=20 
+       *            JPG knows how to handle the 'quality' property, but not 
the 'mimetype', so it scores 1 point
+       *            TIFF knows how to handle the 'mimetype' but not the 
'quality', so it scores 100 points
+       */
+      virtual float estimateSave( const imageStruct&img, const 
std::string&filename, const std::string&mimetype, const gem::Properties&props) 
= 0;
     
-    /**
-     * get writing capabilities of this backend (informative)
-     * 
-     * list all (known) mimetypes and properties this backend supports for 
writing
-     *  both can be empty, if they are not known when requested
-     * if only some properties/mimetypes are explicitely known (but it is 
likely that more are supported), 
-     * it is generally better, to list the few rather than nothing
-     */
-    virtual void getWriteCapabilities(std::vector<std::string>&mimetypes, 
gem::Properties&props) = 0;
+      /**
+       * get writing capabilities of this backend (informative)
+       * 
+       * list all (known) mimetypes and properties this backend supports for 
writing
+       *  both can be empty, if they are not known when requested
+       * if only some properties/mimetypes are explicitely known (but it is 
likely that more are supported), 
+       * it is generally better, to list the few rather than nothing
+       */
+      virtual void getWriteCapabilities(std::vector<std::string>&mimetypes, 
gem::Properties&props) = 0;
     
-    /* returns TRUE, if it is save to use this backend from multple threads
-     */
-    virtual bool isThreadable(void) = 0;
-  };
+      /* returns TRUE, if it is save to use this backend from multple threads
+       */
+      virtual bool isThreadable(void) = 0;
+    };
 
-}; }; // namespace gem
+  }; }; // namespace gem
 
 
 /**
@@ -129,7 +129,7 @@
  * initialized the factory
  * \note call this before any externals register themselves
  */
-#define INIT_IMAGESAVERFACTORY()                                         \
+#define INIT_IMAGESAVERFACTORY()                                       \
   static gem::PluginFactoryRegistrar::dummy<gem::plugins::imagesaver> 
fac_imagesaverdummy
 
 

Modified: trunk/Gem/src/plugins/record.cpp
===================================================================
--- trunk/Gem/src/plugins/record.cpp    2011-08-08 14:32:15 UTC (rev 4439)
+++ trunk/Gem/src/plugins/record.cpp    2011-08-08 14:32:56 UTC (rev 4440)
@@ -17,6 +17,8 @@
 #include "plugins/record.h"
 #include "plugins/PluginFactory.h"
 
+gem::plugins::record :: ~record(void) {}
+
 gem::plugins::record*gem::plugins::record::getInstance(void) {
   return NULL;
 }

Modified: trunk/Gem/src/plugins/record.h
===================================================================
--- trunk/Gem/src/plugins/record.h      2011-08-08 14:32:15 UTC (rev 4439)
+++ trunk/Gem/src/plugins/record.h      2011-08-08 14:32:56 UTC (rev 4440)
@@ -36,20 +36,16 @@
  class GEM_EXTERN record
 {
 public:
-  //////////
-  // start recording
-  /* 
-   * returns TRUE if opening was successfull, FALSE otherwise 
-   */
-  virtual bool start(const std::string filename, gem::Properties&props) = 0;
 
   //////////
-  // stop recording
-  virtual void stop (void) = 0;
+  // returns an instance wrapping all plugins or NULL
+  // if NULL is returned, you might still try your luck with manually 
accessing the 
+  // PluginFactory
+  static record*getInstance(void);
 
-  //////////
-  // record a frame 
-  virtual bool write(imageStruct*) = 0;
+  /////////
+  // dtor must be virtual
+  virtual ~record(void);
 
   /**
    * get a list of supported codecs (short-form names, e.g. "mjpa")
@@ -72,14 +68,24 @@
 
   //////////
   // popup a dialog to set the codec interactively (interesting on os-x and 
w32)
+  // just return FALSE if you don't support dialogs
   virtual bool dialog(void) = 0;
 
+  //////////
+  // start recording
+  /* 
+   * returns TRUE if opening was successfull, FALSE otherwise 
+   */
+  virtual bool start(const std::string filename, gem::Properties&props) = 0;
 
   //////////
-  // returns an instance wrapping all plugins or NULL
-  // if NULL is returned, you might still try your luck with manually 
accessing the 
-  // PluginFactory
-  static record*getInstance(void);
+  // record a frame 
+  virtual bool write(imageStruct*) = 0;
+
+  //////////
+  // stop recording
+  virtual void stop (void) = 0;
+
  };
 }; };
 

Modified: trunk/Gem/src/plugins/video.cpp
===================================================================
--- trunk/Gem/src/plugins/video.cpp     2011-08-08 14:32:15 UTC (rev 4439)
+++ trunk/Gem/src/plugins/video.cpp     2011-08-08 14:32:56 UTC (rev 4440)
@@ -15,6 +15,8 @@
 #include "plugins/video.h"
 #include "plugins/PluginFactory.h"
 
+gem::plugins::video :: ~video(void) {}
+
 gem::plugins::video*gem::plugins::video::getInstance(void) {
  return NULL;
 }

Modified: trunk/Gem/src/plugins/video.h
===================================================================
--- trunk/Gem/src/plugins/video.h       2011-08-08 14:32:15 UTC (rev 4439)
+++ trunk/Gem/src/plugins/video.h       2011-08-08 14:32:56 UTC (rev 4440)
@@ -20,174 +20,189 @@
 /*-----------------------------------------------------------------
   -------------------------------------------------------------------
   CLASS
-       video
+  video
     
-       a OS-indendent interface for grabbing video-frames
+  a OS-indendent interface for grabbing video-frames
        
   KEYWORDS
-       pix, capture
+  pix, capture
     
   -----------------------------------------------------------------*/
 class pixBlock;
 namespace gem { namespace plugins {
- class GEM_EXTERN video {
-  public:
-    /**
-     * returns TRUE if the object can be used in a thread or FALSE otherwise
-     * if a backend implements threading itself, it should return FALSE
-     * in order to prevent double threading
-     */
-    virtual bool isThreadable(void) = 0;
+    class GEM_EXTERN video {
+    public:
 
-    /**
-     * reset the backend, possibly re-enumerating devices
-     * returns TRUE if reset was successfull
-     */
-    virtual bool          reset(void) = 0;
+      //////////
+      // returns an instance wrapping all plugins or NULL
+      // if NULL is returned, you might still try your luck with manually 
accessing the 
+      // PluginFactory
+      static video*getInstance(void);
 
-    /** 
-     * get the next frame (called when rendering)
-     * grab the next frame from the device
-     * if no new frame is available, this should set the "newimage" flag to 
false
-     * \return the new frame or NULL on error
-     */
-    virtual pixBlock *getFrame(void) = 0;
+      ////////
+      // dtor must be virtual
+      virtual ~video(void);
 
-    /**
-     * release a frame (after use)
-     * this gets called once for each frame retrieved via getFrame()
-     * if you are using DMA or the like, now is the time to release the 
ressource
-     */
-    virtual void releaseFrame(void) = 0;
+      //////////////////////
+      // device settings
 
+      /**
+       * enumerate known devices
+       * \return a list of device names (if they can be enumerated)
+       */
+      virtual std::vector<std::string>enumerate(void) = 0;
 
-    /** turn on/off "asynchronous"-grabbing
-     * default is "true"
-     * "asynchronous" means, that the device is constantly grabbing, and 
grabFrame() returns the current frame
-     * non-"continous" means, that the device will only issue a new grab when 
a frame has read
-     *   (thus potentially reducing the CPU-load to what is needed, at the 
cost of slightly outdated images
-     * returns: the old state
-     */
-    virtual bool grabAsynchronous(bool) = 0;
+      /**
+       * set the device to be opened next time
+       * the ID provided should match an index in the list returned by 
enumerate()
+       * after the device has been set, the caller(!) has to restart 
+       * (close() the current handle, try open() with the new settings)
+       * the default implementation (which you normally shouldn't need to 
override)
+       * will simply set m_devicenum and clear m_devicename
+       */
+      virtual bool             setDevice(int ID) = 0;
 
-    //////////////////////
-    // device settings
+      /**
+       * set the device to be opened next time
+       * the list returned by enumerate() provides a set of valid names to use 
here
+       * depending on the backend, other names might be possible as well (e.g. 
IP-cameras)
+       * after the device has been set, the caller(!) has to restart 
+       * (close() the current handle, try open() with the new settings)
+       * the default implementation (which you normally shouldn't need to 
override)
+       * will simply set m_devicename and clear m_devicenum
+       */
+      virtual bool             setDevice(const std::string) = 0;
 
-    /**
-     * enumerate known devices
-     * \return a list of device names (if they can be enumerated)
-     */
-    virtual std::vector<std::string>enumerate(void) = 0;
 
-    /**
-     * set the device to be opened next time
-     * the ID provided should match an index in the list returned by 
enumerate()
-     * after the device has been set, the caller(!) has to restart 
-     * (close() the current handle, try open() with the new settings)
-     * the default implementation (which you normally shouldn't need to 
override)
-     * will simply set m_devicenum and clear m_devicename
-     */
-    virtual bool               setDevice(int ID) = 0;
+      //! open the device (calls openDevice())
+      virtual bool open(gem::Properties&props) = 0;
+      //! start the transmission (calls startTransfer())
+      virtual bool start(void) = 0;
 
-    /**
-     * set the device to be opened next time
-     * the list returned by enumerate() provides a set of valid names to use 
here
-     * depending on the backend, other names might be possible as well (e.g. 
IP-cameras)
-     * after the device has been set, the caller(!) has to restart 
-     * (close() the current handle, try open() with the new settings)
-     * the default implementation (which you normally shouldn't need to 
override)
-     * will simply set m_devicename and clear m_devicenum
-     */
-    virtual bool               setDevice(const std::string) = 0;
+      /** 
+       * get the next frame (called when rendering)
+       * grab the next frame from the device
+       * if no new frame is available, this should set the "newimage" flag to 
false
+       * \return the new frame or NULL on error
+       */
+      virtual pixBlock *getFrame(void) = 0;
 
-    /**
-     * list all properties the currently opened device supports
-     * after calling, "readable" will hold a list of all properties that can 
be read
-     * and "writeable" will hold a list of all properties that can be set
-     * if the enumeration fails, this returns <code>false</code>
-     *
-     * the backend has to provide the names for the properties
-     *  these are defined by default, and need not be enumerated!
-     *    "width"            "dimen" message   (float)
-     *    "height"           "dimen" message   (float)
-     *       "leftmargin"   ("dimen" message)  (float)
-     *       "rightmargin"  ("dimen" message)  (float)
-     *       "toptmargin"   ("dimen" message)  (float)
-     *       "bottommargin" ("dimen" message)  (float)
-     *    "channel"          "channel" message (float)
-     *    "frequency"        "channel" message (float)
-     *    "norm"             "norm" message    (string)
-     *    "quality"          "quality" message (float)
-     */
-    virtual bool enumProperties(gem::Properties&readable,
-                               gem::Properties&writeable) = 0;
+      /**
+       * release a frame (after use)
+       * this gets called once for each frame retrieved via getFrame()
+       * if you are using DMA or the like, now is the time to release the 
ressource
+       */
+      virtual void releaseFrame(void) = 0;
 
-    /**
-     * set a number of properties (as defined by "props")
-     * the "props" may hold properties not supported by the currently opened 
device,
-     *  which is legal; in this case the superfluous properties are simply 
ignored
-     * this function MAY modify the props; 
-     * namely one-shot properties (e.g. "do-white-balance-now") 
-     *     should be removed from the props
-     */
-    virtual void setProperties(gem::Properties&props) = 0;
 
-    /**
-     * get the current value of the given properties from the device
-     * if props holds properties that can not be read from the device, they 
are set to UNSET 
-     */
-    virtual void getProperties(gem::Properties&props) = 0;
+      //! stop the transmission (calls stopTransfer())
+      virtual bool stop(void) = 0;
+      //! close the device (calls closeDevice())
+      virtual void close(void) = 0;
 
+      /**
+       * reset the backend, possibly re-enumerating devices
+       * returns TRUE if reset was successfull
+       */
+      virtual bool          reset(void) = 0;
 
-    /**
-     * call a system-specific configuration dialog
-     * if your system provides a GUI for configuring the device, here is the 
time to open it
-     * of several dialogs are available (for different properties), the user 
can specify which one
-     * they want with the string list
-     * if the list is empty, provide sane defaults (e.g. ALL dialogs)
-     * if the system does not support dialogs, return FALSE
-     * if the system does support dialogs and the user has specified which one 
they want, 
-     * return TRUE if at least one dialog could be handled
-     */
-    virtual bool               
dialog(std::vector<std::string>names=std::vector<std::string>()) = 0;
-    /**
-     * enumerate list of possible dialogs (if any)
-     */
-    virtual std::vector<std::string>dialogs(void) = 0;
 
-    /**
-     * Set the preferred colorspace (of the frames returned by getFrame()
-     * \return FALSE if the colorspace cannot be set (e.g. while grabbing is 
active)
-     */
-    virtual bool               setColor(int) = 0;
+      /**
+       * list all properties the currently opened device supports
+       * after calling, "readable" will hold a list of all properties that can 
be read
+       * and "writeable" will hold a list of all properties that can be set
+       * if the enumeration fails, this returns <code>false</code>
+       *
+       * the backend has to provide the names for the properties
+       *  these are defined by default, and need not be enumerated!
+       *    "width"            "dimen" message   (float)
+       *    "height"           "dimen" message   (float)
+       *       "leftmargin"   ("dimen" message)  (float)
+       *       "rightmargin"  ("dimen" message)  (float)
+       *       "toptmargin"   ("dimen" message)  (float)
+       *       "bottommargin" ("dimen" message)  (float)
+       *    "channel"          "channel" message (float)
+       *    "frequency"        "channel" message (float)
+       *    "norm"             "norm" message    (string)
+       *    "quality"          "quality" message (float)
+       */
+      virtual bool enumProperties(gem::Properties&readable,
+                                 gem::Properties&writeable) = 0;
+
+      /**
+       * set a number of properties (as defined by "props")
+       * the "props" may hold properties not supported by the currently opened 
device,
+       *  which is legal; in this case the superfluous properties are simply 
ignored
+       * this function MAY modify the props; 
+       * namely one-shot properties (e.g. "do-white-balance-now") 
+       *     should be removed from the props
+       */
+      virtual void setProperties(gem::Properties&props) = 0;
+
+      /**
+       * get the current value of the given properties from the device
+       * if props holds properties that can not be read from the device, they 
are set to UNSET 
+       */
+      virtual void getProperties(gem::Properties&props) = 0;
+
+
+      /**
+       * call a system-specific configuration dialog
+       * if your system provides a GUI for configuring the device, here is the 
time to open it
+       * of several dialogs are available (for different properties), the user 
can specify which one
+       * they want with the string list
+       * if the list is empty, provide sane defaults (e.g. ALL dialogs)
+       * if the system does not support dialogs, return FALSE
+       * if the system does support dialogs and the user has specified which 
one they want, 
+       * return TRUE if at least one dialog could be handled
+       */
+      virtual bool             
dialog(std::vector<std::string>names=std::vector<std::string>()) = 0;
+      /**
+       * enumerate list of possible dialogs (if any)
+       */
+      virtual std::vector<std::string>dialogs(void) = 0;
+
+
+
+
+
+      /**
+       * returns TRUE if the object can be used in a thread or FALSE otherwise
+       * if a backend implements threading itself, it should return FALSE
+       * in order to prevent double threading
+       */
+      virtual bool isThreadable(void) = 0;
+
+
+      /** turn on/off "asynchronous"-grabbing
+       * default is "true"
+       * "asynchronous" means, that the device is constantly grabbing, and 
grabFrame() returns the current frame
+       * non-"continous" means, that the device will only issue a new grab 
when a frame has read
+       *   (thus potentially reducing the CPU-load to what is needed, at the 
cost of slightly outdated images
+       * returns: the old state
+       */
+      virtual bool grabAsynchronous(bool) = 0;
+
+      /**
+       * Set the preferred colorspace (of the frames returned by getFrame()
+       * \return FALSE if the colorspace cannot be set (e.g. while grabbing is 
active)
+       */
+      virtual bool setColor(int) = 0;
   
-    //! open the device (calls openDevice())
-    virtual bool open(gem::Properties&props) = 0;
-    //! close the device (calls closeDevice())
-    virtual void close(void) = 0;
-    //! start the transmission (calls startTransfer())
-    virtual bool start(void) = 0;
-    //! stop the transmission (calls stopTransfer())
-    virtual bool stop(void) = 0;
 
-    // for pix_video: query whether this backend provides access to this class 
of devices
-    // (e.g. "dv")
-    virtual bool provides(const std::string) = 0;
-    // get a list of all provided devices
-    virtual std::vector<std::string>provides(void) = 0;
+      // meta information about the plugin
 
-    // get's the name of the backend (e.g. "v4l")
-    virtual const std::string getName(void) = 0;
+      // for pix_video: query whether this backend provides access to this 
class of devices
+      // (e.g. "dv")
+      virtual bool provides(const std::string) = 0;
+      // get a list of all provided devices
+      virtual std::vector<std::string>provides(void) = 0;
 
+      // get's the name of the backend (e.g. "v4l")
+      virtual const std::string getName(void) = 0;
+    };
+  };}; // namespace
 
-  //////////
-  // returns an instance wrapping all plugins or NULL
-  // if NULL is returned, you might still try your luck with manually 
accessing the 
-  // PluginFactory
-    static video*getInstance(void);
-};
-};}; // namespace
-
 /* 
  * factory code:
  * to use these macros, you have to include "plugins/PluginFactory.h"


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts. 
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________
pd-gem-CVS mailing list
pd-gem-CVS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pd-gem-cvs

Reply via email to