## VipsOperation

VipsOperation — the VIPS operation base object class

## Stability Level

Stable, unless otherwise indicated

## Synopsis

    #include <vips/vips.h>

    enum                VipsOperationFlags;
    gboolean            (*VipsOperationBuildFn)             (VipsObject *Param1);
                        VipsOperation;
                        VipsOperationClass;
    VipsOperationFlags  vips_operation_get_flags            (VipsOperation *operation);
    void                vips_operation_class_print_usage    (VipsOperationClass *operation_class);
    int                 vips_operation_call_valist          (VipsOperation *operation,
                                                             va_list ap);
    VipsOperation *     vips_operation_new                  (const char *name);
    int                 vips_call                           (const char *operation_name,
                                                             ...);
    int                 vips_call_split                     (const char *operation_name,
                                                             va_list optional,
                                                             ...);
    void                vips_call_options                   (GOptionGroup *group,
                                                             VipsOperation *operation);
    int                 vips_call_argv                      (VipsOperation *operation,
                                                             int argc,
                                                             char **argv);
    void                vips_cache_drop_all                 (void);
    int                 vips_cache_operation_buildp         (VipsOperation **operation);
    VipsOperation *     vips_cache_operation_build          (VipsOperation *operation);
    void                vips_cache_print                    (void);
    void                vips_cache_set_max                  (int max);
    void                vips_cache_set_max_mem              (size_t max_mem);
    int                 vips_cache_get_max                  (void);
    int                 vips_cache_get_size                 (void);
    size_t              vips_cache_get_max_mem              (void);
    int                 vips_cache_get_max_files            (void);
    void                vips_cache_set_max_files            (int max_files);
    void                vips_cache_set_dump                 (gboolean dump);
    void                vips_cache_set_trace                (gboolean trace);

## Object Hierarchy

      GObject
       +----VipsObject
             +----VipsOperation
                   +----VipsConvolution
                   +----VipsCorrelation
                   +----VipsForeign
                   +----VipsFreqfilt
                   +----VipsHistogram
                   +----VipsCreate
                   +----VipsMorphology

## Description

The VipsOperation class and associated types and macros.

VipsOperation is the base class for all operations in libvips. It builds on VipsObject to provide the introspection and command-line interface to libvips.

It also maintains a cache of recent operations. You can tune the cache behaviour in various ways.

## Details

### enum VipsOperationFlags

    typedef enum {
    	VIPS_OPERATION_NONE = 0,
    	VIPS_OPERATION_SEQUENTIAL = 1,
    	VIPS_OPERATION_SEQUENTIAL_UNBUFFERED = 2,
    	VIPS_OPERATION_NOCACHE = 4
    } VipsOperationFlags;

Flags we associate with an operation.

`VIPS_OPERATION_SEQUENTIAL` means that the operation works like `vips_conv()`: it can happily process images top-to-bottom with only small non-local references.

`VIPS_OPERATION_SEQUENTIAL_UNBUFFERED` means that the operation works like `vips_copy()`: it can happily process images top-to-bottom and makes no non-local references.

`VIPS_OPERATION_NOCACHE` means that the operation must not be cached by vips.

`VIPS_OPERATION_NONE` | no flags
`VIPS_OPERATION_SEQUENTIAL` | can work sequentially
`VIPS_OPERATION_SEQUENTIAL_UNBUFFERED` |
`VIPS_OPERATION_NOCACHE` | must not be cached

### VipsOperationBuildFn ()

    gboolean            (*VipsOperationBuildFn)             (VipsObject *Param1);

### VipsOperation

    typedef struct _VipsOperation VipsOperation;

### VipsOperationClass

    typedef struct {
    	VipsObjectClass parent_class;

    	/* Print the usage message.
    	 */
    	void (*usage)( struct _VipsOperationClass *, VipsBuf * );

    	/* Return a set of operation flags.
    	 */
    	VipsOperationFlags (*get_flags)( VipsOperation * );
    	VipsOperationFlags flags;
    } VipsOperationClass;

### vips_operation_get_flags ()

    VipsOperationFlags  vips_operation_get_flags            (VipsOperation *operation);

Returns the set of flags for this operation.

`operation` : | operation to fetch flags from
Returns : | 0 on success, or -1 on error.

### vips_operation_class_print_usage ()

    void                vips_operation_class_print_usage    (VipsOperationClass *operation_class);

Print a usage message for the operation to stdout.

`operation_class` : | class to print usage for

### vips_operation_call_valist ()

    int                 vips_operation_call_valist          (VipsOperation *operation,
                                                             va_list ap);

### vips_operation_new ()

    VipsOperation *     vips_operation_new                  (const char *name);

### vips_call ()

    int                 vips_call                           (const char *operation_name,
                                                             ...);

### vips_call_split ()

    int                 vips_call_split                     (const char *operation_name,
                                                             va_list optional,
                                                             ...);

### vips_call_options ()

    void                vips_call_options                   (GOptionGroup *group,
                                                             VipsOperation *operation);

### vips_call_argv ()

    int                 vips_call_argv                      (VipsOperation *operation,
                                                             int argc,
                                                             char **argv);

### vips_cache_drop_all ()

    void                vips_cache_drop_all                 (void);

Drop the whole operation cache, handy for leak tracking.

### vips_cache_operation_buildp ()

    int                 vips_cache_operation_buildp         (VipsOperation **operation);

Look up `operation` in the cache. If we get a hit, unref `operation`, ref the old one and return that through the argument pointer.

If we miss, build and add `operation`.

`operation` : | pointer to operation to lookup
Returns : | 0 on success, or -1 on error.

### vips_cache_operation_build ()

    VipsOperation *     vips_cache_operation_build          (VipsOperation *operation);

A binding-friendly version of `vips_cache_operation_buildp()`.

After calling this, `operation` has the same ref count as when it went in, and the result must be freed with `vips_object_unref_outputs()` and `g_object_unref()`.

`operation` : | operation to lookup
Returns : | The built operation. [transfer full]

### vips_cache_print ()

    void                vips_cache_print                    (void);

Print the whole operation cache to stdout. Handy for debugging.

### vips_cache_set_max ()

    void                vips_cache_set_max                  (int max);

Set the maximum number of operations we keep in cache.

`max` : | maximum number of operation to cache

### vips_cache_set_max_mem ()

    void                vips_cache_set_max_mem              (size_t max_mem);

Set the maximum amount of tracked memory we allow before we start dropping cached operations. See `vips_tracked_get_mem()`.

See also: `vips_tracked_get_mem()`.

`max_mem` : | maximum amount of tracked memory we use

### vips_cache_get_max ()

    int                 vips_cache_get_max                  (void);

Get the maximum number of operations we keep in cache.

Returns : | the maximum number of operations we keep in cache

### vips_cache_get_size ()

    int                 vips_cache_get_size                 (void);

Get the current number of operations in cache.

Returns : | get the current number of operations in cache.

### vips_cache_get_max_mem ()

    size_t              vips_cache_get_max_mem              (void);

Get the maximum amount of tracked memory we allow before we start dropping cached operations. See `vips_tracked_get_mem()`.

See also: `vips_tracked_get_mem()`.

Returns : | the maximum amount of tracked memory we allow

### vips_cache_get_max_files ()

    int                 vips_cache_get_max_files            (void);

Get the maximum number of tracked files we allow before we start dropping cached operations. See `vips_tracked_get_files()`.

See also: `vips_tracked_get_files()`.

Returns : | the maximum number of tracked files we allow

### vips_cache_set_max_files ()

    void                vips_cache_set_max_files            (int max_files);

Set the maximum number of tracked files we allow before we start dropping cached operations. See `vips_tracked_get_files()`.

See also: `vips_tracked_get_files()`.

`max_files` : | max open files we allow

### vips_cache_set_dump ()

    void                vips_cache_set_dump                 (gboolean dump);

Handy for debugging. Print the operation cache to stdout just before exit.

See also: `vips_cache_set_trace()`.

`dump` : | if `TRUE`, dump the operation cache on exit

### vips_cache_set_trace ()

    void                vips_cache_set_trace                (gboolean trace);

Handy for debugging. Print operation cache actions to stdout as we run.

See also: `vips_cache_set_dump()`.

`trace` : | if `TRUE`, trace the operation cache

## See Also

object