servlib/storage/SQLBundleStore.h
changeset 0 2b3e5ec03512
equal deleted inserted replaced
-1:000000000000 0:2b3e5ec03512
       
     1 /*
       
     2  *    Copyright 2004-2006 Intel Corporation
       
     3  * 
       
     4  *    Licensed under the Apache License, Version 2.0 (the "License");
       
     5  *    you may not use this file except in compliance with the License.
       
     6  *    You may obtain a copy of the License at
       
     7  * 
       
     8  *        http://www.apache.org/licenses/LICENSE-2.0
       
     9  * 
       
    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 OR CONDITIONS OF ANY KIND, either express or implied.
       
    13  *    See the License for the specific language governing permissions and
       
    14  *    limitations under the License.
       
    15  */
       
    16 
       
    17 #ifndef _SQL_BUNDLE_STORE_H_
       
    18 #define _SQL_BUNDLE_STORE_H_
       
    19 
       
    20 #include <sys/time.h>
       
    21 #include "BundleStore.h"
       
    22 
       
    23 namespace dtn {
       
    24 
       
    25 class SQLImplementation;
       
    26 class SQLStore;
       
    27 
       
    28 /**
       
    29  * Implementation of a BundleStore that uses an underlying SQL
       
    30  * database.
       
    31  */
       
    32 
       
    33 class SQLBundleStore : public BundleStore {
       
    34 public:
       
    35     /**
       
    36      * Constructor -- takes as a parameter an abstract pointer to the
       
    37      * underlying storage technology so as to implement the basic
       
    38      * methods. The table_name identifies the table in which all bundles
       
    39      * will be stored
       
    40      */
       
    41     SQLBundleStore(oasys::SQLImplementation* db, const char* table_name = "bundles");
       
    42     
       
    43     /**
       
    44      * Virtual methods inheritied from BundleStore
       
    45      */
       
    46     Bundle* get(int bundle_id) ;
       
    47     bool    insert(Bundle* bundle);
       
    48     bool    update(Bundle* bundle);
       
    49     bool    del(int bundle_id) ;
       
    50     int     delete_expired(const time_t now);
       
    51     bool    is_custodian(int bundle_id);
       
    52     
       
    53 private:
       
    54     
       
    55     /**
       
    56      * The SQLStore instance used to store all the bundles.
       
    57      */
       
    58     SQLStore* store_;
       
    59 };
       
    60 } // namespace dtn
       
    61 
       
    62 #endif /* _SQL_BUNDLE_STORE_H_ */