// 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
#ifndef _CASTOR_ASTRO_OBJECT_HH
#define _CASTOR_ASTRO_OBJECT_HH
#include <string>
#include <fstream>
#include <libnova/libnova.h>
#include <gdkmm/color.h>
#include <libgnomecanvasmm/group.h>
/*! \namespace Castor
* \brief Astronomical Objects
*
* All astronmical objects in Nova are contained in the namespace Castor.
*
*/
namespace Castor
{
/*! \class AstroObject
* \brief Abstract base class of all Astronomical Objects
*
* All astronomical objects in Nova are derived from this
* abstract base class.
*/
class AstroObject
{
public:
/*! \enum element_type
* \brief Type of element
*/
enum element_type {
INT = 0, /*!< Object is an Int */
DOUBLE, /*!< Object is a double */
STRING /*!< Object is a std::string */
};
/*! \fn AstroObject()
* \brief Constructor
*/
AstroObject();
/*! \fn ~AstroObject()
* \brief Destructor
*/
~AstroObject();
/*! \fn virtual bool add_element (std::string& name, element_type type, std::string& value);
* \brief Add a data element.
*/
virtual bool add_element (std::string& name, element_type type, std::string& value);
/*! \fn virtual bool check_element (std::string& name);
* \brief Is object type known ?
*/
virtual bool check_element (std::string& name);
/*! \fn virtual void get_hrz_posn (double JD, ln_lnlat_posn* observer, ln_hrz_posn* posn) = 0;
* \brief Get object horizontal position
*/
virtual void get_hrz_posn (double JD, ln_lnlat_posn* observer, ln_hrz_posn* posn) = 0;
/*! \fn virtual void get_rst_time (double JD, ln_lnlat_posn* observer, ln_rst_time* time) = 0;
* \brief Get object rise, transit and set time.
*/
virtual void get_rst_time (double JD, ln_lnlat_posn* observer, ln_rst_time* time) = 0;
/*! \fn void get_posn(double& ra, double& dec) = 0;
* \brief Get object Right Ascension and Declination
*/
virtual void get_equ_posn(double JD, double& ra, double& dec) = 0;
/*! \fn double get_mag(double JD = 0) = 0;
* \brief Get object Magnitude
*/
virtual double get_mag(double JD = 0) = 0;
/*! \fn void get_id(std::string& id);
* \brief Get object identification number.
*/
void get_id(std::string& id);
/*! \fn virtual void get_name(std::string& name);
* \brief Get object name.
*/
virtual void get_name(std::string& name);
/*! \fn virtual int save (std::ofstream* file);
* \brief Save object to file.
*/
virtual int save (std::ofstream* file);
/*! \fn virtual int load (std::ifstream* file);
* \brief Load object from file.
*/
virtual int load (std::ifstream* file);
/*! \fn virtual int init();
* \brief Initialise object.
*/
virtual int init();
/*! \fn virtual void get_info (std::list<Glib::ustring>& value);
* \brief Get object information
*/
virtual void get_info (std::list<Glib::ustring>& value);
/*! \fn virtual void render(double x, double y, double mag_max, Gnome::Canvas::Group& group);
* \brief Render object
*/
virtual void render(double x, double y, double mag_max, Gnome::Canvas::Group& group, bool bright, double ppd = 0) = 0;
protected:
std::string m_cat_no; /*!< object id */
std::vector<std::string*> m_unknown_elements; /*!< object unknown elements */
/*! \fn void save_item (std::ofstream* file, int value);
* \brief Save item to file of type int.
*/
void save_item (std::ofstream* file, int value);
/*! \fn void save_item (std::ofstream* file, double value);
* \brief Save item to file of type double.
*/
void save_item (std::ofstream* file, double value);
/*! \fn void save_item (std::ofstream* file, std::string& value);
* \brief Save item to file of type std::string.
*/
void save_item (std::ofstream* file, std::string& value);
/*! \fn void load_item (std::ifstream* file, int& value);
* \brief Load item from file of type int.
*/
void load_item (std::ifstream* file, int& value);
/*! \fn void load_item (std::ifstream* file, double& value);
* \brief Load item from file of type double.
*/
void load_item (std::ifstream* file, double& value);
/*! \fn void load_item (std::ifstream* file, std::string& value);
* \brief Load item from file of type std:string.
*/
void load_item (std::ifstream* file, std::string& value);
private:
/*! \fn add_unknown_element (std::string& name, element_type type, std::string& value);
* \brief add an unknown element type to the object.
*/
bool add_unknown_element (std::string& name, element_type type,
std::string& value);
};
};
#endif
syntax highlighted by Code2HTML, v. 0.9.1