1 /*
2  gg_sequence.h -- Gaia support for Spatialite's own Sequence
3 
4  version 5.0, 2020 August 1
5 
6  Author: Sandro Furieri a.furieri@lqt.it
7 
8  ------------------------------------------------------------------------------
9 
10  Version: MPL 1.1/GPL 2.0/LGPL 2.1
11 
12  The contents of this file are subject to the Mozilla Public License Version
13  1.1 (the "License"); you may not use this file except in compliance with
14  the License. You may obtain a copy of the License at
15  http://www.mozilla.org/MPL/
16 
17 Software distributed under the License is distributed on an "AS IS" basis,
18 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
19 for the specific language governing rights and limitations under the
20 License.
21 
22 The Original Code is the SpatiaLite library
23 
24 The Initial Developer of the Original Code is Alessandro Furieri
25 
26 Portions created by the Initial Developer are Copyright (C) 2008-2021
27 the Initial Developer. All Rights Reserved.
28 
29 Contributor(s):
30 
31 
32 Alternatively, the contents of this file may be used under the terms of
33 either the GNU General Public License Version 2 or later (the "GPL"), or
34 the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
35 in which case the provisions of the GPL or the LGPL are applicable instead
36 of those above. If you wish to allow use of your version of this file only
37 under the terms of either the GPL or the LGPL, and not to allow others to
38 use your version of this file under the terms of the MPL, indicate your
39 decision by deleting the provisions above and replace them with the notice
40 and other provisions required by the GPL or the LGPL. If you do not delete
41 the provisions above, a recipient may use your version of this file under
42 the terms of any one of the MPL, the GPL or the LGPL.
43 
44 */
45 
46 
47 /**
48  \file gg_sequence.h
49 
50  Spatialite's own Sequence
51  */
52 
53 #ifndef DOXYGEN_SHOULD_SKIP_THIS
54 /* stdio.h included for FILE objects. */
55 #include <stdio.h>
56 #ifdef DLL_EXPORT
57 #define GAIASEQ_DECLARE __declspec(dllexport)
58 #else
59 #define GAIASEQ_DECLARE extern
60 #endif
61 #endif
62 
63 #ifndef _GG_SEQUENCE_H
64 #ifndef DOXYGEN_SHOULD_SKIP_THIS
65 #define _GG_SEQUENCE_H
66 #endif
67 
68 #ifdef __cplusplus
69 extern "C"
70 {
71 #endif
72 
73 /**
74  Typedef for Spatialite's own Sequence
75  */
76     typedef struct gaia_sequence
77     {
78 /** name of the Sequence; NULL for the generic unnamed Sequence */
79 	char *seq_name;
80 /** current value */
81 	int value;
82 /** pointer to next Sequence (linked list) */
83 	struct gaia_sequence *next;
84     } gaiaSequence;
85 
86 /**
87  Typedef for Spatialite's own Sequence
88  */
89     typedef gaiaSequence *gaiaSequencePtr;
90 /**
91 / Creates a new SpatiaLite's own Sequence or retrieves an already
92   existing Sequence of the same name
93 
94  \param p_cache a memory pointer returned by spatialite_alloc_connection()
95  \param seq_name name of the Sequence (may be NULL)
96 
97  \return a pointer to the Sequence or NULL on failure
98 
99  \sa gaiaFindSequence(), gaiaLastUsedSequence(), gaiaSequenceNext(),
100  gaiaResetSequence()
101   */
102     GAIASEQ_DECLARE gaiaSequencePtr gaiaCreateSequence (const void *p_cache,
103 							const char *seq_name);
104 
105 /**
106 / Finds an existing SpatiaLite's own Sequence
107 
108  \param p_cache a memory pointer returned by spatialite_alloc_connection()
109  \param seq_name name of the Sequence (may be NULL)
110 
111  \return a pointer to the Sequence or NULL on failure
112 
113  \sa gaiaCreateSequence(), gaiaLastUsedSequence(), gaiaSequenceNext(),
114  gaiaResetSequence()
115   */
116     GAIASEQ_DECLARE gaiaSequencePtr gaiaFindSequence (const void *p_cache,
117 						      const char *seq_name);
118 
119 /**
120 / Finds an existing SpatiaLite's own Sequence
121 
122  \param p_cache a memory pointer returned by spatialite_alloc_connection()
123  \param last_value on sucess will contain the most recently used Sequence value
124 
125  \return ZERO on failure, any other value on success.
126 
127  \sa gaiaCreateSequence(), gaiaLastUsedSequence(), gaiaSequenceNext(),
128  gaiaResetSequence()
129   */
130     GAIASEQ_DECLARE int gaiaLastUsedSequence (const void *p_cache,
131 					      int *last_value);
132 
133 /**
134 / Increases by 1 the value of some SpatiaLite's own Sequence
135 
136  \param p_cache a memory pointer returned by spatialite_alloc_connection()
137  \param sequence a memory pointer returned by gaiaFindSequence() or
138  gaiaFindCreateSequence()
139  \param value new value to be set for the given Sequence
140 
141  \return ZERO on failure, any other value on success.
142 
143  \sa gaiaFindSequence(), gaiaCreateSequence(), gaiaLastUsedSequence(),
144  gaiaResetSequence()
145 
146  \note this method will reset an existing Sequence. The initial
147  value will be increased by the next call to gaiaSequenceNext()
148   */
149     GAIASEQ_DECLARE int gaiaSequenceNext (const void *p_cache,
150 					  gaiaSequencePtr sequence);
151 
152 /**
153 / Resets a SpatiaLite's own Sequence
154 
155  \param sequence a memory pointer returned by gaiaFindSequence() or
156  gaiaCreateSequence()
157  \param value new value to be set for the given Sequence
158 
159  \return ZERO on failure, any other value on success.
160 
161  \sa gaiaFindSequence(), gaiaCreateSequence(), gaiaSequenceNext(),
162  gaiaLastUsedSequence()
163 
164  \note this method will reset an existing Sequence. The initial
165  value will be increased by the next call to gaiaSequenceNext()
166  */
167     GAIASEQ_DECLARE int gaiaResetSequence (gaiaSequencePtr sequence, int value);
168 
169 #ifdef __cplusplus
170 }
171 #endif
172 
173 #endif				/* _GG_SEQUENCE_H */
174