QuantityTypeDescriptor.h
1 /**************************************************************************************
2 Copyright 2015 Applied Research Associates, Inc.
3 Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4 this file except in compliance with the License. You may obtain a copy of the License
5 at:
6 http://www.apache.org/licenses/LICENSE-2.0
7 Unless required by applicable law or agreed to in writing, software distributed under
8 the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
9 CONDITIONS OF ANY KIND, either express or implied. See the License for the
10 specific language governing permissions and limitations under the License.
11 **************************************************************************************/
12 
13 //----------------------------------------------------------------------------
19 //----------------------------------------------------------------------------
20 #pragma once
21 #include <string>
22 
23 namespace biogears {
24 class CCompoundUnit;
25 class CUnitDimension;
26 
28 public:
29  // Ctor for a fundamental quantity
30  CQuantityTypeDescriptor(const char* name, int fundIdx, bool twentyLog);
31  CQuantityTypeDescriptor(const std::string& name, int fundIdx, bool twentyLog);
32 
33  // Ctor for a derived quantity
34  CQuantityTypeDescriptor(const char* name, CCompoundUnit* expansion, bool twentyLog);
35  CQuantityTypeDescriptor(const std::string& name, CCompoundUnit* expansion, bool twentyLog);
36 
37  // Need dtor to free the expansion
39 
40  // Return the name of this quantity type
41  std::string GetName() const;
42  const char* GetName_cStr() const;
43 
44  // Return the "fundamental index". This value is a unique monotonically-increasing
45  // numeric identifier given to each quantity type that designates a fundamental
46  // (such as time or mass), rather than derived (such as force or energy), quantity.
47  // For derived quantities, the value is -1.
48  int GetFundIdx() const
49  {
50  return m_iFundIdx;
51  }
52 
53  // Return the expansion of a derived quantity type as a compound unit. The expansion
54  // defines the "base unit" (whether or not it has an explicit name) of this quantity
55  // in terms of a composition of units of other quantities.
56  const CCompoundUnit* GetExpansion() const
57  {
58  return m_CUExpansion;
59  };
60 
62  {
63  return m_CUD;
64  }
65 
66  double GetBigness() const
67  {
68  return m_dBigness;
69  };
70 
71  bool Is20LogRuleQuantity() const
72  {
73  return m_bTwentyLogRule;
74  }
75 
76  // disable the copy constructor so that I don't accidentally copy a descriptor
77  // when I really intended to initialize a reference to one. I made this mistake
78  // leaving off the '&' on a ref that was initialized with the result of
79  // UnitConversionEngine::GetQuantityTypeDescriptor(), thereby invoking the
80  // copy constructor with bitwise copies on our internal pointer objects, and later
81  // called out dtor when my would-be ref went out of scope, which freed objects that
82  // were still in use. Ugh.
83 private:
85 
86 private:
87  double m_dBigness;
88  std::string m_sName;
93 };
94 }
std::string GetName() const
Definition: QuantityTypeDescriptor.cpp:70
~CQuantityTypeDescriptor()
Definition: QuantityTypeDescriptor.cpp:61
bool m_bTwentyLogRule
Definition: QuantityTypeDescriptor.h:92
CQuantityTypeDescriptor(const char *name, int fundIdx, bool twentyLog)
Definition: QuantityTypeDescriptor.cpp:23
std::string m_sName
Definition: QuantityTypeDescriptor.h:88
double m_dBigness
Definition: QuantityTypeDescriptor.h:87
int m_iFundIdx
Definition: QuantityTypeDescriptor.h:89
int GetFundIdx() const
Definition: QuantityTypeDescriptor.h:48
const CCompoundUnit * GetExpansion() const
Definition: QuantityTypeDescriptor.h:56
bool Is20LogRuleQuantity() const
Definition: QuantityTypeDescriptor.h:71
const CUnitDimension * GetDimension() const
Definition: QuantityTypeDescriptor.h:61
CUnitDimension * m_CUD
Definition: QuantityTypeDescriptor.h:91
double GetBigness() const
Definition: QuantityTypeDescriptor.h:66
Definition: CompoundUnit.h:59
Definition: QuantityTypeDescriptor.h:27
const char * GetName_cStr() const
Definition: QuantityTypeDescriptor.cpp:76
CCompoundUnit * m_CUExpansion
Definition: QuantityTypeDescriptor.h:90
Definition: UnitDimension.h:35
Definition: SEElectricalCircuit.h:18