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 
21 #ifndef __Logical_hpp__
22 #define __Logical_hpp__
23 
24 #include "builtinTypes.hpp"
25 #include "bTypesFunctions.hpp"
26 #include "typeInfo.hpp"
27 
28 namespace pFlow
29 {
30 
31 class iIstream;
32 class iOstream;
33 
34 // allias for bool
35 class Logical
36 {
37 protected:
38  bool s_ = false;
39 
40  int yesNoSet_ = 0;
41 
42  inline static const word YesNo__[4][2] = {{"Yes", "No"},{"on","off"},{"true","false"}, {"Ok","No"}};
43 
44  inline explicit Logical(bool s, int yns)
45  :
46  s_(s),
47  yesNoSet_(yns)
48  {}
49 
50 public:
51 
52  TypeInfoNV("Logical");
53 
54 
55  inline Logical(){}
56 
57 
58  inline explicit Logical(bool s)
59  :
60  s_(s),
61  yesNoSet_(0)
62  {}
63 
64  Logical(const word& l);
65 
66  Logical(const char* ch);
67 
68  Logical(const Logical&) = default;
69 
70  Logical(Logical&&) = default;
71 
72  Logical& operator=(const Logical&) = default;
73 
74  Logical& operator=(Logical&&) = default;
75 
76  inline Logical& operator=(const bool& b)
77  {
78  s_ = b;
79  yesNoSet_ = 0;
80  return *this;
81  }
82 
83  inline bool operator()() const
84  {
85  return s_;
86  }
87 
88  inline explicit operator bool() const
89  {
90  return s_;
91  }
92 
93  inline Logical operator!()const
94  {
95  return Logical(!s_, yesNoSet_);
96  }
97 
99  bool read(iIstream& is);
100 
101  bool write(iOstream& os)const;
102 
103  bool static evaluteWord(const word& l, bool& b, int& yesNoSet );
104 
105 
106 };
107 
108 iIstream& operator>>( iIstream& is, Logical& L);
109 
110 iOstream& operator<<( iOstream& os, const Logical& L);
111 
112 } // pFlow
113 
114 #endif // __Logical_hpp__
pFlow::Logical::evaluteWord
static bool evaluteWord(const word &l, bool &b, int &yesNoSet)
Definition: Logical.cpp:42
pFlow::Logical::YesNo__
static const word YesNo__[4][2]
Definition: Logical.hpp:42
pFlow::Logical::operator=
Logical & operator=(const Logical &)=default
pFlow::Logical::Logical
Logical()
Definition: Logical.hpp:55
pFlow::word
std::string word
Definition: builtinTypes.hpp:63
pFlow::Logical::TypeInfoNV
TypeInfoNV("Logical")
pFlow
Definition: demComponent.hpp:28
pFlow::Logical::write
bool write(iOstream &os) const
Definition: Logical.cpp:98
pFlow::iIstream
Definition: iIstream.hpp:33
pFlow::Logical::read
bool read(iIstream &is)
Definition: Logical.cpp:65
pFlow::Logical::s_
bool s_
Definition: Logical.hpp:38
pFlow::operator>>
INLINE_FUNCTION iIstream & operator>>(iIstream &str, AB3History &ab3)
Definition: AdamsBashforth3.hpp:41
pFlow::operator<<
INLINE_FUNCTION iOstream & operator<<(iOstream &str, const AB3History &ab3)
Definition: AdamsBashforth3.hpp:57
pFlow::Logical::operator()
bool operator()() const
Definition: Logical.hpp:83
pFlow::Logical::Logical
Logical(bool s)
Definition: Logical.hpp:58
pFlow::Logical::operator=
Logical & operator=(const bool &b)
Definition: Logical.hpp:76
pFlow::Logical
Definition: Logical.hpp:35
pFlow::Logical::Logical
Logical(bool s, int yns)
Definition: Logical.hpp:44
pFlow::Logical::operator!
Logical operator!() const
Definition: Logical.hpp:93
typeInfo.hpp
builtinTypes.hpp
bTypesFunctions.hpp
pFlow::Logical::yesNoSet_
int yesNoSet_
Definition: Logical.hpp:40
pFlow::iOstream
Definition: iOstream.hpp:53