object.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651
  1. /* abstract base class for all vips objects
  2. */
  3. /*
  4. Copyright (C) 1991-2003 The National Gallery
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. This library 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 GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with this library; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  16. 02110-1301 USA
  17. */
  18. /*
  19. These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
  20. */
  21. #ifndef VIPS_OBJECT_H
  22. #define VIPS_OBJECT_H
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif /*__cplusplus*/
  26. /* Handy!
  27. */
  28. #ifdef VIPS_DEBUG
  29. #define VIPS_UNREF( X ) G_STMT_START { \
  30. if( X ) { \
  31. g_assert( G_OBJECT( X )->ref_count > 0 ); \
  32. g_object_unref( X ); \
  33. (X) = 0; \
  34. } \
  35. } G_STMT_END
  36. #else /*!VIPS_DEBUG*/
  37. #define VIPS_UNREF( X ) VIPS_FREEF( g_object_unref, (X) )
  38. #endif /*VIPS_DEBUG*/
  39. typedef struct _VipsObject VipsObject;
  40. typedef struct _VipsObjectClass VipsObjectClass;
  41. /* Track extra stuff for arguments to objects
  42. */
  43. typedef enum /*< flags >*/ {
  44. VIPS_ARGUMENT_NONE = 0,
  45. VIPS_ARGUMENT_REQUIRED = 1,
  46. VIPS_ARGUMENT_CONSTRUCT = 2,
  47. VIPS_ARGUMENT_SET_ONCE = 4,
  48. VIPS_ARGUMENT_SET_ALWAYS = 8,
  49. VIPS_ARGUMENT_INPUT = 16,
  50. VIPS_ARGUMENT_OUTPUT = 32,
  51. VIPS_ARGUMENT_DEPRECATED = 64,
  52. VIPS_ARGUMENT_MODIFY = 128
  53. } VipsArgumentFlags;
  54. /* Useful flag combinations. User-visible ones are:
  55. VIPS_ARGUMENT_REQUIRED_INPUT Eg. the "left" argument for an add operation
  56. VIPS_ARGUMENT_OPTIONAL_INPUT Eg. the "caption" for an object
  57. VIPS_ARGUMENT_REQUIRED_OUTPUT Eg. the "result" of an add operation
  58. VIPS_ARGUMENT_OPTIONAL_OUTPUT Eg. the x pos of the image minimum
  59. Other combinations are used internally, eg. supplying the cast-table for an
  60. arithmetic operation
  61. */
  62. #define VIPS_ARGUMENT_REQUIRED_INPUT \
  63. (VIPS_ARGUMENT_INPUT | \
  64. VIPS_ARGUMENT_REQUIRED | \
  65. VIPS_ARGUMENT_CONSTRUCT)
  66. #define VIPS_ARGUMENT_OPTIONAL_INPUT \
  67. (VIPS_ARGUMENT_INPUT | \
  68. VIPS_ARGUMENT_CONSTRUCT)
  69. #define VIPS_ARGUMENT_REQUIRED_OUTPUT \
  70. (VIPS_ARGUMENT_OUTPUT | \
  71. VIPS_ARGUMENT_REQUIRED | \
  72. VIPS_ARGUMENT_CONSTRUCT)
  73. #define VIPS_ARGUMENT_OPTIONAL_OUTPUT \
  74. (VIPS_ARGUMENT_OUTPUT | \
  75. VIPS_ARGUMENT_CONSTRUCT)
  76. #define VIPS_ARG_IMAGE( CLASS, NAME, PRIORITY, LONG, DESC, FLAGS, OFFSET ) { \
  77. GParamSpec *pspec; \
  78. \
  79. pspec = g_param_spec_object( (NAME), (LONG), (DESC), \
  80. VIPS_TYPE_IMAGE, \
  81. (GParamFlags) (G_PARAM_READWRITE) ); \
  82. g_object_class_install_property( G_OBJECT_CLASS( CLASS ), \
  83. vips_argument_get_id(), pspec ); \
  84. vips_object_class_install_argument( VIPS_OBJECT_CLASS( CLASS ), \
  85. pspec, (VipsArgumentFlags) (FLAGS), (PRIORITY), (OFFSET) ); \
  86. }
  87. #define VIPS_ARG_OBJECT( CLASS, NAME, PRIORITY, LONG, DESC, FLAGS, OFFSET, TYPE ) { \
  88. GParamSpec *pspec; \
  89. \
  90. pspec = g_param_spec_object( (NAME), (LONG), (DESC), \
  91. TYPE, \
  92. (GParamFlags) (G_PARAM_READWRITE) ); \
  93. g_object_class_install_property( G_OBJECT_CLASS( CLASS ), \
  94. vips_argument_get_id(), pspec ); \
  95. vips_object_class_install_argument( VIPS_OBJECT_CLASS( CLASS ), \
  96. pspec, (VipsArgumentFlags) (FLAGS), (PRIORITY), (OFFSET) ); \
  97. }
  98. #define VIPS_ARG_INTERPOLATE( CLASS, NAME, PRIORITY, LONG, DESC, FLAGS, OFFSET ) \
  99. VIPS_ARG_OBJECT( CLASS, NAME, PRIORITY, LONG, DESC, FLAGS, OFFSET, VIPS_TYPE_INTERPOLATE )
  100. #define VIPS_ARG_BOOL( CLASS, NAME, PRIORITY, LONG, DESC, \
  101. FLAGS, OFFSET, VALUE ) { \
  102. GParamSpec *pspec; \
  103. \
  104. pspec = g_param_spec_boolean( (NAME), (LONG), (DESC), \
  105. (VALUE), \
  106. (GParamFlags) (G_PARAM_READWRITE) ); \
  107. g_object_class_install_property( G_OBJECT_CLASS( CLASS ), \
  108. vips_argument_get_id(), pspec ); \
  109. vips_object_class_install_argument( VIPS_OBJECT_CLASS( CLASS ), \
  110. pspec, (VipsArgumentFlags) (FLAGS), (PRIORITY), (OFFSET) ); \
  111. }
  112. #define VIPS_ARG_DOUBLE( CLASS, NAME, PRIORITY, LONG, DESC, \
  113. FLAGS, OFFSET, MIN, MAX, VALUE ) { \
  114. GParamSpec *pspec; \
  115. \
  116. pspec = g_param_spec_double( (NAME), (LONG), (DESC), \
  117. (MIN), (MAX), (VALUE), \
  118. (GParamFlags) (G_PARAM_READWRITE) );\
  119. g_object_class_install_property( G_OBJECT_CLASS( CLASS ), \
  120. vips_argument_get_id(), pspec ); \
  121. vips_object_class_install_argument( VIPS_OBJECT_CLASS( CLASS ), \
  122. pspec, (VipsArgumentFlags) (FLAGS), (PRIORITY), (OFFSET) ); \
  123. }
  124. #define VIPS_ARG_BOXED( CLASS, NAME, PRIORITY, LONG, DESC, \
  125. FLAGS, OFFSET, TYPE ) { \
  126. GParamSpec *pspec; \
  127. \
  128. pspec = g_param_spec_boxed( (NAME), (LONG), (DESC), \
  129. (TYPE), \
  130. (GParamFlags) (G_PARAM_READWRITE) );\
  131. g_object_class_install_property( G_OBJECT_CLASS( CLASS ), \
  132. vips_argument_get_id(), pspec ); \
  133. vips_object_class_install_argument( VIPS_OBJECT_CLASS( CLASS ), \
  134. pspec, (VipsArgumentFlags) (FLAGS), (PRIORITY), (OFFSET) ); \
  135. }
  136. #define VIPS_ARG_INT( CLASS, NAME, PRIORITY, LONG, DESC, \
  137. FLAGS, OFFSET, MIN, MAX, VALUE ) { \
  138. GParamSpec *pspec; \
  139. \
  140. pspec = g_param_spec_int( (NAME), (LONG), (DESC), \
  141. (MIN), (MAX), (VALUE), \
  142. (GParamFlags) (G_PARAM_READWRITE) );\
  143. g_object_class_install_property( G_OBJECT_CLASS( CLASS ), \
  144. vips_argument_get_id(), pspec ); \
  145. vips_object_class_install_argument( VIPS_OBJECT_CLASS( CLASS ), \
  146. pspec, (VipsArgumentFlags) (FLAGS), (PRIORITY), (OFFSET) ); \
  147. }
  148. #define VIPS_ARG_UINT64( CLASS, NAME, PRIORITY, LONG, DESC, \
  149. FLAGS, OFFSET, MIN, MAX, VALUE ) { \
  150. GParamSpec *pspec; \
  151. \
  152. pspec = g_param_spec_uint64( (NAME), (LONG), (DESC), \
  153. (MIN), (MAX), (VALUE), \
  154. (GParamFlags) (G_PARAM_READWRITE) );\
  155. g_object_class_install_property( G_OBJECT_CLASS( CLASS ), \
  156. vips_argument_get_id(), pspec ); \
  157. vips_object_class_install_argument( VIPS_OBJECT_CLASS( CLASS ), \
  158. pspec, (VipsArgumentFlags) (FLAGS), (PRIORITY), (OFFSET) ); \
  159. }
  160. #define VIPS_ARG_ENUM( CLASS, NAME, PRIORITY, LONG, DESC, \
  161. FLAGS, OFFSET, TYPE, VALUE ) { \
  162. GParamSpec *pspec; \
  163. \
  164. pspec = g_param_spec_enum( (NAME), (LONG), (DESC), \
  165. (TYPE), (VALUE), \
  166. (GParamFlags) (G_PARAM_READWRITE) );\
  167. g_object_class_install_property( G_OBJECT_CLASS( CLASS ), \
  168. vips_argument_get_id(), pspec ); \
  169. vips_object_class_install_argument( VIPS_OBJECT_CLASS( CLASS ), \
  170. pspec, (VipsArgumentFlags) (FLAGS), (PRIORITY), (OFFSET) ); \
  171. }
  172. #define VIPS_ARG_FLAGS( CLASS, NAME, PRIORITY, LONG, DESC, \
  173. FLAGS, OFFSET, TYPE, VALUE ) { \
  174. GParamSpec *pspec; \
  175. \
  176. pspec = g_param_spec_flags( (NAME), (LONG), (DESC), \
  177. (TYPE), (VALUE), \
  178. (GParamFlags) (G_PARAM_READWRITE) );\
  179. g_object_class_install_property( G_OBJECT_CLASS( CLASS ), \
  180. vips_argument_get_id(), pspec ); \
  181. vips_object_class_install_argument( VIPS_OBJECT_CLASS( CLASS ), \
  182. pspec, (VipsArgumentFlags) (FLAGS), (PRIORITY), (OFFSET) ); \
  183. }
  184. #define VIPS_ARG_STRING( CLASS, NAME, PRIORITY, LONG, DESC, FLAGS, OFFSET, \
  185. VALUE ) { \
  186. GParamSpec *pspec; \
  187. \
  188. pspec = g_param_spec_string( (NAME), (LONG), (DESC), \
  189. (VALUE), \
  190. (GParamFlags) (G_PARAM_READWRITE) ); \
  191. g_object_class_install_property( G_OBJECT_CLASS( CLASS ), \
  192. vips_argument_get_id(), pspec ); \
  193. vips_object_class_install_argument( VIPS_OBJECT_CLASS( CLASS ), \
  194. pspec, (VipsArgumentFlags) (FLAGS), (PRIORITY), (OFFSET) ); \
  195. }
  196. #define VIPS_ARG_POINTER( CLASS, NAME, PRIORITY, LONG, DESC, FLAGS, OFFSET ) { \
  197. GParamSpec *pspec; \
  198. \
  199. pspec = g_param_spec_pointer( (NAME), (LONG), (DESC), \
  200. (GParamFlags) (G_PARAM_READWRITE) ); \
  201. g_object_class_install_property( G_OBJECT_CLASS( CLASS ), \
  202. vips_argument_get_id(), pspec ); \
  203. vips_object_class_install_argument( VIPS_OBJECT_CLASS( CLASS ), \
  204. pspec, (VipsArgumentFlags) (FLAGS), (PRIORITY), (OFFSET) ); \
  205. }
  206. /* Keep one of these for every argument.
  207. */
  208. typedef struct _VipsArgument {
  209. GParamSpec *pspec; /* pspec for this argument */
  210. /* More stuff, see below */
  211. } VipsArgument;
  212. /* Keep one of these in the class struct for every argument.
  213. */
  214. typedef struct _VipsArgumentClass {
  215. VipsArgument parent;
  216. /* The class of the object we are an arg for.
  217. */
  218. VipsObjectClass *object_class;
  219. VipsArgumentFlags flags;
  220. int priority; /* Order args by this */
  221. guint offset; /* G_STRUCT_OFFSET of member in object */
  222. } VipsArgumentClass;
  223. /* Keep one of these in the object struct for every argument instance.
  224. */
  225. typedef struct _VipsArgumentInstance {
  226. VipsArgument parent;
  227. /* The class we are part of.
  228. */
  229. VipsArgumentClass *argument_class;
  230. /* The object we are attached to.
  231. */
  232. VipsObject *object;
  233. /* Has been set.
  234. */
  235. gboolean assigned;
  236. /* If this is an output argument, keep the id of our "close" handler
  237. * here.
  238. */
  239. gulong close_id;
  240. /* We need to listen for "invalidate" on input images and send our own
  241. * "invalidate" out. If we go, we need to disconnect.
  242. */
  243. gulong invalidate_id;
  244. } VipsArgumentInstance;
  245. /* Need to look up our VipsArgument structs from a pspec. Just hash the
  246. * pointer (ie. we assume pspecs are never shared, is this correct?)
  247. */
  248. typedef GHashTable VipsArgumentTable;
  249. int vips_argument_get_id( void );
  250. void vips__object_set_member( VipsObject *object, GParamSpec *pspec,
  251. GObject **member, GObject *argument );
  252. typedef void *(*VipsArgumentMapFn)( VipsObject *object, GParamSpec *pspec,
  253. VipsArgumentClass *argument_class,
  254. VipsArgumentInstance *argument_instance, void *a, void *b );
  255. void *vips_argument_map( VipsObject *object,
  256. VipsArgumentMapFn fn, void *a, void *b );
  257. int vips_object_get_args( VipsObject *object,
  258. const char ***names, int **flags, int *n_args );
  259. typedef void *(*VipsArgumentClassMapFn)( VipsObjectClass *object_class,
  260. GParamSpec *pspec,
  261. VipsArgumentClass *argument_class, void *a, void *b );
  262. void *vips_argument_class_map( VipsObjectClass *object_class,
  263. VipsArgumentClassMapFn fn, void *a, void *b );
  264. gboolean vips_argument_class_needsstring( VipsArgumentClass *argument_class );
  265. int vips_object_get_argument( VipsObject *object, const char *name,
  266. GParamSpec **pspec,
  267. VipsArgumentClass **argument_class,
  268. VipsArgumentInstance **argument_instance );
  269. gboolean vips_object_argument_isset( VipsObject *object, const char *name );
  270. VipsArgumentFlags vips_object_get_argument_flags( VipsObject *object,
  271. const char *name );
  272. int vips_object_get_argument_priority( VipsObject *object, const char *name );
  273. /* We have to loop over an objects args in several places, and we can't always
  274. * use vips_argument_map(), the preferred looper. Have the loop code as a
  275. * macro as well for these odd cases.
  276. */
  277. #define VIPS_ARGUMENT_FOR_ALL( OBJECT, PSPEC, ARG_CLASS, ARG_INSTANCE ) { \
  278. VipsObjectClass *object_class = VIPS_OBJECT_GET_CLASS( OBJECT ); \
  279. GSList *p; \
  280. \
  281. for( p = object_class->argument_table_traverse; p; p = p->next ) { \
  282. VipsArgumentClass *ARG_CLASS = \
  283. (VipsArgumentClass *) p->data; \
  284. VipsArgument *argument = (VipsArgument *) argument_class; \
  285. GParamSpec *PSPEC = argument->pspec; \
  286. VipsArgumentInstance *ARG_INSTANCE __attribute__ ((unused)) = \
  287. vips__argument_get_instance( argument_class, \
  288. VIPS_OBJECT( OBJECT ) ); \
  289. #define VIPS_ARGUMENT_FOR_ALL_END } }
  290. /* And some macros to collect args from a va list.
  291. *
  292. * Use something like this:
  293. GParamSpec *pspec;
  294. VipsArgumentClass *argument_class;
  295. VipsArgumentInstance *argument_instance;
  296. if( vips_object_get_argument( VIPS_OBJECT( operation ), name,
  297. &pspec, &argument_class, &argument_instance ) )
  298. return( -1 );
  299. VIPS_ARGUMENT_COLLECT_SET( pspec, argument_class, ap );
  300. GValue value holds the value of an input argument, do
  301. something with it
  302. VIPS_ARGUMENT_COLLECT_GET( pspec, argument_class, ap );
  303. void **arg points to where to write an output argument
  304. VIPS_ARGUMENT_COLLECT_END
  305. */
  306. #define VIPS_ARGUMENT_COLLECT_SET( PSPEC, ARG_CLASS, AP ) \
  307. if( (ARG_CLASS->flags & VIPS_ARGUMENT_INPUT) ) { \
  308. GValue value = { 0, }; \
  309. gchar *error = NULL; \
  310. \
  311. /* Input args are given inline, eg. ("factor", 12.0) \
  312. * and must be collected. \
  313. */ \
  314. g_value_init( &value, G_PARAM_SPEC_VALUE_TYPE( PSPEC ) ); \
  315. G_VALUE_COLLECT( &value, AP, 0, &error ); \
  316. \
  317. /* Don't bother with the error message. \
  318. */ \
  319. if( error ) { \
  320. VIPS_DEBUG_MSG( "VIPS_OBJECT_COLLECT_SET: err\n" ); \
  321. g_free( error ); \
  322. }
  323. #define VIPS_ARGUMENT_COLLECT_GET( PSPEC, ARG_CLASS, AP ) \
  324. g_value_unset( &value ); \
  325. } \
  326. else if( (ARG_CLASS->flags & VIPS_ARGUMENT_OUTPUT) ) { \
  327. void **arg __attribute__ ((unused)); \
  328. \
  329. /* Output args are a pointer to where to send the \
  330. * result. \
  331. */ \
  332. arg = va_arg( AP, void ** );
  333. #define VIPS_ARGUMENT_COLLECT_END \
  334. }
  335. #define VIPS_TYPE_OBJECT (vips_object_get_type())
  336. #define VIPS_OBJECT( obj ) \
  337. (G_TYPE_CHECK_INSTANCE_CAST( (obj), VIPS_TYPE_OBJECT, VipsObject ))
  338. #define VIPS_OBJECT_CLASS( klass ) \
  339. (G_TYPE_CHECK_CLASS_CAST( (klass), VIPS_TYPE_OBJECT, VipsObjectClass))
  340. #define VIPS_IS_OBJECT( obj ) \
  341. (G_TYPE_CHECK_INSTANCE_TYPE( (obj), VIPS_TYPE_OBJECT ))
  342. #define VIPS_IS_OBJECT_CLASS( klass ) \
  343. (G_TYPE_CHECK_CLASS_TYPE( (klass), VIPS_TYPE_OBJECT ))
  344. #define VIPS_OBJECT_GET_CLASS( obj ) \
  345. (G_TYPE_INSTANCE_GET_CLASS( (obj), VIPS_TYPE_OBJECT, VipsObjectClass ))
  346. struct _VipsObject {
  347. GObject parent_instance;
  348. /* Set after ->build() has run succesfully: construct is fully done
  349. * and checked.
  350. */
  351. gboolean constructed;
  352. /* Set for static objects which are allocated at startup and never
  353. * freed. These objects are ommitted from leak reports.
  354. */
  355. gboolean static_object;
  356. /* Table of argument instances for this class and any derived classes.
  357. */
  358. VipsArgumentTable *argument_table;
  359. /* Class properties (see below), duplicated in the instance so we can
  360. * get at them easily via the property system.
  361. */
  362. char *nickname;
  363. char *description;
  364. /* The pre/post/close callbacks are all fire-once.
  365. */
  366. gboolean preclose;
  367. gboolean close;
  368. gboolean postclose;
  369. /* Total memory allocated relative to this object, handy for
  370. * profiling.
  371. */
  372. size_t local_memory;
  373. };
  374. struct _VipsObjectClass {
  375. GObjectClass parent_class;
  376. /* Build the object ... all argument properties have been set,
  377. * now build the thing.
  378. */
  379. int (*build)( VipsObject *object );
  380. /* Just after build ... the object is fully ready for work.
  381. */
  382. int (*postbuild)( VipsObject *object );
  383. /* Try to print something about the class, handy for help displays.
  384. * Keep to one line.
  385. */
  386. void (*summary_class)( struct _VipsObjectClass *cls, VipsBuf *buf );
  387. /* Try to print a one-line summary for the object, the user can see
  388. * this output via things like "header fred.tif", --vips-cache-trace,
  389. * etc.
  390. */
  391. void (*summary)( VipsObject *object, VipsBuf *buf );
  392. /* Try to print everything about the object, handy for debugging.
  393. */
  394. void (*dump)( VipsObject *object, VipsBuf *buf );
  395. /* Sanity-check the object. Print messages and stuff.
  396. * Handy for debugging.
  397. */
  398. void (*sanity)( VipsObject *object, VipsBuf *buf );
  399. /* Rewind. Save and restore any stuff that needs to survive a
  400. * dispose().
  401. */
  402. void (*rewind)( VipsObject *object );
  403. /* Just before close, everything is still alive.
  404. */
  405. void (*preclose)( VipsObject *object );
  406. /* Close, time to free stuff.
  407. */
  408. void (*close)( VipsObject *object );
  409. /* Post-close, everything is dead, except the VipsObject pointer.
  410. * Useful for eg. deleting the file associated with a temp image.
  411. */
  412. void (*postclose)( VipsObject *object );
  413. /* The CLI interface. Implement these four to get CLI input and output
  414. * for your object.
  415. */
  416. /* Given a command-line arg (eg. a filename), make an instance of the
  417. * object. Just do the g_object_new(), don't call _build().
  418. *
  419. * Don't call this directly, see vips_object_new_from_string().
  420. */
  421. VipsObject *(*new_from_string)( const char *string );
  422. /* The inverse of ^^. Given an object, output what ->new_from_string()
  423. * would have been given to make that object.
  424. */
  425. void (*to_string)( VipsObject *object, VipsBuf *buf );
  426. /* Does this output arg need an arg from the command line? Image
  427. * output, for example, needs a filename to write to.
  428. */
  429. gboolean output_needs_arg;
  430. /* Write the object to the string. Return 0 for success, or -1 on
  431. * error, setting vips_error(). string is NULL if output_needs_arg()
  432. * was FALSE.
  433. */
  434. int (*output_to_arg)( VipsObject *object, const char *string );
  435. /* Class nickname, eg. "VipsInterpolateBicubic" has "bicubic" as a
  436. * nickname. Not internationalised.
  437. */
  438. const char *nickname;
  439. /* Class description. Used for help messages, so internationalised.
  440. */
  441. const char *description;
  442. /* Hash from pspec to VipsArgumentClass.
  443. *
  444. * This records the VipsArgumentClass for every pspec used in
  445. * VipsObject and any subclass (ie. everywhere), so it's huge. Don't
  446. * loop over this hash! Fine for lookups though.
  447. */
  448. VipsArgumentTable *argument_table;
  449. /* A sorted (by priority) list of the VipsArgumentClass for this class
  450. * and any superclasses. This is small and specific to this class.
  451. *
  452. * Use the stored GType to work out when to restart the list for a
  453. * subclass.
  454. */
  455. GSList *argument_table_traverse;
  456. GType argument_table_traverse_gtype;
  457. /* This class is deprecated and therefore hidden from various UI bits.
  458. *
  459. * VipsOperation has a deprecated flag, use that in preference to this
  460. * if you can.
  461. */
  462. gboolean deprecated;
  463. /* Reserved for future expansion.
  464. */
  465. void (*_vips_reserved1)( void );
  466. void (*_vips_reserved2)( void );
  467. void (*_vips_reserved3)( void );
  468. void (*_vips_reserved4)( void );
  469. };
  470. gboolean vips_value_is_null( GParamSpec *psoec, const GValue *value );
  471. void vips_object_set_property( GObject *gobject,
  472. guint property_id, const GValue *value, GParamSpec *pspec );
  473. void vips_object_get_property( GObject *gobject,
  474. guint property_id, GValue *value, GParamSpec *pspec );
  475. void vips_object_preclose( VipsObject *object );
  476. int vips_object_build( VipsObject *object );
  477. void vips_object_summary_class( VipsObjectClass *klass, VipsBuf *buf );
  478. void vips_object_summary( VipsObject *object, VipsBuf *buf );
  479. void vips_object_dump( VipsObject *object, VipsBuf *buf );
  480. void vips_object_print_summary_class( VipsObjectClass *klass );
  481. void vips_object_print_summary( VipsObject *object );
  482. void vips_object_print_dump( VipsObject *object );
  483. void vips_object_print_name( VipsObject *object );
  484. gboolean vips_object_sanity( VipsObject *object );
  485. /* Don't put spaces around void here, it breaks gtk-doc.
  486. */
  487. GType vips_object_get_type(void);
  488. void vips_object_class_install_argument( VipsObjectClass *cls,
  489. GParamSpec *pspec, VipsArgumentFlags flags,
  490. int priority, guint offset );
  491. int vips_object_set_argument_from_string( VipsObject *object,
  492. const char *name, const char *value );
  493. gboolean vips_object_argument_needsstring( VipsObject *object,
  494. const char *name );
  495. int vips_object_get_argument_to_string( VipsObject *object,
  496. const char *name, const char *arg );
  497. int vips_object_set_required( VipsObject *object, const char *value );
  498. typedef void *(*VipsObjectSetArguments)( VipsObject *object, void *a, void *b );
  499. VipsObject *vips_object_new( GType type,
  500. VipsObjectSetArguments set, void *a, void *b );
  501. int vips_object_set_valist( VipsObject *object, va_list ap );
  502. int vips_object_set( VipsObject *object, ... )
  503. __attribute__((sentinel));
  504. int vips_object_set_from_string( VipsObject *object, const char *string );
  505. VipsObject *vips_object_new_from_string( VipsObjectClass *object_class,
  506. const char *p );
  507. void vips_object_to_string( VipsObject *object, VipsBuf *buf );
  508. void *vips_object_map( VipsSListMap2Fn fn, void *a, void *b );
  509. typedef void *(*VipsTypeMapFn)( GType type, void *a );
  510. typedef void *(*VipsTypeMap2Fn)( GType type, void *a, void *b );
  511. typedef void *(*VipsClassMapFn)( VipsObjectClass *cls, void *a );
  512. void *vips_type_map( GType base, VipsTypeMap2Fn fn, void *a, void *b );
  513. void *vips_type_map_all( GType base, VipsTypeMapFn fn, void *a );
  514. int vips_type_depth( GType type );
  515. GType vips_type_find( const char *basename, const char *nickname );
  516. const char *vips_nickname_find( GType type );
  517. void *vips_class_map_all( GType type, VipsClassMapFn fn, void *a );
  518. const VipsObjectClass *vips_class_find( const char *basename,
  519. const char *nickname );
  520. VipsObject **vips_object_local_array( VipsObject *parent, int n );
  521. void vips_object_local_cb( VipsObject *vobject, GObject *gobject );
  522. #define vips_object_local( V, G ) \
  523. (g_signal_connect( V, "close", G_CALLBACK( vips_object_local_cb ), G ))
  524. void vips_object_set_static( VipsObject *object, gboolean static_object );
  525. void vips_object_print_all( void );
  526. void vips_object_sanity_all( void );
  527. void vips_object_rewind( VipsObject *object );
  528. void vips_object_unref_outputs( VipsObject *object );
  529. const char *vips_object_get_description( VipsObject *object );
  530. #ifdef __cplusplus
  531. }
  532. #endif /*__cplusplus*/
  533. #endif /*VIPS_OBJECT_H*/