FMT 0.9.8
Forest management tools for forest planning
Loading...
Searching...
No Matches
FMTobject.hpp
Go to the documentation of this file.
1/*
2Copyright (c) 2019 Gouvernement du Québec
3
4SPDX-License-Identifier: LiLiQ-R-1.1
5License-Filename: LICENSES/EN/LiLiQ-R11unicode.txt
6*/
7
8#ifndef FMTobject_H_INCLUDED
9#define FMTobject_H_INCLUDED
10
11#ifndef NOMINMAX
12 #define NOMINMAX
13#endif // !NOMINMAX
14
15#include <boost/serialization/shared_ptr.hpp>
16#include <boost/serialization/nvp.hpp>
17#include <boost/serialization/export.hpp>
18#include "FMTexception.hpp"
19#include <memory>
20#include <chrono>
21#include <vector>
22
23#if defined _MSC_VER || __MINGW64__ || __CYGWIN__
24
25#else
26 #include <boost/dll/runtime_symbol_info.hpp>
27#endif
28
29namespace Exception
30{
31 class FMTexceptionhandler;
32}
33
34namespace Logging
35{
36 class FMTlogger;
37}
38
39
40
41namespace Core
42{
43// DocString: FMTobject
50 {
51 // DocString: FMTobject::serialize
55 friend class boost::serialization::access;
56 template<class Archive>
57 void serialize(Archive& ar, const unsigned int version)
58 {
59 //ar & BOOST_SERIALIZATION_NVP(_exhandler);
60 //ar & BOOST_SERIALIZATION_NVP(_logger);
61 //ar & BOOST_SERIALIZATION_NVP(_section);
62 }
63 protected:
64 // DocString: FMTobject::_exhandler
66 static std::shared_ptr<Exception::FMTexceptionhandler> _exhandler;
67 // DocString: FMTobject::_logger
69 static std::shared_ptr<Logging::FMTlogger> _logger;
70 // DocString: FMTobject:: forcesave
74 template<class Archive>
75 void forcesave(Archive& ar, const unsigned int version) const
76 {
77 //ar & BOOST_SERIALIZATION_NVP(_exhandler);
78 //ar & BOOST_SERIALIZATION_NVP(_logger);
79 //ar & BOOST_SERIALIZATION_NVP(_section);
80 }
81 // DocString: FMTobject:: forceload
85 template<class Archive>
86 void forceload(Archive& ar, const unsigned int version)
87 {
88 //ar & BOOST_SERIALIZATION_NVP(_exhandler);
89 //ar & BOOST_SERIALIZATION_NVP(_logger);
90 setdefaultlogger();
91 setdefaultexceptionhandler();
92 //ar & BOOST_SERIALIZATION_NVP(_section);
93 }
94 // DocString: FMTobject::checksignals
98 void checksignals() const;
99 // DocString: FMTobject::setCPLhandler
104 // DocString: FMTobject::getclock
108 static std::chrono::time_point<std::chrono::high_resolution_clock> getclock();
109 // DocString: FMTobject::getduration
113 template<class chrono>
114 static double getduration(const std::chrono::time_point<std::chrono::high_resolution_clock>& startclock);
115 // DocString: FMTobject::getdurationinseconds
119 static std::string getdurationinseconds(const std::chrono::time_point<std::chrono::high_resolution_clock>& startclock);
120 public:
121 // DocString: FMTobject::getruntimelocation
125 static std::string getruntimelocation();
126 // DocString: FMTobject::getavailablememory
130 static unsigned long long getavailablememory();
131 // DocString: FMTobject()
136 // DocString: ~FMTobject()
140 virtual ~FMTobject();
141 // DocString: FMTobject(const std::shared_ptr<Exception::FMTexceptionhandler>)
146 FMTobject(const std::shared_ptr<Exception::FMTexceptionhandler> exhandler);
147 // DocString: FMTobject(const FMTobject&)
151 FMTobject(const FMTobject& rhs);
152 // DocString: FMTobject::operator=
156 FMTobject& operator = (const FMTobject& rhs);
157 // DocString: FMTobject::passinlogger
161 virtual void passinlogger(const std::shared_ptr<Logging::FMTlogger>& logger);
162 // DocString: FMTobject::passinexceptionhandler
166 void passinexceptionhandler(const std::shared_ptr<Exception::FMTexceptionhandler>& exhandler);
167 // DocString: FMTobject::redirectlogtofile
171 void redirectlogtofile(const std::string& location);
172 // DocString: FMTobject::setdefaultlogger
176 virtual void setdefaultlogger();
177 // DocString: FMTobject::setquietlogger
181 virtual void setquietlogger();
182 // DocString: FMTobject::settasklogger
186 virtual void settasklogger();
187 // DocString: FMTobject::setdebuglogger
191 virtual void setdebuglogger();
192 // DocString: FMTobject::setdefaultexceptionhandler
197 // DocString: FMTobject::setquietexceptionhandler
202 // DocString: FMTobject::setdebugexceptionhandler
207 // DocString: FMTobject::setfreeexceptionhandler
212 // DocString: FMTobject::disablenestedexceptions
218 // DocString: FMTobject::enablenestedexceptions
224 // DocString: FMTobject::seterrorstowarnings
229 void seterrorstowarnings(const std::vector<Exception::FMTexc>& errors);
230 // DocString: FMTobject::setmaxwarningsbeforesilenced
234 void setmaxwarningsbeforesilenced(const size_t& maxwarningcount);
235
236 };
237}
238BOOST_SERIALIZATION_ASSUME_ABSTRACT(Core::FMTobject)
239BOOST_CLASS_TRACKING(Core::FMTobject, boost::serialization::track_always)
240BOOST_CLASS_EXPORT_KEY(Core::FMTobject)
241
242#endif
243
#define FMTEXPORT
Definition: FMTutility.hpp:92
Definition: FMTobject.hpp:50
void forcesave(Archive &ar, const unsigned int version) const
Definition: FMTobject.hpp:75
virtual void setquietlogger()
void seterrorstowarnings(const std::vector< Exception::FMTexc > &errors)
void enablenestedexceptions()
static std::string getruntimelocation()
void redirectlogtofile(const std::string &location)
static double getduration(const std::chrono::time_point< std::chrono::high_resolution_clock > &startclock)
static std::shared_ptr< Logging::FMTlogger > _logger
A shared pointer to the logger.
Definition: FMTobject.hpp:69
void setmaxwarningsbeforesilenced(const size_t &maxwarningcount)
void checksignals() const
void disablenestedexceptions()
FMTobject(const std::shared_ptr< Exception::FMTexceptionhandler > exhandler)
void setdebugexceptionhandler()
static unsigned long long getavailablememory()
void setquietexceptionhandler()
virtual ~FMTobject()
static std::chrono::time_point< std::chrono::high_resolution_clock > getclock()
void setCPLhandler()
void passinexceptionhandler(const std::shared_ptr< Exception::FMTexceptionhandler > &exhandler)
virtual void setdefaultlogger()
FMTobject(const FMTobject &rhs)
void setdefaultexceptionhandler()
void setfreeexceptionhandler()
static std::shared_ptr< Exception::FMTexceptionhandler > _exhandler
A shared pointer to the exception handler.
Definition: FMTobject.hpp:66
void forceload(Archive &ar, const unsigned int version)
Definition: FMTobject.hpp:86
static std::string getdurationinseconds(const std::chrono::time_point< std::chrono::high_resolution_clock > &startclock)
virtual void passinlogger(const std::shared_ptr< Logging::FMTlogger > &logger)
virtual void settasklogger()
virtual void setdebuglogger()
The Core namespace provides classes for simulating stands/strata growth/harvest through time.
Definition: FMTaction.hpp:31
Namespace for exceptions and exceptions handling (warnings and errors) thrown by FMT and all exceptio...
Definition: FMTcplhandler.hpp:16
Namespace for the log management, provides different log handlers.
Definition: FMTdebuglogger.hpp:14