Loading...
Searching...
No Matches
ccmBase.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2016-2025 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::ccm::base
28
29Description
30 Base functionality common to reader and writer classes
31
32Note
33 this class is in development
34 - any/all of the class names and members may change
35
36SourceFiles
37 ccmBase.C
38
39\*---------------------------------------------------------------------------*/
40
41#ifndef Foam_ccmBase_H
42#define Foam_ccmBase_H
43
44#include <memory>
45#include <string>
46
47// Normally mingw will export *all* symbols, but since the ADF library
48// explicitly uses __declspec(dllexport) itself we must do the same otherwise
49// none of our library symbols are exported and linking fails (issue #3199).
51#undef FOAM_DLL_EXPORT
52#ifdef __MINGW32__
53 #define FOAM_DLL_EXPORT __declspec(dllexport)
54#else
55 #define FOAM_DLL_EXPORT
56#endif
57
59// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
60
61namespace Foam
62{
63namespace ccm
64{
65
66// Forward Declarations
67class ccmGlobalState;
68
69// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
71/*---------------------------------------------------------------------------*\
72 Class ccm::base Declaration
73\*---------------------------------------------------------------------------*/
74
75class base
76{
77protected:
78
79 // Protected Data
80
81 //- Maintain overall global states (error, root-node)
82 std::unique_ptr<ccmGlobalState> globalState_;
83
84
85 // Protected Member Functions
86
87 //- Die with msg if there is an error
88 // Return true if there is no error
89 static bool assertNoError(int err, const char *msg);
90
91 //- Die with msg if there is an error
92 // Return true if there is no error
93 static bool assertNoError(int err, const std::string& msg);
94
95
96 //- check global state for errors and die as required
97 // Return true if there is no error
98 bool assertNoError(const char* msg) const;
99
100 //- check global state for errors and die as required
101 // Return true if there is no error
102 bool assertNoError(const std::string& msg) const;
103
104public:
105
106 // Generated Methods
107
108 //- No copy construct
109 base(const base&) = delete;
110
111 //- No copy assignment
112 void operator=(const base&) = delete;
113
114
115 // Constructors
116
117 //- Default construct. Initializes the global-state.
118 base();
119
121 //- Destructor: close file
122 ~base();
123
124
125 // Member Functions
126
127 //- Explicitly close the file and terminate ccmio access.
128 // Return false if it was already closed.
129 bool close();
130};
131
132
133// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
134
135} // End namespace ccm
136} // End namespace Foam
137
138// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
139
140#endif
141
142// ************************************************************************* //
~base()
Destructor: close file.
Definition ccmBase.C:69
base(const base &)=delete
No copy construct.
bool close()
Explicitly close the file and terminate ccmio access.
Definition ccmBase.C:77
std::unique_ptr< ccmGlobalState > globalState_
Maintain overall global states (error, root-node).
Definition ccmBase.H:79
void operator=(const base &)=delete
No copy assignment.
static bool assertNoError(int err, const char *msg)
Die with msg if there is an error.
Definition ccmBase.C:28
base()
Default construct. Initializes the global-state.
Definition ccmBase.C:61
Namespace for OpenFOAM.