00001
00002 #include "pup.h"
00003
00004 #include "register.h"
00005
00006 #ifndef DEBUG_CONV_PLUSPLUS_H
00007 #define DEBUG_CONV_PLUSPLUS_H
00008
00015 class CpdListAccessor {
00016 protected:
00022 void beginItem(PUP::er &p,int itemNo);
00024 bool checkBound;
00025 public:
00026 CpdListAccessor() : checkBound(true) {}
00027 virtual ~CpdListAccessor();
00029 virtual const char *getPath(void) const =0;
00031 virtual size_t getLength(void) const =0;
00033 virtual bool checkBoundary(void) const { return checkBound; }
00035 virtual void pup(PUP::er &p,CpdListItemsRequest &req) =0;
00036 };
00037
00043 void CpdListRegister(CpdListAccessor *acc);
00044
00045 class CpdListAccessor_c : public CpdListAccessor {
00046 const char *path;
00047 CpdListLengthFn_c lenFn;
00048 void *lenParam;
00049 CpdListItemsFn_c itemsFn;
00050 void *itemsParam;
00051 public:
00052 CpdListAccessor_c(const char *path_,
00053 CpdListLengthFn_c lenFn_,void *lenParam_,
00054 CpdListItemsFn_c itemsFn_,void *itemsParam_,bool checkBoundary_=true):
00055 path(path_), lenFn(lenFn_), lenParam(lenParam_),
00056 itemsFn(itemsFn_), itemsParam(itemsParam_) {checkBound = checkBoundary_;}
00057 CpdListAccessor_c(const CpdListAccessor_c &p);
00058 void operator=(const CpdListAccessor_c &p);
00059
00060 virtual const char *getPath(void) const {return path;}
00061 virtual size_t getLength(void) const {return (*lenFn)(lenParam);}
00062 virtual void pup(PUP::er &p,CpdListItemsRequest &req) {
00063 (itemsFn)(itemsParam,(pup_er *)&p,&req);
00064 }
00065 };
00066
00072 template <class T>
00073 class CpdSimpleListAccessor : public CpdListAccessor {
00074 public:
00077 typedef void (*pupFn)(PUP::er &p,int itemNo);
00078 private:
00079 const char *path;
00080 CkRegisteredInfo<T> *info;
00081 pupFn pfn;
00082 public:
00092 CpdSimpleListAccessor(const char *path_, CkRegisteredInfo<T> *info_, pupFn pfn_)
00093 :path(path_),info(info_),pfn(pfn_) { }
00094 virtual ~CpdSimpleListAccessor() {}
00095 virtual const char *getPath(void) const { return path; }
00096 virtual size_t getLength(void) const { return info->size(); }
00097 virtual void pup(PUP::er &p,CpdListItemsRequest &req) {
00098 for (int i = req.lo; i < req.hi; i++) {
00099 beginItem(p, i);
00100 (*pfn)(p, i);
00101 }
00102 }
00103 };
00104
00105 #endif