Grassroots Infrastructure
The Grassroots Infrastructure is a suite of computing tools to help users and developers use scientific data infrastructure that can easily be interconnected.
schema_version.h
Go to the documentation of this file.
1 /*
2 ** Copyright 2014-2016 The Earlham Institute
3 **
4 ** Licensed under the Apache License, Version 2.0 (the "License");
5 ** you may not use this file except in compliance with the License.
6 ** You may obtain a copy of the License at
7 **
8 ** http://www.apache.org/licenses/LICENSE-2.0
9 **
10 ** Unless required by applicable law or agreed to in writing, software
11 ** distributed under the License is distributed on an "AS IS" BASIS,
12 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 ** See the License for the specific language governing permissions and
14 ** limitations under the License.
15 */
16 
21 /*
22  * schema_version.h
23  *
24  * Created on: 6 May 2016
25  * Author: tyrrells
26  */
27 
28 #ifndef SRC_UTIL_INCLUDE_SCHEMA_VERSION_H_
29 #define SRC_UTIL_INCLUDE_SCHEMA_VERSION_H_
30 
32 #include "typedefs.h"
33 #include "jansson.h"
34 
35 
44 typedef struct SchemaVersion
45 {
47  uint32 sv_major;
48 
50  uint32 sv_minor;
51 
57  char *sv_version_s;
59 
60 
61 
62 /*
63  * The following preprocessor macros allow us to declare
64  * and define the variables in the same place. By default,
65  * they will expand to
66  *
67  * extern const char *SERVICE_NAME_S;
68  *
69  * however if ALLOCATE_SCHEMA_VERSION_TAGS is defined then it will
70  * become
71  *
72  * const char *ALLOCATE_SCHEMA_VERSION_TAGS = "path";
73  *
74  * ALLOCATE_SCHEMA_VERSION_TAGS must be defined only once prior to
75  * including this header file. Currently this happens in
76  * schema_version.c.
77  */
78 
79 #ifndef DOXYGEN_SHOULD_SKIP_THIS
80 
81 #ifdef ALLOCATE_SCHEMA_VERSION_TAGS
82  #define SV_PREFIX GRASSROOTS_UTIL_API
83  #define SV_VAL(x) = x
84 #else
85  #define SV_PREFIX extern GRASSROOTS_UTIL_API
86  #define SV_VAL(x)
87 #endif
88 
89 #endif /* ifndef DOXYGEN_SHOULD_SKIP_THIS */
90 
91 #ifdef __cplusplus
92 extern "C" {
93 #endif
94 
95 
96 
102 SV_PREFIX const uint32 CURRENT_SCHEMA_VERSION_MAJOR SV_VAL(0);
103 
104 
110 SV_PREFIX const uint32 CURRENT_SCHEMA_VERSION_MINOR SV_VAL(10);
111 
112 
123 GRASSROOTS_UTIL_API SchemaVersion *AllocateSchemaVersion (const int major, const int minor);
124 
125 
136 GRASSROOTS_UTIL_API bool SetSchemaVersionDetails (SchemaVersion *sv_p, const int major, const int minor);
137 
138 
146 
147 
155 
156 
164 GRASSROOTS_UTIL_API json_t *GetSchemaVersionAsJSON (const SchemaVersion * const sv_p);
165 
166 
176 GRASSROOTS_UTIL_API SchemaVersion *GetSchemaVersionFromJSON (const json_t * const json_p);
177 
178 
179 
181 
182 
183 
184 #ifdef __cplusplus
185 }
186 #endif
187 
188 
189 #endif /* SRC_UTIL_INCLUDE_SCHEMA_VERSION_H_ */
SchemaVersion
This is a datatype to store the versioning details for the Grassroots JSON schema that is being used.
Definition: schema_version.h:44
grassroots_util_library.h
SchemaVersion::sv_minor
uint32 sv_minor
The minor revision of the schema.
Definition: schema_version.h:50
SchemaVersion::GetSchemaVersionFromJSON
SchemaVersion * GetSchemaVersionFromJSON(const json_t *const json_p)
Create a SchemaVersion from a JSON representation.
SchemaVersion::AllocateSchemaVersion
SchemaVersion * AllocateSchemaVersion(const int major, const int minor)
Create a new SchemaVersion.
SchemaVersion::GetSchemaVersionAsJSON
json_t * GetSchemaVersionAsJSON(const SchemaVersion *const sv_p)
Get the JSON representation for a SchemaVersion.
typedefs.h
SchemaVersion::ClearSchemaVersion
void ClearSchemaVersion(SchemaVersion *sv_p)
Clear the memory and resources for a given SchemaVersion.
SchemaVersion::FreeSchemaVersion
void FreeSchemaVersion(SchemaVersion *sv_p)
Free the memory and resources for a given SchemaVersion.
SchemaVersion::sv_major
uint32 sv_major
The major revision of the schema.
Definition: schema_version.h:47
SchemaVersion::SetSchemaVersionDetails
bool SetSchemaVersionDetails(SchemaVersion *sv_p, const int major, const int minor)
Set the details for a given SchemaVersion.
AllocateCurrentSchemaVersion
SchemaVersion * AllocateCurrentSchemaVersion(void)
CURRENT_SCHEMA_VERSION_MINOR
const uint32 CURRENT_SCHEMA_VERSION_MINOR
The current minor revision of the Grassroots schema.
Definition: schema_version.h:110
GRASSROOTS_UTIL_API
#define GRASSROOTS_UTIL_API
Definition: grassroots_util_library.h:47
SchemaVersion::sv_version_s
char * sv_version_s
The version as a string this will be of the form.
Definition: schema_version.h:57
CURRENT_SCHEMA_VERSION_MAJOR
const uint32 CURRENT_SCHEMA_VERSION_MAJOR
The current major revision of the Grassroots schema.
Definition: schema_version.h:102