Main Page | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

statement.h

Go to the documentation of this file.
00001 /**********************************************************************
00002  *
00003  * Verball Model Storage Library, Common Information Model Library 
00004  * for integration of Intelligent Services.
00005  * Copyright (C) 2005 Nikita Vinokurov, Orgway LLC.
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; 
00010  * version 2.1 of the License.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, 
00020  * Boston, MA  02110-1301  USA
00021  *
00022  * $Id: statement.h,v 1.16 2006/12/10 10:21:27 yagel Exp $
00023  **********************************************************************/
00024 
00025 #ifndef _STATEMENT_H_
00026 #define _STATEMENT_H_
00027 
00028 #include "node.h"
00029 #include <time.h>
00030 
00057 typedef enum  {
00059     NO_MASK = 0,
00061     CONTEXT_MASK = 1,
00063     PREDICATE_MASK = 2,
00065     SUBJECT_MASK = 4,
00067     OBJECT_MASK = 8,
00069     MASK_ALL = 15
00070 } statement_mask;
00071 
00074 typedef enum {
00081     STATEMENT_OP_UNSET = 0,
00087     STATEMENT_OP_SET = 1,
00091     STATEMENT_OP_UNDEF = 2
00092 } statement_op;
00093 
00094 typedef enum {
00095     STATEMENT_RETURN_LIE = 1,
00096     STATEMENT_SET_LIE = 1,
00097 } ex_flags;
00098 
00104 typedef struct _statement {
00105     Node context; 
00106     Node predicate; 
00107     Node subject; 
00108     Node object; 
00109     int mask; 
00114     statement_op operation;
00117     statement_op prev;
00118     time_t start;
00119     time_t end;
00120     time_t time;
00122     struct _statement *next;
00124     struct _statement *last;
00126     struct _statement *previous;
00127 } Statement;
00128 
00129 #ifdef __cplusplus
00130 extern "C"
00131 {
00132 
00133 #endif/* __cplusplus */
00134 
00136 STORAGE_TYPE
00137 Statement *statement_new();
00138 
00143 STORAGE_TYPE
00144 Statement *statement_create(const Node *context, const Node *predicate, const Node *subject, const Node *object); 
00145 
00150 STORAGE_TYPE 
00151 Statement *statement_clone(const Statement *src);
00152 
00155 STORAGE_TYPE
00156 Statement* stmt_from_strings(const char* c, const char* p, const char* s, const char* o );
00157 
00161 STORAGE_TYPE 
00162 Statement *statement_create_with_op(const Node *c, const Node *p, const Node *s, const Node *o, statement_op op); 
00163 
00164 
00168 STORAGE_TYPE void statement_free(Statement *stmt);
00169 
00170 
00174 STORAGE_TYPE void statement_clear(Statement *stmt);
00175 
00176 
00177 STORAGE_TYPE void statement_init(Statement *stmt, 
00178                                  const Node *c,
00179                                  const Node *p,
00180                                  const Node *s,
00181                                  const Node *o);
00182 
00186 STORAGE_TYPE void stmt_init_from_strings(Statement *stmt,
00187                                  const char *c,
00188                                  const char *p,
00189                                  const char *s,
00190                                  const char *o);
00191 
00195 STORAGE_TYPE 
00196 Statement *statement_set_op(Statement *stmt, statement_op operation);
00197 
00201 STORAGE_TYPE
00202 statement_op statement_get_op(const Statement *stmt);
00203 
00206 STORAGE_TYPE void statement_set_context(Statement *stmt, const Node *context);
00207 
00210 STORAGE_TYPE void statement_set_predicate(Statement *stmt, const Node *predicate);
00211 
00214 STORAGE_TYPE void statement_set_subject(Statement *stmt, const Node *subject);
00215 
00218 STORAGE_TYPE void statement_set_object(Statement *stmt, const Node *object);
00219 
00222 STORAGE_TYPE
00223 void statement_set_mask(Statement *stmt, int mask);
00224 
00230 STORAGE_TYPE 
00231 int statement_match(const Statement *mask, const Statement *stmt);
00232 
00234 STORAGE_TYPE
00235 const Node *statement_get_context(const Statement *stmt);
00236 
00238 STORAGE_TYPE
00239 const Node *statement_get_predicate(const Statement *stmt);
00240 
00242 STORAGE_TYPE
00243 const Node *statement_get_subject(const Statement *stmt);
00244 
00246 STORAGE_TYPE
00247 const Node *statement_get_object(const Statement *stmt);
00248 
00250 STORAGE_TYPE
00251 int statement_get_mask(const Statement *stmt);
00252 
00253 
00258 STORAGE_TYPE
00259 void statement_result_append(Statement **result, Statement *s);
00260 
00264 STORAGE_TYPE
00265 void statement_result_remove(Statement **result, Statement *stmt);
00266 
00267 STORAGE_TYPE
00268 unsigned int statement_result_count(Statement *result);
00269 
00278 STORAGE_TYPE
00279 void statement_result_compact(unsigned *count, Statement ***result);
00280 
00283 STORAGE_TYPE
00284 void statement_result_free(Statement **result);
00285 
00289 STORAGE_TYPE
00290 int statement_result_pop(Statement **result, Statement *head);
00291 
00294 STORAGE_TYPE
00295 void statement_swap_op(Statement *op); 
00296 
00297 
00298 STORAGE_TYPE
00299 void statement_set_start(Statement *stmt, time_t t);
00300 
00301 STORAGE_TYPE
00302 void statement_set_end(Statement *stmt, time_t t);
00303 
00304 STORAGE_TYPE
00305 time_t statement_get_start(const Statement *stmt);
00306 
00307 STORAGE_TYPE
00308 time_t statement_get_end(const Statement *stmt);
00309 
00310 #ifdef __cplusplus
00311 }
00312 #endif/* __cplusplus */
00313 
00314 #endif /* _STATEMENT_H_ */
00315 #ifdef DMALLOC
00316 #include<dmalloc.h>
00317 #endif

Generated on Wed Dec 27 16:52:18 2006 for VRB Online Server by  doxygen 1.4.4