|
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 _LINK_STORE_H_ |
|
18 #define _LINK_STORE_H_ |
|
19 |
|
20 #include <oasys/debug/DebugUtils.h> |
|
21 #include <oasys/serialize/TypeShims.h> |
|
22 #include <oasys/storage/InternalKeyDurableTable.h> |
|
23 #include <oasys/util/Singleton.h> |
|
24 |
|
25 namespace dtn { |
|
26 |
|
27 class Link; |
|
28 |
|
29 /** |
|
30 * Convenience typedef for the oasys adaptor that implements the link |
|
31 * durable store. |
|
32 */ |
|
33 typedef oasys::InternalKeyDurableTable< |
|
34 oasys::StringShim, std::string, Link> LinkStoreImpl; |
|
35 |
|
36 /** |
|
37 * The class for link storage. |
|
38 */ |
|
39 class LinkStore : public oasys::Singleton<LinkStore, false>, |
|
40 public LinkStoreImpl { |
|
41 public: |
|
42 /** |
|
43 * Boot time initializer that takes as a parameter the storage |
|
44 * configuration to use. |
|
45 */ |
|
46 static int init(const oasys::StorageConfig& cfg, |
|
47 oasys::DurableStore* store) |
|
48 { |
|
49 if (instance_ != NULL) { |
|
50 PANIC("LinkStore::init called multiple times"); |
|
51 } |
|
52 instance_ = new LinkStore(); |
|
53 return instance_->do_init(cfg, store); |
|
54 } |
|
55 |
|
56 /** |
|
57 * Constructor. |
|
58 */ |
|
59 LinkStore(); |
|
60 |
|
61 /** |
|
62 * Return true if initialization has completed. |
|
63 */ |
|
64 static bool initialized() { return (instance() != NULL); } |
|
65 }; |
|
66 |
|
67 } // namespace dtn |
|
68 |
|
69 #endif /* _LINK_STORE_H_ */ |