Guardtime KSI c SDK
tree_builder.h
Go to the documentation of this file.
1 /*
2  * Copyright 2013-2015 Guardtime, Inc.
3  *
4  * This file is part of the Guardtime client SDK.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License").
7  * You may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  * http://www.apache.org/licenses/LICENSE-2.0
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, CONDITIONS, OR OTHER LICENSES OF ANY KIND, either
13  * express or implied. See the License for the specific language governing
14  * permissions and limitations under the License.
15  * "Guardtime" and "KSI" are trademarks or registered trademarks of
16  * Guardtime, Inc., and no license to trademarks is granted; Guardtime
17  * reserves and retains all trademark rights.
18  */
19 
20 
21 #ifndef TREE_NODE_H_
22 #define TREE_NODE_H_
23 
24 #include "types.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
37 #define KSI_TREE_BUILDER_STACK_LEN 0x100
38 
43 
51 
60  unsigned level;
67 };
68 
76  int (*fn)(KSI_TreeNode *in, void *c, KSI_TreeNode **out);
78  void *c;
79 };
80 
82 #define KSI_TreeBuilderLeafProcessorList_append(lst, o) KSI_APPLY_TO_NOT_NULL((lst), append, ((lst), (o)))
83 #define KSI_TreeBuilderLeafProcessorList_remove(lst, pos, o) KSI_APPLY_TO_NOT_NULL((lst), removeElement, ((lst), (pos), (o)))
84 #define KSI_TreeBuilderLeafProcessorList_indexOf(lst, o, i) KSI_APPLY_TO_NOT_NULL((lst), indexOf, ((lst), (o), (i)))
85 #define KSI_TreeBuilderLeafProcessorList_insertAt(lst, pos, o) KSI_APPLY_TO_NOT_NULL((lst), insertAt, ((lst), (pos), (o)))
86 #define KSI_TreeBuilderLeafProcessorList_replaceAt(lst, pos, o) KSI_APPLY_TO_NOT_NULL((lst), replaceAt, ((lst), (pos), (o)))
87 #define KSI_TreeBuilderLeafProcessorList_elementAt(lst, pos, o) KSI_APPLY_TO_NOT_NULL((lst), elementAt, ((lst), (pos), (o)))
88 #define KSI_TreeBuilderLeafProcessorList_length(lst) (((lst) != NULL && (lst)->length != NULL) ? (lst)->length((lst)) : 0)
89 #define KSI_TreeBuilderLeafProcessorList_sort(lst, cmp) KSI_APPLY_TO_NOT_NULL((lst), sort, ((lst), (cmp)))
90 #define KSI_TreeBuilderLeafProcessorList_foldl(lst, foldCtx, foldFn) (((lst) != NULL) ? ( ((lst)->foldl != NULL) ? ((lst)->foldl((lst), (foldCtx), (foldFn)))) : KSI_INVALID_STATE) : KSI_OK)
91 
96  size_t ref;
109 };
110 
115 typedef struct KSI_TreeLeafHandle_st KSI_TreeLeafHandle;
117 #define KSI_TreeLeafHandleList_append(lst, o) KSI_APPLY_TO_NOT_NULL((lst), append, ((lst), (o)))
118 #define KSI_TreeLeafHandleList_remove(lst, pos, o) KSI_APPLY_TO_NOT_NULL((lst), removeElement, ((lst), (pos), (o)))
119 #define KSI_TreeLeafHandleList_indexOf(lst, o, i) KSI_APPLY_TO_NOT_NULL((lst), indexOf, ((lst), (o), (i)))
120 #define KSI_TreeLeafHandleList_insertAt(lst, pos, o) KSI_APPLY_TO_NOT_NULL((lst), insertAt, ((lst), (pos), (o)))
121 #define KSI_TreeLeafHandleList_replaceAt(lst, pos, o) KSI_APPLY_TO_NOT_NULL((lst), replaceAt, ((lst), (pos), (o)))
122 #define KSI_TreeLeafHandleList_elementAt(lst, pos, o) KSI_APPLY_TO_NOT_NULL((lst), elementAt, ((lst), (pos), (o)))
123 #define KSI_TreeLeafHandleList_length(lst) (((lst) != NULL && (lst)->length != NULL) ? (lst)->length((lst)) : 0)
124 #define KSI_TreeLeafHandleList_sort(lst, cmp) KSI_APPLY_TO_NOT_NULL((lst), sort, ((lst), (cmp)))
125 #define KSI_TreeLeafHandleList_foldl(lst, foldCtx, foldFn) (((lst) != NULL) ? ( ((lst)->foldl != NULL) ? ((lst)->foldl((lst), (foldCtx), (foldFn)))) : KSI_INVALID_STATE) : KSI_OK)
126 
128 
142 
147 void KSI_TreeNode_free(KSI_TreeNode *node);
148 
155 
165 
170 
180 
187 
198 
209 
217 
222 #ifdef __cplusplus
223 }
224 #endif
225 
226 #endif /* TREE_NODE_H_ */
int KSI_TreeBuilder_addMetaData(KSI_TreeBuilder *builder, KSI_MetaData *metaData, int level, KSI_TreeLeafHandle **leaf)
KSI_DataHasher * hsr
Definition: tree_builder.h:108
unsigned level
Definition: tree_builder.h:60
void * c
Definition: tree_builder.h:78
int KSI_TreeLeafHandle_getAggregationChain(const KSI_TreeLeafHandle *handle, KSI_AggregationHashChain **chain)
Definition: tree_builder.h:69
size_t ref
Definition: tree_builder.h:96
KSI_HashAlgorithm algo
Definition: tree_builder.h:100
void KSI_TreeBuilder_free(KSI_TreeBuilder *builder)
#define KSI_DEFINE_REF(typ)
Definition: types_base.h:56
struct KSI_DataHash_st KSI_DataHash
Definition: hash.h:52
Definition: tree_builder.h:52
struct KSI_TreeLeafHandle_st KSI_TreeLeafHandle
Definition: tree_builder.h:115
enum KSI_HashAlgorithm_en KSI_HashAlgorithm
KSI_DataHash * hash
Definition: tree_builder.h:56
KSI_CTX * ctx
Definition: tree_builder.h:54
KSI_CTX * ctx
Definition: tree_builder.h:94
KSI_TreeNode * parent
Definition: tree_builder.h:62
KSI_TreeNode * rootNode
Definition: tree_builder.h:98
Definition: tree_builder.h:92
void KSI_TreeLeafHandle_free(KSI_TreeLeafHandle *handle)
void KSI_TreeNode_free(KSI_TreeNode *node)
#define KSI_DEFINE_LIST(type)
Definition: list.h:146
#define KSI_TREE_BUILDER_STACK_LEN
Definition: tree_builder.h:37
KSI_MetaData * metaData
Definition: tree_builder.h:58
struct KSI_CTX_st KSI_CTX
Definition: types_base.h:124
int KSI_TreeBuilder_close(KSI_TreeBuilder *builder)
struct KSI_AggregationHashChain_st KSI_AggregationHashChain
Definition: types.h:130
int KSI_TreeNode_new(KSI_CTX *ctx, KSI_DataHash *hash, KSI_MetaData *metaData, int level, KSI_TreeNode **node)
KSI_TreeNode * rightChild
Definition: tree_builder.h:66
struct KSI_DataHasher_st KSI_DataHasher
Definition: hash.h:46
KSI_TreeNode * leftChild
Definition: tree_builder.h:64
int KSI_TreeBuilder_new(KSI_CTX *ctx, KSI_HashAlgorithm algo, KSI_TreeBuilder **builder)
struct KSI_MetaData_st KSI_MetaData
Definition: types.h:42
#define KSI_LIST(type)
Definition: list.h:43
int KSI_TreeBuilder_addDataHash(KSI_TreeBuilder *builder, KSI_DataHash *hsh, int level, KSI_TreeLeafHandle **leaf)