providers_state_table.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  * providers_state_table.h
23  *
24  * Created on: 6 May 2016
25  * Author: tyrrells
26  */
27 
28 #ifndef SRC_NETWORK_SRC_PROVIDERS_STATE_TABLE_H_
29 #define SRC_NETWORK_SRC_PROVIDERS_STATE_TABLE_H_
30 
32 #include "json_tools.h"
33 #include "json_util.h"
34 #include "grassroots_server.h"
35 
36 
49 typedef struct ProvidersStateTable
50 {
52  json_t *pst_values_p;
54 
55 
56 
57 #ifdef __cplusplus
58 extern "C"
59 {
60 #endif
61 
62 
76 GRASSROOTS_SERVICE_API ProvidersStateTable *AllocateProvidersStateTable (const json_t *req_p);
77 
78 
85 GRASSROOTS_SERVICE_API void FreeProvidersStateTable (ProvidersStateTable *providers_p);
86 
87 
102 GRASSROOTS_SERVICE_API ProvidersStateTable *GetInitialisedProvidersStateTable (const json_t *req_p, LinkedList *services_p, GrassrootsServer *grassroots_p);
103 
104 GRASSROOTS_SERVICE_API ProvidersStateTable *GetInitialisedProvidersStateTableForSingleService (const json_t *req_p, const char * const server_uri_s, const char * const service_s);
120 
121 
131 GRASSROOTS_SERVICE_API bool AddToProvidersStateTable (ProvidersStateTable *providers_p, const char *server_uri_s, const char *service_s);
132 
133 
143 GRASSROOTS_SERVICE_API bool IsServiceInProvidersStateTable (const ProvidersStateTable *providers_p, const char *server_uri_s, const char *service_s);
144 
145 
153 GRASSROOTS_SERVICE_API json_t *GetProvidersStateTableAsJSON (const ProvidersStateTable *providers_p);
154 
155 
171 GRASSROOTS_SERVICE_API json_t *GetAvailableServicesRequestForAllProviders (const ProvidersStateTable * providers_p, UserDetails *user_p, const SchemaVersion * const sv_p);
172 
173 
174 
184 GRASSROOTS_SERVICE_API bool AddServicesListToProvidersStateTable (ProvidersStateTable *providers_p, LinkedList *services_p, GrassrootsServer *grassroots_p);
185 
186 
199 GRASSROOTS_SERVICE_API bool AddProvidersStateTableToRequest (const ProvidersStateTable * providers_p, json_t *req_p);
200 
201 
212 GRASSROOTS_SERVICE_API bool InitProvidersStateTableFromRequest (ProvidersStateTable * const providers_p, const json_t * const req_p);
213 
214 
222 GRASSROOTS_SERVICE_API bool ClearProvidersStateTable (ProvidersStateTable *providers_p);
223 
224 
240 GRASSROOTS_SERVICE_API bool ReinitProvidersStateTable (ProvidersStateTable *providers_p, const json_t * const req_p, const char *server_uri_s, const char *service_name_s);
241 
242 
243 #ifdef __cplusplus
244 }
245 #endif
246 
247 
248 #endif /* SRC_NETWORK_SRC_PROVIDERS_STATE_TABLE_H_ */
bool ReinitProvidersStateTable(ProvidersStateTable *providers_p, const json_t *const req_p, const char *server_uri_s, const char *service_name_s)
Clear a given ProvidersStateTable and add the details from a json request and a given Server-Service ...
void FreeProvidersStateTable(ProvidersStateTable *providers_p)
Deallocate a ProvidersStateTable.
This is a datatype to store the versioning details for the Grassroots JSON schema that is being used.
Definition: schema_version.h:44
json_t * GetProvidersStateTableAsJSON(const ProvidersStateTable *providers_p)
Get the json representation of a ProvidersStateTable.
bool ClearProvidersStateTable(ProvidersStateTable *providers_p)
Clear all of the servers and services that are being tracked within a ProvidersStateTable.
A doubly-linked list that can be traversed in either direction.
Definition: linked_list.h:56
bool IsServiceInProvidersStateTable(const ProvidersStateTable *providers_p, const char *server_uri_s, const char *service_s)
Check whether a given server and service are in a ProvidersStateTable.
bool AddProvidersStateTableToRequest(const ProvidersStateTable *providers_p, json_t *req_p)
Add the details to a json request to get the list of all available Services on a Server making sure n...
ProvidersStateTable * GetInitialisedProvidersStateTableForSingleService(const json_t *req_p, const char *const server_uri_s, const char *const service_s)
Create a new ProvidersStateTable and populate it with any details within a specified json request and...
ProvidersStateTable * GetInitialisedProvidersStateTable(const json_t *req_p, LinkedList *services_p, GrassrootsServer *grassroots_p)
Create a new ProvidersStateTable and populate it with any details within a specified json request and...
A datatype to store user credentials.
Definition: user_details.h:76
This is a datatype that is used to keep track of which servers and services have already been process...
Definition: providers_state_table.h:49
ProvidersStateTable * AllocateProvidersStateTable(const json_t *req_p)
Allocate a ProvidersStateTable and populate it with any details within a specified json request.
bool AddServicesListToProvidersStateTable(ProvidersStateTable *providers_p, LinkedList *services_p, GrassrootsServer *grassroots_p)
Add a list of Services for this Server to a ProvidersStateTable.
bool AddToProvidersStateTable(ProvidersStateTable *providers_p, const char *server_uri_s, const char *service_s)
Add a server and service to a ProvidersStateTable.
Definition: grassroots_server.h:44
bool InitProvidersStateTableFromRequest(ProvidersStateTable *const providers_p, const json_t *const req_p)
Add the details from a json request to a given ProvidersStateTable.
json_t * GetAvailableServicesRequestForAllProviders(const ProvidersStateTable *providers_p, UserDetails *user_p, const SchemaVersion *const sv_p)
Create a json request that to get the list of all available Services making sure not to duplicate any...