// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// Copyright 2003 Liam Girdwood
#include "skymap_object.hh"
namespace Castor
{
SkymapObject::SkymapObject ()
{
m_rv = 0;
m_sp_mk = "";
}
SkymapObject::~SkymapObject()
{
}
bool SkymapObject::check_element (std::string& name)
{
if (name == "RV")
return true;
if (name == "Vder")
return true;
if (name == "SpMK")
return true;
return StarObject::check_element(name);
}
bool SkymapObject::add_element (std::string& name, element_type type,
std::string& value)
{
switch (type) {
case DOUBLE: {
double val = strtod (value.c_str(), 0);
if (name == "RV") {
m_rv = val;
return true;
}
if (name == "Vder") {
m_mag = val;
return true;
}
}
break;
case INT: {
}
break;
case STRING: {
if (name == "SpMK") {
m_sp_mk = value;
return true;
}
}
break;
}
return StarObject::add_element (name, type, value);
}
int SkymapObject::save (std::ofstream* file)
{
save_item (file, m_rv);
save_item (file, m_sp_mk);
// base object
StarObject::save(file);
}
int SkymapObject::load (std::ifstream* file)
{
load_item (file, m_rv);
load_item (file, m_sp_mk);
// base object
StarObject::load(file);
}
/*! \fn virtual void get_info (std::list<Glib::ustring> name, std::list<Glib::ustring> value);
* \param Get object information
*/
void SkymapObject::get_info (std::list<Glib::ustring>& name, std::list<Glib::ustring>& value)
{
char temp[16];
sprintf(temp, "%4.3f", m_rv);
name.push_front(Glib::ustring("RadVel"));
value.push_front(Glib::ustring(temp));
name.push_front(Glib::ustring("SpMk"));
value.push_front(Glib::ustring(m_sp_mk));
StarObject::get_info (name, value);
}
}
syntax highlighted by Code2HTML, v. 0.9.1