|
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_REGISTRATION_STORE_H_ |
|
18 #define _SQL_REGISTRATION_STORE_H_ |
|
19 |
|
20 #include "RegistrationStore.h" |
|
21 |
|
22 namespace oasys { |
|
23 class SQLImplementation; |
|
24 } |
|
25 |
|
26 namespace dtn { |
|
27 |
|
28 class SQLStore; |
|
29 |
|
30 /** |
|
31 * Implementation of RegistrationStore that uses an underlying SQL database. |
|
32 */ |
|
33 class SQLRegistrationStore : public RegistrationStore { |
|
34 public: |
|
35 /** |
|
36 * Constructor |
|
37 */ |
|
38 SQLRegistrationStore(oasys::SQLImplementation* impl, |
|
39 const char* table_name = "registration"); |
|
40 |
|
41 /** |
|
42 * Destructor |
|
43 */ |
|
44 virtual ~SQLRegistrationStore(); |
|
45 |
|
46 /** |
|
47 * Load in the whole database of registrations, populating the |
|
48 * given list. |
|
49 */ |
|
50 virtual void load(RegistrationList* reg_list); |
|
51 |
|
52 /** |
|
53 * Add a new registration to the database. Returns true if the |
|
54 * registration is successfully added, false on error. |
|
55 */ |
|
56 virtual bool add(Registration* reg); |
|
57 |
|
58 /** |
|
59 * Remove the registration from the database, returns true if |
|
60 * successful, false on error. |
|
61 */ |
|
62 virtual bool del(Registration* reg); |
|
63 |
|
64 /** |
|
65 * Update the registration in the database. Returns true on |
|
66 * success, false if there's no matching registration or on error. |
|
67 */ |
|
68 virtual bool update(Registration* reg); |
|
69 |
|
70 protected: |
|
71 SQLStore* store_; |
|
72 }; |
|
73 } // namespace dtn |
|
74 |
|
75 #endif /* _SQL_REGISTRATION_STORE_H_ */ |