Quantum++  v0.8.8
C++11 quantum computing library
init.h
Go to the documentation of this file.
1 /*
2  * Quantum++
3  *
4  * Copyright (c) 2013 - 2016 Vlad Gheorghiu (vgheorgh@gmail.com)
5  *
6  * This file is part of Quantum++.
7  *
8  * Quantum++ is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * Quantum++ is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with Quantum++. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
27 #ifndef CLASSES_INIT_H_
28 #define CLASSES_INIT_H_
29 
30 namespace qpp
31 {
32 
38 class Init final : public internal::Singleton<const Init> // const Singleton
39 {
40  friend class internal::Singleton<const Init>;
41 
42 private:
46  Init()
47  {
48  // on entry message
49  std::cout << ">>> Starting Quantum++..." << std::endl;
50 
51  // gets and displays current system time
52  std::time_t current_date = std::time(nullptr);
53  std::cout << ">>> " << std::ctime(&current_date) << std::endl;
54 
55  // set default output format and precision
56  std::cout << std::fixed; // use fixed format for nice formatting
57  // std::cout << std::scientific;
58  std::cout << std::setprecision(4); // only for fixed/scientific modes
59  }
60 
65  {
66  // on exit message
67  std::cout << std::endl << ">>> Exiting Quantum++..." << std::endl;
68 
69  // gets and displays current system time
70  std::time_t current_date = std::time(nullptr);
71  std::cout << ">>> " << std::ctime(&current_date);
72  }
73 }; /* class Init */
74 
75 } /* namespace qpp */
76 
77 #endif /* CLASSES_INIT_H_ */
Singleton policy class, used internally to implement the singleton pattern via CRTP (Curiously recurr...
Definition: singleton.h:77
Quantum++ main namespace.
Definition: codes.h:30
const Singleton class that performs additional initializations/cleanups
Definition: init.h:38
~Init()
Cleanups.
Definition: init.h:64
Init()
Additional initializations.
Definition: init.h:46