libxcks  0.1.0.1
libxcks.cpp
Go to the documentation of this file.
1 /*
2  * libxcks
3  * Copyright (C) 2022 Julien Couot
4  *
5  * This program is free software: you can redistribute it and/or modify it
6  * under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or (at your
8  * option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
13  * License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this program. If not, see <https://www.gnu.org/licenses/>.
17  */
18 
25 //---------------------------------------------------------------------------
26 // #include <string> // Done in headers
27 
28 #include "libxcks/libxcks.hpp"
29 //---------------------------------------------------------------------------
30 
31 
33 using namespace std;
34 
35 
36 namespace libxcks
37 {
39 static void initialiseLibrary()
40 {
41  ChecksumFactory::initialise();
42 }
43 //---------------------------------------------------------------------------
44 
45 
47 static void cleanupLibrary()
48 {
49  ChecksumFactory::cleanUp();
50 }
51 //---------------------------------------------------------------------------
52 
53 
54 // Number of instances.
55 int LibXCKSInitialiser::nbInstances = 0;
56 
57 // Initialises libxcks.
58 LibXCKSInitialiser::LibXCKSInitialiser()
59 {
60  if (nbInstances++ == 0)
61  initialiseLibrary();
62 }
63 //---------------------------------------------------------------------------
64 
65 // Destructor.
66 LibXCKSInitialiser::~LibXCKSInitialiser()
67 {
68  if (--nbInstances == 0)
69  cleanupLibrary();
70 }
71 
72 } // namespace libxcks
73 //---------------------------------------------------------------------------
74 
75 
Entry point and convenience header of libxcks.