home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2002 April / pcpro0402.iso / essentials / graphics / Gimp / gimp-src-20001226.exe / src / gimp / app / procedural_db.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-12-17  |  5.6 KB  |  203 lines

  1. /* The GIMP -- an image manipulation program
  2.  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3.  *
  4.  * This program is free software; you can redistribute it and/or modify
  5.  * it under the terms of the GNU General Public License as published by
  6.  * the Free Software Foundation; either version 2 of the License, or
  7.  * (at your option) any later version.
  8.  *
  9.  * This program is distributed in the hope that it will be useful,
  10.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.  * GNU General Public License for more details.
  13.  *
  14.  * You should have received a copy of the GNU General Public License
  15.  * along with this program; if not, write to the Free Software
  16.  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17.  */
  18. #ifndef __PROCEDURAL_DB_H__
  19. #define __PROCEDURAL_DB_H__
  20.  
  21. #include <glib.h>
  22.  
  23. #include "apptypes.h"
  24.  
  25. /*  Procedural database types  */
  26. typedef enum
  27. {
  28.   PDB_INT32,
  29.   PDB_INT16,
  30.   PDB_INT8,
  31.   PDB_FLOAT,
  32.   PDB_STRING,
  33.   PDB_INT32ARRAY,
  34.   PDB_INT16ARRAY,
  35.   PDB_INT8ARRAY,
  36.   PDB_FLOATARRAY,
  37.   PDB_STRINGARRAY,
  38.   PDB_COLOR,
  39.   PDB_REGION,
  40.   PDB_DISPLAY,
  41.   PDB_IMAGE,
  42.   PDB_LAYER,
  43.   PDB_CHANNEL,
  44.   PDB_DRAWABLE,
  45.   PDB_SELECTION,
  46.   PDB_BOUNDARY,
  47.   PDB_PATH,
  48.   PDB_PARASITE,
  49.   PDB_STATUS,
  50.   PDB_END
  51. } PDBArgType;
  52.  
  53. /*  Error types  */
  54. typedef enum
  55. {
  56.   PDB_EXECUTION_ERROR,
  57.   PDB_CALLING_ERROR,
  58.   PDB_PASS_THROUGH,
  59.   PDB_SUCCESS,
  60.   PDB_CANCEL
  61. } PDBStatusType;
  62.  
  63.  
  64. /*  Procedure types  */
  65. typedef enum /*< chop=PDB_ >*/
  66. {
  67.   PDB_INTERNAL,
  68.   PDB_PLUGIN,
  69.   PDB_EXTENSION,
  70.   PDB_TEMPORARY
  71. } PDBProcType;
  72.  
  73.  
  74. /*  Argument type  */
  75. typedef struct _Argument Argument;
  76.  
  77. struct _Argument
  78. {
  79.   PDBArgType    arg_type;       /*  argument type  */
  80.  
  81.   union _ArgValue
  82.   {
  83.     gint32      pdb_int;        /*  Integer type  */
  84.     gdouble     pdb_float;      /*  Floating point type  */
  85.     gpointer    pdb_pointer;    /*  Pointer type  */
  86.   } value;
  87. };
  88.  
  89.  
  90. /*  Argument marshalling procedures  */
  91. typedef Argument * (* ArgMarshal) (Argument *);
  92.  
  93.  
  94. /*  Execution types  */
  95. typedef struct _IntExec    IntExec;
  96. typedef struct _PlugInExec PlugInExec;
  97. typedef struct _ExtExec    ExtExec;
  98. typedef struct _TempExec   TempExec;
  99. typedef struct _NetExec    NetExec;
  100.  
  101. struct _IntExec
  102. {
  103.   ArgMarshal  marshal_func;   /*  Function called to marshal arguments  */
  104. };
  105.  
  106. struct _PlugInExec
  107. {
  108.   gchar      *filename;       /*  Where is the executable on disk?  */
  109. };
  110.  
  111. struct _ExtExec
  112. {
  113.   gchar      *filename;       /*  Where is the executable on disk?  */
  114. };
  115.  
  116. struct _TempExec
  117. {
  118.   void       *plug_in;        /*  Plug-in that registered this temp proc  */
  119. };
  120.  
  121. struct _NetExec
  122. {
  123.   gchar      *host;           /*  Host responsible for procedure execution  */
  124.   gint32      port;           /*  Port on host to send data to  */
  125. };
  126.  
  127.  
  128. /*  Structure for a procedure argument  */
  129. typedef struct _ProcArg ProcArg;
  130.  
  131. struct _ProcArg
  132. {
  133.   PDBArgType  arg_type;       /*  Argument type (int, char, char *, etc)  */
  134.   gchar      *name;           /*  Argument name  */
  135.   gchar      *description;    /*  Argument description  */
  136. };
  137.  
  138.  
  139. /*  Structure for a procedure  */
  140.  
  141. typedef struct _ProcRecord ProcRecord;
  142.  
  143. struct _ProcRecord
  144. {
  145.   /*  Procedure information  */
  146.   gchar       *name;          /*  Procedure name  */
  147.   gchar       *blurb;         /*  Short procedure description  */
  148.   gchar       *help;          /*  Detailed help instructions  */
  149.   gchar       *author;        /*  Author field  */
  150.   gchar       *copyright;     /*  Copyright field  */
  151.   gchar       *date;          /*  Date field  */
  152.  
  153.   /*  Procedure type  */
  154.   PDBProcType  proc_type;     /*  Type of procedure--Internal, Plug-In, Extension  */
  155.  
  156.   /*  Input arguments  */
  157.   gint32       num_args;      /*  Number of procedure arguments  */
  158.   ProcArg     *args;          /*  Array of procedure arguments  */
  159.  
  160.   /*  Output values  */
  161.   gint32       num_values;    /*  Number of return values  */
  162.   ProcArg     *values;        /*  Array of return values  */
  163.  
  164.   /*  Method of procedure execution  */
  165.   union _ExecMethod
  166.   {
  167.     IntExec     internal;     /*  Execution information for internal procs  */
  168.     PlugInExec  plug_in;      /*  ..................... for plug-ins  */
  169.     ExtExec     extension;    /*  ..................... for extensions  */
  170.     TempExec    temporary;    /*  ..................... for temp procs  */
  171.   } exec_method;
  172. };
  173.  
  174. /*  Variables  */
  175. extern GHashTable *procedural_ht;
  176.  
  177. /*  Functions  */
  178. void          procedural_db_init         (void);
  179. void          procedural_db_free         (void);
  180. void          procedural_db_register     (ProcRecord *procedure);
  181. void          procedural_db_unregister   (gchar      *name);
  182. ProcRecord  * procedural_db_lookup       (gchar      *name);
  183. Argument    * procedural_db_execute      (gchar      *name,
  184.                       Argument   *args);
  185. Argument    * procedural_db_run_proc     (gchar      *name,
  186.                       gint       *nreturn_vals,
  187.                       ...);
  188. Argument    * procedural_db_return_args  (ProcRecord *procedure,
  189.                       gboolean    success);
  190. void          procedural_db_destroy_args (Argument   *args,
  191.                       gint        nargs);
  192. void          pdb_add_image              (GimpImage  *gimage);
  193. gint          pdb_image_to_id            (GimpImage  *gimage);
  194. GimpImage   * pdb_id_to_image            (gint        id);
  195. void          pdb_remove_image           (GimpImage  *image);
  196.  
  197. /* "type" should really be a PDBArgType, but we can cope with
  198.  *  out-of-range values.
  199.  */
  200. const gchar * pdb_type_name (gint type); /* really exists in _cmds.c file */
  201.  
  202. #endif  /*  __PROCEDURAL_DB_H__  */
  203.