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 -------------------------------------------------------------------------------
10 License
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 
26 Class
27  Foam::ccm::base
28 
29 Description
30  Base functionality common to reader and writer classes
31 
32 Note
33  this class is in development
34  - any/all of the class names and members may change
35 
36 SourceFiles
37  ccmBase.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef ccmBase_H
42 #define ccmBase_H
43 
44 #include <memory>
45 #include <string>
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 namespace ccm
52 {
53 
54 // Forward Declarations
55 class ccmGlobalState;
56 
57 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58 
59 /*---------------------------------------------------------------------------*\
60  Class ccm::base Declaration
61 \*---------------------------------------------------------------------------*/
62 
63 class base
64 {
65 protected:
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 
100 public:
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 // ************************************************************************* //
Foam::ccm::base::base
base()
Default construct. Initializes the global-state.
Definition: ccmBase.C:68
Foam::ccm::base::globalState_
std::unique_ptr< ccmGlobalState > globalState_
Maintain overall global states (error, root-node)
Definition: ccmBase.H:69
Foam::ccm::base::assertNoError
static bool assertNoError(int err, const char *msg)
Die with msg if there is an error.
Definition: ccmBase.C:35
Foam::ccm::base::close
bool close()
Explicitly close the file and terminate ccmio access.
Definition: ccmBase.C:84
Foam::ccm::base::~base
~base()
Destructor: close file.
Definition: ccmBase.C:76
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::ccm::base
Base functionality common to reader and writer classes.
Definition: ccmBase.H:62
Foam::ccm::base::operator=
void operator=(const base &)=delete
No copy assignment.