torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LogicValueAttributes.cpp
Go to the documentation of this file.
1 // Torc - Copyright 2011-2013 University of Southern California. All Rights Reserved.
2 // $HeadURL$
3 // $Id$
4 
5 // This program is free software: you can redistribute it and/or modify it under the terms of the
6 // GNU General Public License as published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
11 // the GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License along with this program. If
14 // not, see <http://www.gnu.org/licenses/>.
15 
17 #include <iostream>
18 
19 namespace torc {
20 namespace generic {
21 
22 /**
23  * Set the logic value, which is used to indicate that the
24  * current logic value is stronger than this logic value.
25  *
26  * @param[in] inSource Pointer to the logic value
27  */
29  mStrong = inSource;
30 }
31 
32 /**
33  * Set the logic value, which is used to indicate that the
34  * current logic value is weaker than this logic value.
35  *
36  * @param[in] inSource Pointer to the logic value
37  */
39  mWeak = inSource;
40 }
41 
42 /**
43  * Set the voltage value for this logic value.
44  *
45  * @param[in] value Voltage value. Must be Value::MiNoMax
46  */
48  mVoltageMap = value;
49  mIsVoltageMapSet = true;
50 }
51 
52 /**
53  * Set the current value for this logic value.
54  *
55  * @param[in] value Current value. Must be Value::MiNoMax
56  */
58  mCurrentMap = value;
59  mIsCurrentMapSet = true;
60 }
61 
62 /**
63  * Set the boolean value(true/false) for this logic value.
64  *
65  * @param[in] value Boolean value. Must be Value::Boolean
66  */
68  mBooleanMap = value;
69  mIsBooleanMapSet = true;
70 }
71 
72 /**
73  * Set the list of compound logic values for this logic value.
74  *
75  * @param[in] inSource List of logic values to be appended to
76  */
77 void LogicValueAttributes::setCompoundLogicValues(const std::list<LogicValueSharedPtr>& inSource)
78  throw (Error) {
79  std::list<LogicValueSharedPtr>::const_iterator it = inSource.begin();
80  for(; it != inSource.end(); it++) {
81  try {
82  mCompounds.push_back(*it);
83  } catch(Error& e) {
84  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
85  throw;
86  }
87  }
88 }
89 
90 /**
91  * Set the list of logic values, which are dominated by the current logic value
92  *
93  * @param[in] inSource List of logic values to be appended to
94  */
95 void LogicValueAttributes::setDominatedLogicValues(const std::list<LogicValueSharedPtr>& inSource)
96  throw (Error) {
97  std::list<LogicValueSharedPtr>::const_iterator it = inSource.begin();
98  for(; it != inSource.end(); it++) {
99  try {
100  mDominates.push_back(*it);
101  } catch(Error& e) {
102  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
103  throw;
104  }
105  }
106 }
107 
108 /**
109  * Set the logic value is isolated or not, default is false
110  *
111  * @param[in] inSource bool Whether the logic value is isolated or not.
112  */
113 void LogicValueAttributes::setIsIsolated(const bool& inSource) {
114  mIsIsolated = inSource;
115 }
116 
117 /**
118  * Set the list of logic maps.
119  *
120  * @param[in] inSource List of logic maps to be appended to
121  */
122 void LogicValueAttributes::setLogicMaps(const std::list<LogicMap*>& inSource) {
123  std::list<LogicMap*>::const_iterator it = inSource.begin();
124  for(; it != inSource.end(); it++) {
125  try {
126  mLogicMaps.push_back(*it);
127  } catch(Error& e) {
128  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
129  throw;
130  }
131  }
132 }
133 
134 /**
135  * Add a logic map to the list of logic maps. If an empty pointer is supplied,
136  * it returns without doing anything.
137  *
138  * @param[in] inLogicMap A pointer to a logic map object.
139  *
140  * @exception Error Logic map could not be added.
141  */
143  if(!inLogicMap) {
144  return;
145  }
146  mLogicMaps.push_back(inLogicMap);
147 }
148 
149 /**
150  * Set the list of logic values, which are resolved by the current logic value
151  *
152  * @param[in] inSource List of logic values to be appended to
153  */
154 void LogicValueAttributes::setResolvedLogicValues(const std::list<LogicValueSharedPtr>& inSource) {
155  std::list<LogicValueSharedPtr>::const_iterator it = inSource.begin();
156  for(; it != inSource.end(); it++) {
157  try {
158  mResolves.push_back(*it);
159  } catch(Error& e) {
160  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
161  throw;
162  }
163  }
164 }
165 
166 LogicValueAttributes::LogicValueAttributes() : mVoltageMap(), mIsVoltageMapSet(false),
167  mCurrentMap(), mIsCurrentMapSet(false), mBooleanMap(), mIsBooleanMapSet(false), mCompounds(),
168  mWeak(), mStrong(), mDominates(), mLogicMaps(), mIsIsolated(false), mResolves() {}
169 
171  std::list<LogicMap *>::iterator it = mLogicMaps.begin();
172  for(; it != mLogicMaps.end(); it++) {
173  if(*it) {
174  delete *it;
175  *it = NULL;
176  }
177  }
178 }
179 
181  mVoltageMap(source.mVoltageMap), mIsVoltageMapSet(source.mIsVoltageMapSet),
182  mCurrentMap(source.mCurrentMap), mIsCurrentMapSet(source.mIsCurrentMapSet),
183  mBooleanMap(source.mBooleanMap), mIsBooleanMapSet(source.mIsBooleanMapSet),
184  mCompounds(source.mCompounds), mWeak(source.mWeak), mStrong(source.mStrong),
185  mDominates(source.mDominates), mLogicMaps(source.mLogicMaps), mIsIsolated(source.mIsIsolated),
186  mResolves(source.mResolves) {}
187 
189  if(this != &source) {
190  mVoltageMap = source.mVoltageMap;
192  mCurrentMap = source.mCurrentMap;
194  mBooleanMap = source.mBooleanMap;
196  mCompounds = source.mCompounds;
197  mWeak = source.mWeak;
198  mStrong = source.mStrong;
199  mDominates = source.mDominates;
200  mLogicMaps = source.mLogicMaps;
201  mIsIsolated = source.mIsIsolated;
202  mResolves = source.mResolves;
203  }
204  return *this;
205 }
206 
207 } // namespace generic
208 } // namespace torc
boost::shared_ptr< LogicValue > LogicValueSharedPtr
void setDominatedLogicValues(const std::list< LogicValueSharedPtr > &inSource)
void setCurrentMap(const Value::MiNoMax &value)
This structure is for logicRef and libraryRef used in logicMapInput/logicMapOutput.
void setLogicMaps(const std::list< LogicMap * > &inSource)
void setWeakLogicValue(const LogicValueSharedPtr &inSource)
void addLogicMap(LogicMap *&inLogicMap)
LogicValueAttributes & operator=(const LogicValueAttributes &source)
void setVoltageMap(const Value::MiNoMax &value)
void setStrongLogicValue(const LogicValueSharedPtr &inSource)
The Error object thrown by different methods of EdifOM.
Definition: Error.hpp:41
std::list< LogicValueSharedPtr > mDominates
void setResolvedLogicValues(const std::list< LogicValueSharedPtr > &inSource)
This class is used within simulationInfo construct to define a logic value to use for modeling...
void setBooleanMap(const Value::Boolean &value)
std::list< LogicValueSharedPtr > mResolves
void setIsIsolated(const bool &inSource)
void setCompoundLogicValues(const std::list< LogicValueSharedPtr > &inSource)
std::list< LogicValueSharedPtr > mCompounds
void setCurrentLocation(const std::string &inFunction, const std::string &inFile, uint32_t inLine)
Definition: Error.cpp:73