SyncBase.h

Go to the documentation of this file.
00001 /**
00002  * @file sync/SyncBase.h
00003  *  
00004  * Part of CCNx Sync.
00005  *
00006  * Copyright (C) 2011 Palo Alto Research Center, Inc.
00007  *
00008  * This library is free software; you can redistribute it and/or modify it
00009  * under the terms of the GNU Lesser General Public License version 2.1
00010  * as published by the Free Software Foundation.
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00014  * Lesser General Public License for more details. You should have received
00015  * a copy of the GNU Lesser General Public License along with this library;
00016  * if not, write to the Free Software Foundation, Inc., 51 Franklin Street,
00017  * Fifth Floor, Boston, MA 02110-1301 USA.
00018  */
00019 
00020 
00021 #ifndef CCN_SyncBase
00022 #define CCN_SyncBase
00023 
00024 #include <sys/types.h>
00025 #include <stdint.h>
00026 #include <stdio.h>
00027 #include <ccn/ccn.h>
00028 #include <ccn/indexbuf.h>
00029 #include <ccn/schedule.h>
00030 #include <ccn/uri.h>
00031 #include <ccnr/ccnr_private.h>
00032 
00033 #include "SyncMacros.h"
00034 
00035 // Incomplete types for opaque structures.
00036 struct ccn_schedule;
00037 struct ccnr_handle;
00038 struct ccn;
00039 struct SyncPrivate;
00040 
00041 // A SyncBase is the common data for a Sync Agent.  Each Sync Agent supports a
00042 // list of collections. 
00043 
00044 struct SyncBaseStruct {
00045     struct SyncErrStruct *errList;  // private data for Sync
00046     struct SyncPrivate *priv;       // opaque data for Repo (from Repo)
00047     struct ccnr_handle *ccnr;       // the ccnr handle to use (from Repo)
00048     struct ccn *ccn;                // the ccn handle to use (from Repo)
00049     struct ccn_schedule *sched;     // the scheduler to use (from Repo)
00050     int debug;                      // higher gives more output, 0 gives none
00051     unsigned lastRootId;            // last root id assigned (0 is not used)
00052     ccnr_hwm highWater;             // high water mark for accession numbers
00053 };
00054 
00055 // Error support
00056 
00057 enum SyncErrCode {
00058     SyncErrCode_none = 0,       // no error
00059     SyncErrCode_bug = 1,        // internal bug
00060     SyncErrCode_caller = 2      // caller error (bad args, wrong state, ...)
00061 };
00062 
00063 struct SyncErrStruct {
00064     struct SyncErrStruct *next;
00065     enum SyncErrCode code;
00066     char * file;
00067     int line;
00068 };
00069 
00070 // add a new error record
00071 // this routine should be called from the SET_SYNC_ERR macro
00072 void SyncSetErrInner(struct SyncBaseStruct *base,
00073                      enum SyncErrCode code,
00074                      char * file, int line);
00075 
00076 // clear all the existing error records
00077 void SyncClearErr(struct SyncBaseStruct *base);
00078 
00079 // Basic object support
00080 
00081 // allocate and initialize a new sync base
00082 struct SyncBaseStruct *
00083 SyncNewBase(struct ccnr_handle *ccnr,
00084             struct ccn *ccn,
00085             struct ccn_schedule *sched);
00086 
00087 // initialize a sync base
00088 void
00089 SyncInit(struct SyncBaseStruct *bp);
00090 
00091 // free up the resources for the sync base
00092 // called by Repo when shutting down
00093 // (no callbacks possible at this point)
00094 void
00095 SyncFreeBase(struct SyncBaseStruct **bp);
00096 
00097 // Enumeration support
00098 // called by Repo
00099 // name = NULL indicates end of enumeration
00100 // returns -1 to terminate, 0 to continue
00101 int
00102 SyncNotifyContent(struct SyncBaseStruct *base,
00103                   int enumeration,
00104                   ccnr_accession item,
00105                   struct ccn_charbuf *name);
00106 
00107 // shutdown a sync base
00108 void
00109 SyncShutdown(struct SyncBaseStruct *bp);
00110 
00111 #endif

Generated on Thu Feb 16 00:44:01 2012 for Content-Centric Networking in C by  doxygen 1.5.6