Main Page | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Related Pages

cxx_mpool.cpp

00001 /*-
00002  * See the file LICENSE for redistribution information.
00003  *
00004  * Copyright (c) 1997-2005
00005  *      Sleepycat Software.  All rights reserved.
00006  *
00007  * $Id: cxx_mpool.cpp,v 12.1 2005/06/16 20:21:02 bostic Exp $
00008  */
00009 
00010 #include "db_config.h"
00011 
00012 #include <errno.h>
00013 
00014 #include "db_cxx.h"
00015 #include "dbinc/cxx_int.h"
00016 
00017 #include "db_int.h"
00018 
00019 // Helper macros for simple methods that pass through to the
00020 // underlying C method. It may return an error or raise an exception.
00021 // Note this macro expects that input _argspec is an argument
00022 // list element (e.g., "char *arg") and that _arglist is the arguments
00023 // that should be passed through to the C method (e.g., "(mpf, arg)")
00024 //
00025 #define DB_MPOOLFILE_METHOD(_name, _argspec, _arglist, _retok)          \
00026 int DbMpoolFile::_name _argspec                                         \
00027 {                                                                       \
00028         int ret;                                                        \
00029         DB_MPOOLFILE *mpf = unwrap(this);                               \
00030                                                                         \
00031         if (mpf == NULL)                                                \
00032                 ret = EINVAL;                                           \
00033         else                                                            \
00034                 ret = mpf->_name _arglist;                              \
00035         if (!_retok(ret))                                               \
00036                 DB_ERROR(DbEnv::get_DbEnv(mpf->dbenv), \
00037                         "DbMpoolFile::"#_name, ret, ON_ERROR_UNKNOWN);  \
00038         return (ret);                                                   \
00039 }
00040 
00041 #define DB_MPOOLFILE_METHOD_VOID(_name, _argspec, _arglist)             \
00042 void DbMpoolFile::_name _argspec                                        \
00043 {                                                                       \
00044         DB_MPOOLFILE *mpf = unwrap(this);                               \
00045                                                                         \
00046         mpf->_name _arglist;                                            \
00047 }
00048 
00050 //                                                                    //
00051 //                            DbMpoolFile                             //
00052 //                                                                    //
00054 
00055 DbMpoolFile::DbMpoolFile()
00056 :       imp_(0)
00057 {
00058 }
00059 
00060 DbMpoolFile::~DbMpoolFile()
00061 {
00062 }
00063 
00064 int DbMpoolFile::close(u_int32_t flags)
00065 {
00066         DB_MPOOLFILE *mpf = unwrap(this);
00067         int ret;
00068         DbEnv *dbenv = DbEnv::get_DbEnv(mpf->dbenv);
00069 
00070         if (mpf == NULL)
00071                 ret = EINVAL;
00072         else
00073                 ret = mpf->close(mpf, flags);
00074 
00075         imp_ = 0;                   // extra safety
00076 
00077         // This may seem weird, but is legal as long as we don't access
00078         // any data before returning.
00079         delete this;
00080 
00081         if (!DB_RETOK_STD(ret))
00082                 DB_ERROR(dbenv, "DbMpoolFile::close", ret, ON_ERROR_UNKNOWN);
00083 
00084         return (ret);
00085 }
00086 
00087 DB_MPOOLFILE_METHOD(get, (db_pgno_t *pgnoaddr, u_int32_t flags, void *pagep),
00088     (mpf, pgnoaddr, flags, pagep), DB_RETOK_MPGET)
00089 DB_MPOOLFILE_METHOD(open,
00090     (const char *file, u_int32_t flags, int mode, size_t pagesize),
00091     (mpf, file, flags, mode, pagesize), DB_RETOK_STD)
00092 DB_MPOOLFILE_METHOD(put, (void *pgaddr, u_int32_t flags),
00093     (mpf, pgaddr, flags), DB_RETOK_STD)
00094 DB_MPOOLFILE_METHOD(set, (void *pgaddr, u_int32_t flags),
00095     (mpf, pgaddr, flags), DB_RETOK_STD)
00096 DB_MPOOLFILE_METHOD(get_clear_len, (u_int32_t *lenp),
00097     (mpf, lenp), DB_RETOK_STD)
00098 DB_MPOOLFILE_METHOD(set_clear_len, (u_int32_t len),
00099     (mpf, len), DB_RETOK_STD)
00100 DB_MPOOLFILE_METHOD(get_fileid, (u_int8_t *fileid),
00101     (mpf, fileid), DB_RETOK_STD)
00102 DB_MPOOLFILE_METHOD(set_fileid, (u_int8_t *fileid),
00103     (mpf, fileid), DB_RETOK_STD)
00104 DB_MPOOLFILE_METHOD(get_flags, (u_int32_t *flagsp),
00105     (mpf, flagsp), DB_RETOK_STD)
00106 DB_MPOOLFILE_METHOD(set_flags, (u_int32_t flags, int onoff),
00107     (mpf, flags, onoff), DB_RETOK_STD)
00108 DB_MPOOLFILE_METHOD(get_ftype, (int *ftypep),
00109     (mpf, ftypep), DB_RETOK_STD)
00110 DB_MPOOLFILE_METHOD(set_ftype, (int ftype),
00111     (mpf, ftype), DB_RETOK_STD)
00112 DB_MPOOLFILE_METHOD(get_lsn_offset, (int32_t *offsetp),
00113     (mpf, offsetp), DB_RETOK_STD)
00114 DB_MPOOLFILE_METHOD(set_lsn_offset, (int32_t offset),
00115     (mpf, offset), DB_RETOK_STD)
00116 DB_MPOOLFILE_METHOD(get_maxsize, (u_int32_t *gbytesp, u_int32_t *bytesp),
00117     (mpf, gbytesp, bytesp), DB_RETOK_STD)
00118 DB_MPOOLFILE_METHOD(set_maxsize, (u_int32_t gbytes, u_int32_t bytes),
00119     (mpf, gbytes, bytes), DB_RETOK_STD)
00120 DB_MPOOLFILE_METHOD(get_pgcookie, (DBT *dbt),
00121     (mpf, dbt), DB_RETOK_STD)
00122 DB_MPOOLFILE_METHOD(set_pgcookie, (DBT *dbt),
00123     (mpf, dbt), DB_RETOK_STD)
00124 DB_MPOOLFILE_METHOD(get_priority, (DB_CACHE_PRIORITY *priorityp),
00125     (mpf, priorityp), DB_RETOK_STD)
00126 DB_MPOOLFILE_METHOD(set_priority, (DB_CACHE_PRIORITY priority),
00127     (mpf, priority), DB_RETOK_STD)
00128 DB_MPOOLFILE_METHOD(sync, (),
00129     (mpf), DB_RETOK_STD)

Generated on Sun Dec 25 12:14:18 2005 for Berkeley DB 4.4.16 by  doxygen 1.4.2