00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "torc/generic/om/SimulationInfo.hpp"
00017 #include "torc/generic/om/LogicValue.hpp"
00018 #include "torc/generic/om/Library.hpp"
00019
00020 namespace torc {
00021
00022 namespace generic {
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 SimulationInfoSharedPtr
00033 SimulationInfo::Factory::newSimulationInfoPtr(
00034 const std::vector< LogicValueSharedPtr > & inLogicValues,
00035 const LibrarySharedPtr & inLibraryPtr ) throw(Error) {
00036 try
00037 {
00038 SimulationInfoSharedPtr newSimulationInfo;
00039 create( newSimulationInfo );
00040 newSimulationInfo->setLogicValues( inLogicValues );
00041 inLibraryPtr->setSimulationInfo( newSimulationInfo );
00042 return newSimulationInfo;
00043 }
00044 catch( Error &e )
00045 {
00046 e.setCurrentLocation(
00047 __FUNCTION__, __FILE__, __LINE__ );
00048 throw;
00049 }
00050 }
00051
00052 void
00053 SimulationInfo::accept(BaseVisitor & inoutVisitor) throw(Error) {
00054 try
00055 {
00056 runVisitor( *this, inoutVisitor );
00057 }
00058 catch( Error &e )
00059 {
00060 e.setCurrentLocation(
00061 __FUNCTION__, __FILE__, __LINE__ );
00062 throw;
00063 }
00064 }
00065
00066
00067
00068
00069
00070
00071 void
00072 SimulationInfo::setLogicValues(
00073 const std::vector< LogicValueSharedPtr > & inLogicValues) throw(Error) {
00074 std::vector< LogicValueSharedPtr >::const_iterator it = inLogicValues.begin();
00075 for( ; it != inLogicValues.end(); it++ )
00076 {
00077 try
00078 {
00079 addLogicValue( *it );
00080 }
00081 catch( Error &e )
00082 {
00083 e.setCurrentLocation(
00084 __FUNCTION__, __FILE__, __LINE__ );
00085 throw;
00086 }
00087 }
00088 }
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098 void
00099 SimulationInfo::addLogicValue(
00100 const LogicValueSharedPtr & inLogicValue) throw(Error) {
00101 if( !inLogicValue )
00102 {
00103 return;
00104 }
00105 std::string name = inLogicValue->getName();
00106 if( name.empty() )
00107 {
00108 Error e( eMessageIdErrorEmptyItemName,
00109 __FUNCTION__, __FILE__, __LINE__ );
00110 e.saveContextData("Empty logic value name ", name);
00111 throw e;
00112 }
00113 if( false == mLogicValueSymTab.set( name, inLogicValue ) )
00114 {
00115 Error e( eMessageIdErrorItemAlreadyExists,
00116 __FUNCTION__, __FILE__, __LINE__ );
00117 e.saveContextData("Logic value name", name);
00118 throw e;
00119 }
00120 inLogicValue->setParent( getSharedThis() );
00121 }
00122
00123
00124
00125
00126
00127
00128
00129
00130 LogicValueSharedPtr
00131 SimulationInfo::findLogicValue(const std::string & inName) throw() {
00132 if( inName.empty() )
00133 {
00134 Error e( eMessageIdErrorEmptyItemName,
00135 __FUNCTION__, __FILE__, __LINE__ );
00136 e.saveContextData("Empty logic value name", inName);
00137 throw e;
00138 }
00139 LogicValueSharedPtr logicValue;
00140 mLogicValueSymTab.get( inName, logicValue );
00141 return logicValue;
00142 }
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152 void
00153 SimulationInfo::removeLogicValue(const std::string &inName) throw(Error) {
00154 if( inName.empty() )
00155 {
00156 Error e( eMessageIdErrorEmptyItemName,
00157 __FUNCTION__, __FILE__, __LINE__ );
00158 e.saveContextData("Logic value name", inName);
00159 throw e;
00160 }
00161 if( false == mLogicValueSymTab.remove( inName ) )
00162 {
00163 Error e( eMessageIdErrorItemNotFound,
00164 __FUNCTION__, __FILE__, __LINE__ );
00165 e.saveContextData("Logic value name", inName);
00166 throw e;
00167 }
00168 return;
00169 }
00170
00171 SimulationInfo::SimulationInfo()
00172 : Commentable(),
00173 Visitable(),
00174 ParentedObject<Library>(),
00175 SelfReferencing<SimulationInfo>(),
00176 UserDataContainer(),
00177 mLogicValueSymTab() {
00178 }
00179
00180 SimulationInfo::~SimulationInfo() throw() {
00181 }
00182
00183 }
00184
00185 }