Web Wispers 1.2.2 C++ Unit Test Coverage |
|
|
|
|
Branch data Line data Source code
1 : : /*
2 : : * Copyright 2006-2009 Savarese Software Research 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 : : * https://www.savarese.com/software/ApacheLicense-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 : : /**
18 : : * @file
19 : : * This header defines a class that initializes and releases SQLite3 library
20 : : * resources.
21 : : */
22 : :
23 : : #ifndef __SSRC_WSPR_INITIALIZE_LIBRARY_H
24 : : #define __SSRC_WSPR_INITIALIZE_LIBRARY_H
25 : :
26 : : #include <ssrc/wispers-packages.h>
27 : :
28 : : __BEGIN_NS_SQLITE3_INCLUDE
29 : : #include <sqlite3.h>
30 : : __END_NS_SQLITE3_INCLUDE
31 : :
32 : : __BEGIN_NS_SSRC_WSPR_DATABASE
33 : :
34 : : /**
35 : : * InitializeLibrary is a utility class whose constructor calls
36 : : * sqlite3_initialize() and whose destructor calls sqlie3_shutdown().
37 : : * Although it is not currently necessary to use this class and it
38 : : * would be desirable to hide this implementation detail, the
39 : : * SQLite library may in the future require explicit initialization
40 : : * of the library via sqlite3_initialize(). Therefore, it is recommended that
41 : : * all programs using the Database class instantiate InitializeLibrary
42 : : * at the beginning of their main(). That will guarantee that
43 : : * sqlite3_initialize() initializes the SQLite library before any database
44 : : * operations are performed and that sqlite3_shutdown() will be called
45 : : * before the program exits. This technique cannot be used for programs
46 : : * that continue to execute threads after main() terminates.
47 : : */
48 : : struct InitializeLibrary {
49 : : /**
50 : : * Initializes the database library by calling sqlite3_initialize().
51 : : */
52 : 23 : InitializeLibrary() {
53 : 23 : SQLite3::sqlite3_initialize();
54 : 23 : }
55 : : /**
56 : : * Releases all database library resources by calling sqlite3_shutdown().
57 : : */
58 : 23 : ~InitializeLibrary() {
59 : 23 : SQLite3::sqlite3_shutdown();
60 : 23 : }
61 : : };
62 : :
63 : : // A macro that can be used in conjunction with
64 : : // WSPR_CUSTOM_SERVICE_MAIN_WITH_INIT to initialize SQLite in a service program.
65 : : #define WSPR_DB_INIT_LIBRARY \
66 : : NS_SSRC_WSPR_DATABASE::InitializeLibrary WSPR_DB_INIT_LIBRARY_INSTANCE;
67 : :
68 : : __END_NS_SSRC_WSPR_DATABASE
69 : :
70 : : #endif
|
Copyright © 2017 Savarese Software Research Corporation. All rights reserved