1 // Copyright (C) 2014-2015 EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 // Lesser General Public License for more details.
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include <HYDROData_StricklerTable.h>
20 #include <TDataStd_NamedData.hxx>
22 IMPLEMENT_STANDARD_HANDLE( HYDROData_StricklerTable, HYDROData_Entity )
23 IMPLEMENT_STANDARD_RTTIEXT( HYDROData_StricklerTable, HYDROData_Entity )
25 HYDROData_StricklerTable::HYDROData_StricklerTable()
29 HYDROData_StricklerTable::~HYDROData_StricklerTable()
33 const ObjectKind HYDROData_StricklerTable::GetKind() const
35 return KIND_STRICKLER_TABLE;
38 bool HYDROData_StricklerTable::Import( const TCollection_AsciiString& theFileName )
40 FILE* aFile = fopen( theFileName.ToCString(), "r" );
44 const int aBufLen = 256;
46 while( !feof( aFile ) )
48 fgets( aBuf, aBufLen, aFile );
49 std::string aStr = aBuf;
54 bool HYDROData_StricklerTable::Export( const TCollection_AsciiString& theFileName )
60 double HYDROData_StricklerTable::Get( const TCollection_ExtendedString& theType, double theDefault ) const
62 Handle( TDataStd_NamedData ) aMap = Map();
63 if( aMap->HasReal( theType ) )
64 return aMap->GetReal( theType );
69 void HYDROData_StricklerTable::Set( const TCollection_ExtendedString& theType, double theCoefficient )
71 Handle( TDataStd_NamedData ) aMap = Map();
72 aMap->SetReal( theType, theCoefficient );
75 Handle( TDataStd_NamedData ) HYDROData_StricklerTable::Map() const
77 TDF_Label aLabel = myLab.FindChild( DataTag_Table );
78 Handle( TDataStd_NamedData ) aMap;
79 if( !aLabel.FindAttribute( TDataStd_NamedData::GetID(), aMap ) )
80 aMap = TDataStd_NamedData::Set( aLabel );