www.cemf.ir
Logical.hpp
Go to the documentation of this file.
1 /*------------------------------- phasicFlow ---------------------------------
2  O C enter of
3  O O E ngineering and
4  O O M ultiscale modeling of
5  OOOOOOO F luid flow
6 ------------------------------------------------------------------------------
7  Copyright (C): www.cemf.ir
8  email: hamid.r.norouzi AT gmail.com
9 ------------------------------------------------------------------------------
10 Licence:
11  This file is part of phasicFlow code. It is a free software for simulating
12  granular and multiphase flows. You can redistribute it and/or modify it under
13  the terms of GNU General Public License v3 or any other later versions.
14 
15  phasicFlow is distributed to help others in their research in the field of
16  granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
17  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 
19 -----------------------------------------------------------------------------*/
20 #ifndef __Logical_hpp__
21 #define __Logical_hpp__
22 
23 #include "builtinTypes.hpp"
24 #include "bTypesFunctions.hpp"
25 
26 
27 
28 namespace pFlow
29 {
30 
31 //- Forward
32 class iIstream;
33 class iOstream;
34 
39 class Logical
40 {
41 private:
42 
44  bool s_ = false;
45 
47  int yesNoSet_ = 0;
48 
50  inline static const word YesNo__[4][2] = { { "Yes", "No" },
51  { "on", "off" },
52  { "true", "false" },
53  { "Ok", "No" } };
54 
56  inline explicit Logical(bool s, int yns)
57  : s_(s),
58  yesNoSet_(yns)
59  {
60  }
61 
62 public:
63 
65  inline static word TYPENAME()
66  {
67  return "Logical";
68  }
69 
70  inline word typeName()const
71  {
72  return TYPENAME();
73  }
74 
76 
78  inline Logical() = default;
79 
81  inline explicit Logical(bool s)
82  : s_(s)
83  {
84  }
85 
87  Logical(const word& l);
88 
90  Logical(const char* ch);
91 
93  Logical(const Logical&) = default;
94 
96  Logical(Logical&&) = default;
97 
99  Logical& operator=(const Logical&) = default;
100 
102  Logical& operator=(Logical&&) = default;
103 
105  inline Logical& operator=(const bool& b)
106  {
107  s_ = b;
108  yesNoSet_ = 0;
109  return *this;
110  }
111 
113 
115  inline bool operator()() const
116  {
117  return s_;
118  }
119 
121  inline explicit operator bool() const
122  {
123  return s_;
124  }
125 
127  inline Logical operator!() const
128  {
129  return Logical(!s_, yesNoSet_);
130  }
131 
133 
134  bool read(iIstream& is);
135 
136  bool write(iOstream& os) const;
137 
139 
140  bool static evaluteWord(const word& l, bool& b, int& yesNoSet);
141 };
142 
143 iIstream&
144 operator>>(iIstream& is, Logical& L);
145 
146 iOstream&
147 operator<<(iOstream& os, const Logical& L);
148 
149 } // pFlow
150 
151 #endif // __Logical_hpp__
pFlow::Logical::evaluteWord
static bool evaluteWord(const word &l, bool &b, int &yesNoSet)
Definition: Logical.cpp:41
pFlow::Logical::YesNo__
static const word YesNo__[4][2]
Set of Yes or Nos.
Definition: Logical.hpp:50
pFlow::Logical::operator=
Logical & operator=(const Logical &)=default
Copy assignment.
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow
Definition: demGeometry.hpp:27
pFlow::Logical::write
bool write(iOstream &os) const
Definition: Logical.cpp:97
pFlow::Logical::TYPENAME
static word TYPENAME()
Type info.
Definition: Logical.hpp:65
pFlow::iIstream
Interface class for any input stream
Definition: iIstream.hpp:37
pFlow::Logical::read
bool read(iIstream &is)
Definition: Logical.cpp:65
pFlow::Logical::s_
bool s_
bool value
Definition: Logical.hpp:44
pFlow::operator>>
INLINE_FUNCTION iIstream & operator>>(iIstream &str, AB3History &ab3)
Definition: AdamsBashforth3.hpp:41
pFlow::Logical::typeName
word typeName() const
Definition: Logical.hpp:70
pFlow::operator<<
INLINE_FUNCTION iOstream & operator<<(iOstream &str, const AB3History &ab3)
Definition: AdamsBashforth3.hpp:57
pFlow::Logical::operator()
bool operator()() const
() operator, return bool value
Definition: Logical.hpp:115
pFlow::Logical::Logical
Logical(bool s)
Construct from bool.
Definition: Logical.hpp:81
pFlow::Logical::operator=
Logical & operator=(const bool &b)
Assignment with bool.
Definition: Logical.hpp:105
pFlow::Logical
Holds a bool value and converts strings to bool.
Definition: Logical.hpp:39
pFlow::Logical::Logical
Logical()=default
Default constructor.
pFlow::Logical::Logical
Logical(bool s, int yns)
Construct from bool and set number.
Definition: Logical.hpp:56
pFlow::Logical::operator!
Logical operator!() const
Not operator.
Definition: Logical.hpp:127
builtinTypes.hpp
bTypesFunctions.hpp
pFlow::Logical::yesNoSet_
int yesNoSet_
Set numbe of of Yes or No.
Definition: Logical.hpp:47
pFlow::iOstream
Interface class for any output stream.
Definition: iOstream.hpp:59