libdas2
das2 core C utilities
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
node.h
1 /* Copyright (C) 2018 Chris Piker <chris-piker@uiowa.edu>
2  *
3  * This file is part of libdas2, the Core Das2 C Library.
4  *
5  * Libdas2 is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU Lesser General Public License version 2.1 as published
7  * by the Free Software Foundation.
8  *
9  * Libdas2 is distributed in the hope that it will be useful, but WITHOUT ANY
10  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * version 2.1 along with libdas2; if not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef _das_node_h_
19 #define _das_node_h_
20 
21 #include <das2/credentials.h>
22 #include <das2/array.h>
23 #include <das2/json.h>
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 
30 
125 /* Defines for common path_uri's */
126 #define D2URI_ROOT "tag:das2.org,2012:"
127 #define D2URI_SITES D2URI_ROOT "site"
128 #define D2URI_SITE_UIOWA D2URI_SITES ":/uiowa"
129 
130 /* Defines for common document fragments */
131 #define D2FRAG_TYPE "type"
132 #define D2FRAG_NAME "name"
133 #define D2FRAG_TITLE "title"
134 #define D2FRAG_DESC "description"
135 #define D2FRAG_SUB_PATHS "catalog"
136 #define D2FRAG_PATH_SEP "separator"
137 #define D2FRAG_SOURCES "sources"
138 #define D2FRAG_URLS "urls"
139 
140 /* Defines for common document string values */
141 #define D2CV_TYPE_CATALOG "Catalog"
142 #define D2CV_TYPE_COLLECTION "Collection"
143 #define D2CV_TYPE_STREAM "HttpStreamSrc"
144 #define D2CV_TYPE_TIMEAGG "FileTimeAgg"
145 #define D2CV_TYPE_SPASE "SpaseRecord"
146 #define D2Cv_TYPE_SPDF_MASTER "SpdfMasterCat"
147 
149 typedef enum das_node_type_enum {
150  d2node_inv = 0, d2node_catalog = 1, d2node_collection = 2,
151  d2node_stream_src = 3, d2node_file_agg = 4, d2node_spdf_cat = 5,
152  d2node_spase_cat = 6
153 } das_node_type_e;
154 
160 typedef struct das_node {
161  das_node_type_e nType; /* Holds the node type */
162  char sURL[512]; /* Holds source URL for this node */
163  char sPath[512]; /* Holds the Path URI for this node */
164  bool bIsRoot; /* True if a local root node (i.e. is a memory manager) */
165  void* pDom; /* A pointer to the document tokens. */
166 } DasNode;
167 
212  const char* sPathUri, DasCredMngr* pMgr, const char* sAgent
213 );
214 
259 DasNode* new_RootNode_url(const char* sUrl, const char* sPathUri,
260  DasCredMngr* pMgr, const char* sAgent);
261 
291  DasNode* pThis, const char* sRelPath, DasCredMngr* pMgr, const char* sAgent
292 );
293 
297 bool DasNode_isCatalog(const DasNode* pNode);
298 
302 bool DasNode_isStreamSrc(const DasNode* pNode);
303 
307 bool DasNode_isSpaseRec(const DasNode* pNode);
308 
312 bool DasNode_isSpdfCat(const DasNode* pNode);
313 
319 const char* DasNode_pathUri(const DasNode* pThis);
320 
328 const char* DasNode_srcUrl(const DasNode* pThis);
329 
338 das_node_type_e DasNode_type(const DasNode* pThis);
339 
347 const char* DasNode_name(const DasNode* pThis);
348 
352 const char* DasNode_title(const DasNode* pThis);
353 
354 
360 bool DasNode_isJson(const DasNode* pThis);
361 
369 const DasJdo* DasNode_getJdo(const DasNode* pThis, const char* sFragment);
370 
371 
382  const DasNode* pThis, enum das_json_type_e, const char* sFragment
383 );
384 
389 void del_RootNode(DasNode* pNode);
390 
391 
392 #ifdef __cplusplus
393 }
394 #endif
395 
396 #endif /* _das_catalog_h_ */
const char * DasNode_title(const DasNode *pThis)
Get the node short description, if provided.
const DasJdo * DasNode_getJdo(const DasNode *pThis, const char *sFragment)
Get a JSON document object at a fragment location in a node.
DasNode * new_RootNode_url(const char *sUrl, const char *sPathUri, DasCredMngr *pMgr, const char *sAgent)
Create a new root catalog node via direct URL.
das_json_type_e
The various types JSON values can be.
Definition: json.h:74
Credentials manager Handles a list of login credentials and supplies these as needed for network oper...
Definition: credentials.h:94
Base type for das2 catalog nodes.
Definition: node.h:160
A dynamic buffer with multi-dimensional array style access.
const char * DasNode_srcUrl(const DasNode *pThis)
Get the location from which this catalog node was read.
bool DasNode_isSpdfCat(const DasNode *pNode)
Determine if this node is an SPDF catalog.
Sheredom&#39;s json.h parser with global symbol name changes.
bool DasNode_isCatalog(const DasNode *pNode)
Returns true this node can contain sub nodes.
bool DasNode_isSpaseRec(const DasNode *pNode)
Determine if this node is a SPASE record.
DasNode * DasNode_subNode(DasNode *pThis, const char *sRelPath, DasCredMngr *pMgr, const char *sAgent)
Get a das2 catalog node contained item.
Handle storing credentials during a Das2 session and optionally save them to a file.
const char * DasNode_pathUri(const DasNode *pThis)
Get the path URI for this catalog node.
das_node_type_e DasNode_type(const DasNode *pThis)
Get the type of node This is a more specific question than the &#39;is&#39; functions below, which should probably be used instead so that application code can work in a &quot;duck-typing&quot; manner.
const DasJdo * DasNode_getJdoType(const DasNode *pThis, enum das_json_type_e, const char *sFragment)
Get a JSON document object of a particular type at a fragment location.
DasNode * new_RootNode(const char *sPathUri, DasCredMngr *pMgr, const char *sAgent)
Create a new root catalog node via a path URI.
JSON Dom Element.
Definition: json.h:152
void del_RootNode(DasNode *pNode)
Delete a root node freeing it&#39;s memory.
const char * DasNode_name(const DasNode *pThis)
Get the node title.
bool DasNode_isStreamSrc(const DasNode *pNode)
Determine if this node defines a das2 stream source.