Skip to content
Snippets Groups Projects
Commit a112745b authored by Emmanuel Christophe's avatar Emmanuel Christophe
Browse files

ENH: ERS model intanciation from kwl

parent d24e6ca1
No related branches found
No related tags found
No related merge requests found
......@@ -38,8 +38,8 @@ ErsSarLeader::~ErsSarLeader()
std::ostream& operator<<(std::ostream& os, const ErsSarLeader& data)
{
std::map<int, ErsSarRecord*>::const_iterator it = data._records.begin();
while(it != data._records.end())
std::map<int, ErsSarRecord*>::const_iterator it = data.theRecords.begin();
while(it != data.theRecords.end())
{
(*it).second->Write(os);
++it;
......@@ -69,7 +69,7 @@ std::istream& operator>>(std::istream& is, ErsSarLeader& data)
if (record != NULL)
{
record->Read(is);
data._records[header.get_rec_seq()] = record;
data.theRecords[header.get_rec_seq()] = record;
}
else
{
......@@ -85,10 +85,10 @@ std::istream& operator>>(std::istream& is, ErsSarLeader& data)
ErsSarLeader::ErsSarLeader(const ErsSarLeader& rhs)
{
std::map<int, ErsSarRecord*>::const_iterator it = rhs._records.begin();
while(it != rhs._records.end())
std::map<int, ErsSarRecord*>::const_iterator it = rhs.theRecords.begin();
while(it != rhs.theRecords.end())
{
_records[(*it).first] = (*it).second->Clone();
theRecords[(*it).first] = (*it).second->Clone();
++it;
}
}
......@@ -96,10 +96,10 @@ ErsSarLeader::ErsSarLeader(const ErsSarLeader& rhs)
ErsSarLeader& ErsSarLeader::operator=(const ErsSarLeader& rhs)
{
ClearRecords();
std::map<int, ErsSarRecord*>::const_iterator it = rhs._records.begin();
while(it != rhs._records.end())
std::map<int, ErsSarRecord*>::const_iterator it = rhs.theRecords.begin();
while(it != rhs.theRecords.end())
{
_records[(*it).first] = (*it).second->Clone();
theRecords[(*it).first] = (*it).second->Clone();
++it;
}
......@@ -108,13 +108,13 @@ ErsSarLeader& ErsSarLeader::operator=(const ErsSarLeader& rhs)
void ErsSarLeader::ClearRecords()
{
std::map<int, ErsSarRecord*>::const_iterator it = _records.begin();
while(it != _records.end())
std::map<int, ErsSarRecord*>::const_iterator it = theRecords.begin();
while(it != theRecords.end())
{
delete (*it).second;
++it;
}
_records.clear();
theRecords.clear();
}
bool ErsSarLeader::saveState(ossimKeywordlist& kwl,
......@@ -257,27 +257,26 @@ bool ErsSarLeader::saveState(ossimKeywordlist& kwl,
return result;
}
ErsSarFacilityData * ErsSarLeader::get_ErsSarFacilityData() const
{
return (ErsSarFacilityData*)_records[ErsSarFacilityDataID];
return (ErsSarFacilityData*)theRecords[ErsSarFacilityDataID];
}
ErsSarPlatformPositionData * ErsSarLeader::get_ErsSarPlatformPositionData() const
{
return (ErsSarPlatformPositionData*)_records[ErsSarPlatformPositionDataID];
return (ErsSarPlatformPositionData*)theRecords[ErsSarPlatformPositionDataID];
}
ErsSarMapProjectionData * ErsSarLeader::get_ErsSarMapProjectionData() const
{
return (ErsSarMapProjectionData*)_records[ErsSarMapProjectionDataID];
return (ErsSarMapProjectionData*)theRecords[ErsSarMapProjectionDataID];
}
ErsSarDataSetSummary * ErsSarLeader::get_ErsSarDataSetSummary() const
{
return (ErsSarDataSetSummary*)_records[ErsSarDataSetSummaryID];
return (ErsSarDataSetSummary*)theRecords[ErsSarDataSetSummaryID];
}
ErsSarFileDescriptor * ErsSarLeader::get_ErsSarFileDescriptor() const
{
return static_cast<ErsSarFileDescriptor*>(_records[ErsSarFileDescriptorID]);
return static_cast<ErsSarFileDescriptor*>(theRecords[ErsSarFileDescriptorID]);
}
}
......@@ -84,6 +84,12 @@ public:
virtual bool saveState(ossimKeywordlist& kwl,
const char* prefix=0) const;
/**
* @brief Method to the load (recreate) the state of the object from a
* keyword list. Return true if ok or false on error.
* @return true if load OK, false on error
*/
ErsSarFacilityData * get_ErsSarFacilityData() const;
ErsSarPlatformPositionData * get_ErsSarPlatformPositionData() const;
ErsSarMapProjectionData * get_ErsSarMapProjectionData() const;
......@@ -93,7 +99,7 @@ public:
protected:
// Made mutable because the get_* methods need to access it.
// (modifying the definition of the map might be another solution)
mutable std::map<int, ErsSarRecord*> _records;
mutable std::map<int, ErsSarRecord*> theRecords;
static const int ErsSarFacilityDataID;
static const int ErsSarPlatformPositionDataID;
......
......@@ -47,6 +47,11 @@ ossimErsSarModel::~ossimErsSarModel()
{
}
ossimString ossimErsSarModel::getClassName() const
{
return ossimString("ossimErsSarModel");
}
ossimObject* ossimErsSarModel::dup() const
{
return new ossimErsSarModel(*this);
......@@ -228,6 +233,72 @@ bool ossimErsSarModel::saveState(ossimKeywordlist& kwl,
return result;
}
bool ossimErsSarModel::loadState (const ossimKeywordlist &kwl, const char *prefix)
{
static const char MODULE[] = "ossimErsSarModel::loadState";
if (traceDebug())
{
ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " entered...\n";
}
const char* lookup = 0;
ossimString s;
// Check the type first.
lookup = kwl.find(prefix, ossimKeywordNames::TYPE_KW);
if (lookup)
{
s = lookup;
if (s != getClassName())
{
return false;
}
}
// Load the base class.
// bool result = ossimGeometricSarSensorModel::loadState(kwl, prefix);
bool result = false;
result = InitPlatformPosition(kwl, prefix);
if (!result)
{
if (traceDebug())
{
ossimNotify(ossimNotifyLevel_WARN)
<< MODULE
<< "\nCan't init platform position \n";
}
}
if (result)
{
result = InitSensorParams(kwl, prefix);
if (!result)
{
if (traceDebug())
{
ossimNotify(ossimNotifyLevel_WARN)
<< MODULE
<< "\nCan't init sensor parameters \n";
}
}
}
if (result)
{
result = InitRefPoint(kwl, prefix);
if (!result)
{
if (traceDebug())
{
ossimNotify(ossimNotifyLevel_WARN)
<< MODULE
<< "\nCan't init ref point \n";
}
}
}
return result;
}
bool ossimErsSarModel::InitPlatformPosition(const ossimKeywordlist &kwl, const char *prefix)
{
......
......@@ -45,7 +45,13 @@ public:
/**
* @brief Destructor
*/
~ossimErsSarModel();
virtual ~ossimErsSarModel();
/**
* @brief Method to return the class name.
* @return The name of this class.
*/
virtual ossimString getClassName() const;
/**
* @brief Returns pointer to a new instance, copy of this.
......@@ -74,6 +80,13 @@ public:
virtual bool saveState(ossimKeywordlist& kwl,
const char* prefix=0) const;
/**
* @brief Method to the load (recreate) the state of the object from a
* keyword list. Return true if ok or false on error.
* @return true if load OK, false on error
*/
virtual bool loadState (const ossimKeywordlist &kwl, const char *prefix=0);
protected:
/**
* @brief Slant Range for each Ground Range (SRGR) number of coefficients sets
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment