Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

stellarclass.h

Go to the documentation of this file.
00001 // stellarclass.h
00002 //
00003 // Copyright (C) 2001, Chris Laurel <claurel@shatters.net>
00004 //
00005 // This program is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU General Public License
00007 // as published by the Free Software Foundation; either version 2
00008 // of the License, or (at your option) any later version.
00009 
00010 #ifndef _STELLARCLASS_H_
00011 #define _STELLARCLASS_H_
00012 
00013 #include <iostream>
00014 #include <string>
00015 #include <celutil/basictypes.h>
00016 #include <celutil/color.h>
00017 
00018 
00019 class StellarClass
00020 {
00021 public:
00022     enum StarType
00023     {
00024         NormalStar     = 0,
00025         WhiteDwarf     = 1,
00026         NeutronStar    = 2,
00027         BlackHole      = 3,
00028     };
00029 
00030     enum SpectralClass
00031     {
00032         Spectral_O     = 0,
00033         Spectral_B     = 1,
00034         Spectral_A     = 2,
00035         Spectral_F     = 3,
00036         Spectral_G     = 4,
00037         Spectral_K     = 5,
00038         Spectral_M     = 6,
00039         Spectral_R     = 7, // superceded by class C
00040         Spectral_S     = 8,
00041         Spectral_N     = 9, // superceded by class C
00042         Spectral_WC    = 10,
00043         Spectral_WN    = 11,
00044         Spectral_Unknown = 12,
00045         Spectral_L     = 13,
00046         Spectral_T     = 14,
00047         Spectral_C     = 15,
00048         Spectral_DA    = 16, // white dwarf A (Balmer lines, no He I or metals)
00049         Spectral_DB    = 17, // white dwarf B (He I lines, no H or metals)
00050         Spectral_DC    = 18, // white dwarf C, continuous spectrum
00051         Spectral_DO    = 19, // white dwarf O, He II strong, He I or H
00052         Spectral_DQ    = 20, // white dwarf Q, carbon features
00053         Spectral_DZ    = 21, // white dwarf Z, metal lines only, no H or He
00054         Spectral_D     = 22, // generic white dwarf, no additional data
00055         Spectral_DX    = 23,
00056         Spectral_Count = 24,
00057     };
00058 
00059     enum
00060     {
00061         FirstWDClass = 16,
00062         WDClassCount = 8,
00063         SubclassCount = 11,
00064         NormalClassCount = 16,
00065     };
00066 
00067     enum LuminosityClass
00068     {
00069         Lum_Ia0     = 0,
00070         Lum_Ia      = 1,
00071         Lum_Ib      = 2,
00072         Lum_II      = 3,
00073         Lum_III     = 4,
00074         Lum_IV      = 5,
00075         Lum_V       = 6,
00076         Lum_VI      = 7,
00077         Lum_Unknown = 8,
00078         Lum_Count   = 9,
00079     };
00080 
00081     enum
00082     {
00083         Subclass_Unknown = 10
00084     };
00085 
00086     inline StellarClass();
00087     inline StellarClass(StarType,
00088                         SpectralClass,
00089                         unsigned int,
00090                         LuminosityClass);
00091 
00092     inline StarType getStarType() const;
00093     inline SpectralClass getSpectralClass() const;
00094     inline unsigned int getSubclass() const;
00095     inline LuminosityClass getLuminosityClass() const;
00096 
00097     Color getApparentColor() const;
00098     Color getApparentColor(StellarClass::SpectralClass sc) const;
00099 
00100     char* str(char* buf, unsigned int buflen) const;
00101     std::string str() const;
00102 
00103     static StellarClass parse(const std::string&);
00104 
00105     friend bool operator<(const StellarClass& sc0, const StellarClass& sc1);
00106 
00107     uint16 pack() const;
00108     bool unpack(uint16);
00109 
00110 private:
00111     StarType starType;
00112     SpectralClass specClass;
00113     LuminosityClass lumClass;
00114     unsigned int subclass;
00115 };
00116 
00117 
00118 std::ostream& operator<<(std::ostream& s, const StellarClass& sc);
00119 
00120 // A rough ordering of stellar classes, from 'early' to 'late' . . .
00121 // Useful for organizing a list of stars by spectral class.
00122 bool operator<(const StellarClass& sc0, const StellarClass& sc1);
00123 
00124 StellarClass::StellarClass(StarType t,
00125                            SpectralClass sc,
00126                            unsigned int ssub,
00127                            LuminosityClass lum) :
00128     starType(t),
00129     specClass(sc),
00130     lumClass(lum),
00131     subclass(ssub)
00132 {
00133 }
00134 
00135 StellarClass::StellarClass() :
00136     starType(NormalStar),
00137     specClass(Spectral_Unknown),
00138     lumClass(Lum_Unknown),
00139     subclass(Subclass_Unknown)
00140 {
00141     
00142 }
00143 
00144 StellarClass::StarType StellarClass::getStarType() const
00145 {
00146     return starType;
00147 }
00148 
00149 StellarClass::SpectralClass StellarClass::getSpectralClass() const
00150 {
00151     return specClass;
00152 }
00153 
00154 unsigned int StellarClass::getSubclass() const
00155 {
00156     return subclass;
00157 }
00158 
00159 StellarClass::LuminosityClass StellarClass::getLuminosityClass() const
00160 {
00161     return lumClass;
00162 }
00163 
00164 #endif // _STELLARCLASS_H_

Generated on Sat Jan 14 22:30:29 2006 for Celestia by  doxygen 1.4.1