1 /* base class for all vips operations
2  */
3 
4 /*
5 
6     Copyright (C) 1991-2005 The National Gallery
7 
8     This library is free software; you can redistribute it and/or
9     modify it under the terms of the GNU Lesser General Public
10     License as published by the Free Software Foundation; either
11     version 2.1 of the License, or (at your option) any later version.
12 
13     This library is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16     Lesser General Public License for more details.
17 
18     You should have received a copy of the GNU Lesser General Public
19     License along with this library; if not, write to the Free Software
20     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21     02110-1301  USA
22 
23  */
24 
25 /*
26 
27     These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
28 
29  */
30 
31 #ifndef VIPS_OPERATION_H
32 #define VIPS_OPERATION_H
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif /*__cplusplus*/
37 
38 typedef enum /*< flags >*/ {
39 	VIPS_OPERATION_NONE = 0,
40 	VIPS_OPERATION_SEQUENTIAL = 1,
41 	VIPS_OPERATION_SEQUENTIAL_UNBUFFERED = 2,
42 	VIPS_OPERATION_NOCACHE = 4,
43 	VIPS_OPERATION_DEPRECATED = 8
44 } VipsOperationFlags;
45 
46 #define VIPS_TYPE_OPERATION (vips_operation_get_type())
47 #define VIPS_OPERATION( obj ) \
48 	(G_TYPE_CHECK_INSTANCE_CAST( (obj), \
49 		VIPS_TYPE_OPERATION, VipsOperation ))
50 #define VIPS_OPERATION_CLASS( klass ) \
51 	(G_TYPE_CHECK_CLASS_CAST( (klass), \
52 		VIPS_TYPE_OPERATION, VipsOperationClass ))
53 #define VIPS_IS_OPERATION( obj ) \
54 	(G_TYPE_CHECK_INSTANCE_TYPE( (obj), VIPS_TYPE_OPERATION ))
55 #define VIPS_IS_OPERATION_CLASS( klass ) \
56 	(G_TYPE_CHECK_CLASS_TYPE( (klass), VIPS_TYPE_OPERATION ))
57 #define VIPS_OPERATION_GET_CLASS( obj ) \
58 	(G_TYPE_INSTANCE_GET_CLASS( (obj), \
59 		VIPS_TYPE_OPERATION, VipsOperationClass ))
60 
61 typedef gboolean (*VipsOperationBuildFn)( VipsObject *object );
62 
63 typedef struct _VipsOperation {
64 	VipsObject parent_instance;
65 
66 	/* Keep the hash here.
67 	 */
68 	guint hash;
69 	gboolean found_hash;
70 
71 	/* Pixels calculated ... handy for measuring over-calculation.
72 	 */
73 	int pixels;
74 
75 } VipsOperation;
76 
77 typedef struct _VipsOperationClass {
78 	VipsObjectClass parent_class;
79 
80 	/* Print the usage message.
81 	 */
82 	void (*usage)( struct _VipsOperationClass *cls, VipsBuf *buf );
83 
84 	/* Return a set of operation flags.
85 	 */
86 	VipsOperationFlags (*get_flags)( VipsOperation *operation );
87 	VipsOperationFlags flags;
88 
89 	/* One of our input images has signalled "invalidate". The cache uses
90 	 * VipsOperation::invalidate to drop dirty ops.
91 	 */
92 	void (*invalidate)( VipsOperation *operation );
93 } VipsOperationClass;
94 
95 /* Don't put spaces around void here, it breaks gtk-doc.
96  */
97 GType vips_operation_get_type(void);
98 
99 VipsOperationFlags vips_operation_get_flags( VipsOperation *operation );
100 void vips_operation_class_print_usage( VipsOperationClass *operation_class );
101 void vips_operation_invalidate( VipsOperation *operation );
102 
103 int vips_operation_call_valist( VipsOperation *operation, va_list ap );
104 VipsOperation *vips_operation_new( const char *name );
105 int vips_call_required_optional( VipsOperation **operation,
106 	va_list required, va_list optional );
107 int vips_call( const char *operation_name, ... )
108 	__attribute__((sentinel));
109 int vips_call_split( const char *operation_name, va_list optional, ... );
110 int vips_call_split_option_string( const char *operation_name,
111 	const char *option_string, va_list optional, ... );
112 
113 void vips_call_options( GOptionGroup *group, VipsOperation *operation );
114 int vips_call_argv( VipsOperation *operation, int argc, char **argv );
115 
116 void vips_cache_drop_all( void );
117 VipsOperation *vips_cache_operation_lookup( VipsOperation *operation );
118 void vips_cache_operation_add( VipsOperation *operation );
119 int vips_cache_operation_buildp( VipsOperation **operation );
120 VipsOperation *vips_cache_operation_build( VipsOperation *operation );
121 void vips_cache_print( void );
122 void vips_cache_set_max( int max );
123 void vips_cache_set_max_mem( size_t max_mem );
124 int vips_cache_get_max( void );
125 int vips_cache_get_size( void );
126 size_t vips_cache_get_max_mem( void );
127 int vips_cache_get_max_files( void );
128 void vips_cache_set_max_files( int max_files );
129 void vips_cache_set_dump( gboolean dump );
130 void vips_cache_set_trace( gboolean trace );
131 
132 /* Part of threadpool, really, but we want these in a header that gets scanned
133  * for our typelib.
134  */
135 void vips_concurrency_set( int concurrency );
136 int vips_concurrency_get( void );
137 
138 #ifdef __cplusplus
139 }
140 #endif /*__cplusplus*/
141 
142 #endif /*VIPS_OPERATION_H*/
143