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 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 ccmBase_H
42#define ccmBase_H
43
44#include <memory>
45#include <string>
46
47// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48
49namespace Foam
51namespace ccm
52{
53
54// Forward Declarations
55class ccmGlobalState;
56
57// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58
59/*---------------------------------------------------------------------------*\
60 Class ccm::base Declaration
61\*---------------------------------------------------------------------------*/
63class base
64{
65protected:
66
67 // Protected Data
68
69 //- Maintain overall global states (error, root-node)
70 std::unique_ptr<ccmGlobalState> globalState_;
71
72
73 // Protected Member Functions
74
75 //- Die with msg if there is an error
76 // Return true if there is no error
77 static bool assertNoError(int err, const char *msg);
78
79 //- Die with msg if there is an error
80 // Return true if there is no error
81 static bool assertNoError(int err, const std::string& msg);
82
83
84 //- check global state for errors and die as required
85 // Return true if there is no error
86 bool assertNoError(const char* msg) const;
87
88 //- check global state for errors and die as required
89 // Return true if there is no error
90 bool assertNoError(const std::string& msg) const;
91
92
93 //- No copy construct
94 base(const base&) = delete;
95
96 //- No copy assignment
97 void operator=(const base&) = delete;
98
99
100public:
101
102 // Constructors
103
104 //- Default construct. Initializes the global-state.
105 base();
106
107
108 //- Destructor: close file
109 ~base();
110
111
112 // Member Functions
113
114 //- Explicitly close the file and terminate ccmio access.
115 // Return false if it was already closed.
116 bool close();
117
118};
119
120// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
121
122} // End namespace ccm
123} // End namespace Foam
124
125// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
126
127#endif
128
129// ************************************************************************* //
Base functionality common to reader and writer classes.
Definition: ccmBase.H:63
~base()
Destructor: close file.
Definition: ccmBase.C:76
base(const base &)=delete
No copy construct.
bool close()
Explicitly close the file and terminate ccmio access.
Definition: ccmBase.C:84
std::unique_ptr< ccmGlobalState > globalState_
Maintain overall global states (error, root-node)
Definition: ccmBase.H:69
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:35
base()
Default construct. Initializes the global-state.
Definition: ccmBase.C:68
Namespace for OpenFOAM.