OrsaFile Class Reference

orsa default input-output file More...

#include <orsa_file.h>

Inheritance diagram for OrsaFile:

Inheritance graph
[legend]
Collaboration diagram for OrsaFile:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 OrsaFile ()
void Read ()
void Write ()
void Open (const FILE_STATUS st=OPEN_R)
void Close ()
virtual std::string GetFileName () const
virtual void SetFileName (std::string name_in)
virtual void SetFileName (char *name_in)

Static Public Member Functions

static bool GoodFile (const std::string &)

Protected Member Functions

void Write (Universe **)
void Read (Universe **)
void Write (Evolution **)
void Read (Evolution **)
void Write (Frame *, bool=false)
void Read (Frame *, bool=false)
void Write (Body *)
void Read (Body *)
void Write (BodyWithEpoch *)
void Read (BodyWithEpoch *)
void Write (const Integrator *)
void Read (Integrator **)
void Write (const Interaction *)
void Read (Interaction **)
void Write (std::string *)
void Read (std::string *)
void Write (orsa::Vector *)
void Read (orsa::Vector *)
void Write (bool *)
void Read (bool *)
void Write (unsigned int *)
void Read (unsigned int *)
void Write (int *)
void Read (int *)
void Write (double *)
void Read (double *)
void Write (IntegratorType *)
void Read (IntegratorType *)
void Write (InteractionType *)
void Read (InteractionType *)
void Write (time_unit *)
void Read (time_unit *)
void Write (length_unit *)
void Read (length_unit *)
void Write (mass_unit *)
void Read (mass_unit *)
void Write (Date *)
void Read (Date *)
void Write (UniverseTypeAwareTime *)
void Read (UniverseTypeAwareTime *)
void Write (UniverseTypeAwareTimeStep *)
void Read (UniverseTypeAwareTimeStep *)
void Write (ReferenceSystem *)
void Read (ReferenceSystem *)
void Write (UniverseType *)
void Read (UniverseType *)
void Write (TimeScale *)
void Read (TimeScale *)
void Write (OrsaFileDataType *)
void Read (OrsaFileDataType *)
void Write (JPL_planets *)
void Read (JPL_planets *)
void Write (TimeStep *)
void Read (TimeStep *)

Protected Attributes

std::string filename
FILE_TYPE file
FILE_STATUS status

Detailed Description

orsa default input-output file

Definition at line 404 of file orsa_file.h.


Constructor & Destructor Documentation

OrsaFile (  ) 

Definition at line 1529 of file orsa_file.cc.

01529 : ReadWriteFile() { }


Member Function Documentation

void Read (  )  [virtual]

Implements ReadWriteFile.

Definition at line 1552 of file orsa_file.cc.

References File::Close(), File::GetFileName(), orsa::LengthLabel(), orsa::MassLabel(), ReadWriteFile::Open(), orsa::OPEN_R, ORSA_DEBUG, ORSA_ERROR, Universe::size(), File::status, orsa::TimeLabel(), and orsa::universe.

Referenced by OrsaFile::Read().

01552                       {
01553     
01554     Open(OPEN_R);
01555     
01556     if (status != OPEN_R) {
01557       ORSA_ERROR("Status error!");
01558       return;
01559     }
01560     
01561     Read(&universe);
01562     
01563     Close();
01564     
01565     ORSA_DEBUG("ORSA file %s [ORSA version: %s, byte order: %i, evolutions: %i, units: [%s,%s,%s]]",
01566                GetFileName().c_str(), orsa_version.c_str(), byte_order,universe->size(),
01567                LengthLabel().c_str(), MassLabel().c_str(),TimeLabel().c_str());
01568   }

Here is the call graph for this function:

void Write (  )  [virtual]

Implements ReadWriteFile.

Definition at line 1531 of file orsa_file.cc.

References File::Close(), File::file, FLUSH_FILE, ReadWriteFile::Open(), orsa::OPEN_W, ORSA_ERROR, File::status, and orsa::universe.

Referenced by OrsaFile::Write().

01531                        {
01532     
01533     Open(OPEN_W);
01534     
01535     if (status != OPEN_W) {
01536       ORSA_ERROR("Status error!");
01537       return;
01538     }
01539     
01540     if (!universe) {
01541       ORSA_ERROR("cannot write a non-allocated universe!");
01542       return;
01543     }
01544     
01545     Write(&universe);
01546     
01547     FLUSH_FILE(file);
01548     
01549     Close();
01550   }

Here is the call graph for this function:

static bool GoodFile ( const std::string &   )  [static]

void Write ( Universe **   )  [protected]

Definition at line 1570 of file orsa_file.cc.

References Units::GetLengthBaseUnit(), Units::GetMassBaseUnit(), Units::GetTimeBaseUnit(), ORSA_VERSION, orsa::units, and OrsaFile::Write().

01570                                    {
01571     
01572     // endian issues
01573     byte_order = BYTEORDER; // from config.h
01574     Write(&byte_order);
01575     
01576     // various info...
01577     orsa_version = ORSA_VERSION;
01578     Write(&orsa_version);
01579     
01580     time_unit   tu = units->GetTimeBaseUnit();
01581     length_unit lu = units->GetLengthBaseUnit();
01582     mass_unit   mu = units->GetMassBaseUnit();
01583     //
01584     Write(&tu); Write(&lu); Write(&mu);
01585     
01586     UniverseType ut = (*u)->GetUniverseType();
01587     Write(&ut);
01588     
01589     ReferenceSystem rs = (*u)->GetReferenceSystem();
01590     Write(&rs);
01591     
01592     TimeScale ts = (*u)->GetTimeScale();
01593     Write(&ts);
01594     
01595     Write(&((*u)->name));
01596     Write(&((*u)->description));
01597     
01598     unsigned int j;
01599     for(j=0;j<(*u)->size();j++) {
01600       if ((*(*u))[j]!=0) Write(&(*(*u))[j]);
01601     }
01602   }

Here is the call graph for this function:

void Read ( Universe **   )  [protected]

Definition at line 1609 of file orsa_file.cc.

References orsa::OFDT_EVOLUTION, OrsaFile::Read(), and orsa::swap().

01609                                   {
01610     
01611     swap_bytes = false;
01612     Read(&byte_order);
01613     if (byte_order != BYTEORDER) {
01614       swap_bytes = true;
01615       swap(&byte_order,sizeof(byte_order));
01616     }
01617     
01618     Read(&orsa_version);
01619     
01620     time_unit   tu;
01621     length_unit lu;
01622     mass_unit   mu;
01623     //
01624     Read(&tu);
01625     Read(&lu);
01626     Read(&mu);
01627     
01628     UniverseType ut;
01629     Read(&ut);
01630     
01631     ReferenceSystem rs;;
01632     Read(&rs);
01633     
01634     TimeScale ts;
01635     Read(&ts);
01636     
01637     make_new_universe(u,lu,mu,tu,ut,rs,ts);
01638     
01639     Read(&((*u)->name));
01640     Read(&((*u)->description));
01641     
01642     Read(&last_ofdt_read); // the others are read by the Read(evol..)
01643     /* 
01644        { // debug
01645        ORSA_ERROR("Read(Universe *u)  ofdt = %i",last_ofdt_read);
01646        }
01647     */
01648     while (last_ofdt_read == OFDT_EVOLUTION) {
01649       Evolution * e = 0;  
01650       Read(&e);
01651       (*u)->push_back(e);
01652     }
01653   }

Here is the call graph for this function:

void Write ( Evolution **   )  [protected]

Definition at line 1655 of file orsa_file.cc.

References Universe::GetUniverseType(), orsa::OFDT_EVOLUTION, orsa::Real, orsa::universe, and OrsaFile::Write().

01655                                     {
01656     
01657     OrsaFileDataType t = OFDT_EVOLUTION; Write(&t);
01658     
01659     Write(&((*e)->name));
01660     UniverseTypeAwareTimeStep sp = (*e)->GetSamplePeriod(); Write(&sp);
01661     // const Integrator * itg = (*e)->GetIntegrator(); Write(&itg);
01662     Write((*e)->GetIntegrator());
01663     // Write(&((*e)->interaction));
01664     Write((*e)->GetInteraction());
01665     
01666     unsigned int n = (*e)->start_bodies.size();
01667     Write(&n);
01668     for(unsigned int j=0;j<n;j++) {
01669       Write(&((*e)->start_bodies[j]));
01670     }
01671     //
01672     if (universe->GetUniverseType() == Real) {
01673       n = (*e)->start_JPL_bodies.size();
01674       Write(&n);
01675       for(unsigned int j=0;j<n;++j) {
01676         Write(&((*e)->start_JPL_bodies[j]));
01677       }
01678     }
01679     
01680     // the first only
01681     if ((*e)->size() > 0) Write(&((*(*e))[0]));
01682     
01683     // from the second on, write only position and velocity
01684     for(unsigned int j=1;j<(*e)->size();++j) {
01685       Write(&((*(*e))[j]),true);
01686     }
01687   }

Here is the call graph for this function:

void Read ( Evolution **   )  [protected]

Definition at line 1694 of file orsa_file.cc.

References Universe::GetUniverseType(), orsa::OFDT_FRAME, OrsaFile::Read(), orsa::Real, and orsa::universe.

01694                                    {
01695     
01696     string name;
01697     Read(&name);
01698     
01699     // double sample_period;
01700     UniverseTypeAwareTimeStep sample_period;
01701     Read(&sample_period);
01702     
01703     Integrator * integrator = 0;
01704     Read(&integrator);
01705     
01706     Interaction * interaction = 0;
01707     Read(&interaction);
01708     
01709     make_new_evolution(e);
01710     
01711     (*e)->clear();
01712     
01713     (*e)->name          = name;
01714     (*e)->SetSamplePeriod(sample_period);
01715     (*e)->SetIntegrator(integrator);
01716     (*e)->SetInteraction(interaction);
01717     
01718     delete integrator;
01719     integrator = 0;
01720     
01721     delete interaction;
01722     interaction = 0;
01723     
01724     unsigned int n;
01725     Read(&n);
01726     (*e)->start_bodies.resize(n);
01727     for(unsigned int j=0;j<n;j++) {
01728       Read(&((*e)->start_bodies[j]));
01729     }
01730     //
01731     if (universe->GetUniverseType() == Real) {
01732       Read(&n);
01733       (*e)->start_JPL_bodies.clear();
01734       
01735       JPL_planets tmp_jp;
01736       for(unsigned int j=0;j<n;j++) {
01737         Read(&tmp_jp);
01738         (*e)->start_JPL_bodies.push_back(tmp_jp);
01739       }
01740     }
01741     
01742     // we REALLY need a Frame to keep all the constant values....
01743     Frame f;
01744     
01745     Read(&last_ofdt_read);
01746     /* 
01747        { // debug
01748        ORSA_ERROR("Read(Evolution *e)  ofdt = %i",last_ofdt_read);
01749        }
01750     */
01751     if (last_ofdt_read == OFDT_FRAME) {
01752       // the first is different from the others
01753       Read(&f);
01754       (*e)->push_back(f);
01755     }
01756     
01757     Read(&last_ofdt_read);
01758     /* 
01759        { // debug
01760        ORSA_ERROR("Read(Evolution *e)  ofdt = %i",last_ofdt_read);
01761        }
01762     */
01763     while (last_ofdt_read == OFDT_FRAME) {
01764       Read(&f,true);
01765       (*e)->push_back(f);
01766       Read(&last_ofdt_read);
01767     }
01768   }

Here is the call graph for this function:

void Write ( Frame ,
bool  = false 
) [protected]

Definition at line 1770 of file orsa_file.cc.

References orsa::OFDT_FRAME, Frame::size(), and OrsaFile::Write().

01770                                                      {
01771     
01772     OrsaFileDataType t = OFDT_FRAME; Write(&t);
01773     
01774     UniverseTypeAwareTime f_time = *f;
01775     Write(&f_time);
01776     unsigned int n = f->size();
01777     Write(&n);
01778     // unsigned int j;
01779     Vector v;
01780     if (write_only_r_v) {
01781       for(unsigned int j=0;j<n;j++) {
01782         v = (*f)[j].position(); Write(&v);
01783         v = (*f)[j].velocity(); Write(&v);
01784       }
01785     } else {
01786       for(unsigned int j=0;j<n;j++) {
01787         Write(&((*f)[j]));
01788       }
01789     }
01790   }

Here is the call graph for this function:

void Read ( Frame ,
bool  = false 
) [protected]

Definition at line 1792 of file orsa_file.cc.

References OrsaFile::Read(), UniverseTypeAwareTime::SetTime(), and Frame::size().

01792                                                    {
01793     
01794     UniverseTypeAwareTime f_time;
01795     Read(&f_time);
01796     f->SetTime(f_time);
01797     unsigned int n = f->size();
01798     Read(&n);
01799     f->resize(n);
01800     unsigned int j;
01801     Vector v;
01802     if (read_only_r_v) {
01803       for(j=0;j<n;j++) {
01804         Read(&v); (*f)[j].SetPosition(v);
01805         Read(&v); (*f)[j].SetVelocity(v);
01806       }
01807     } else {
01808       for(j=0;j<n;j++) { 
01809         Read(&((*f)[j]));
01810       }
01811     }
01812   }

Here is the call graph for this function:

void Write ( Body  )  [protected]

Definition at line 1814 of file orsa_file.cc.

References Body::JPLPlanet(), Body::mass(), Body::name(), Body::position(), Body::radius(), Body::velocity(), and OrsaFile::Write().

01814                               {
01815     string b_name   = b->name();   Write(&b_name);
01816     double b_mass   = b->mass();   Write(&b_mass);
01817     double b_radius = b->radius(); Write(&b_radius);
01818     JPL_planets b_planet = b->JPLPlanet(); Write(&b_planet);
01819     Vector v;
01820     v = b->position(); Write(&v);
01821     v = b->velocity(); Write(&v);
01822   }

Here is the call graph for this function:

void Read ( Body  )  [protected]

Definition at line 1824 of file orsa_file.cc.

References OrsaFile::Read(), Body::SetPosition(), and Body::SetVelocity().

01824                              {
01825     string b_name;   Read(&b_name);
01826     double b_mass;   Read(&b_mass);
01827     double b_radius; Read(&b_radius);
01828     JPL_planets b_planet; Read(&b_planet);
01829     
01830     *b = Body(b_name,b_mass,b_radius,b_planet);
01831     
01832     Vector v;
01833     Read(&v); b->SetPosition(v);
01834     Read(&v); b->SetVelocity(v);
01835   }

Here is the call graph for this function:

void Write ( BodyWithEpoch  )  [protected]

Definition at line 1837 of file orsa_file.cc.

References OrsaFile::Write().

01837                                         {
01838     Write((Body*)b);
01839     UniverseTypeAwareTime b_epoch = b->Epoch(); Write(&b_epoch);
01840   }

Here is the call graph for this function:

void Read ( BodyWithEpoch  )  [protected]

Definition at line 1842 of file orsa_file.cc.

References OrsaFile::Read().

01842                                        {
01843     Read((Body*)b);
01844     UniverseTypeAwareTime b_epoch; Read(&b_epoch); b->SetEpoch(b_epoch);
01845   }

Here is the call graph for this function:

void Write ( const Integrator  )  [protected]

Definition at line 1908 of file orsa_file.cc.

References Integrator::accuracy, Integrator::GetType(), Integrator::m, Integrator::timestep, and OrsaFile::Write().

01908                                            {
01909     
01910     //  IntegratorType it = (*i)->GetType();
01911     IntegratorType it = i->GetType();
01912     Write(&it);
01913     
01914     // UniverseTypeAwareTimeStep ts = (*i)->timestep;
01915     UniverseTypeAwareTimeStep ts = i->timestep;
01916     Write(&ts);
01917     
01918     // double a = (*i)->accuracy;
01919     double a = i->accuracy;
01920     Write(&a);
01921     
01922     // unsigned int m = (*i)->m;
01923     unsigned int m = i->m;
01924     Write(&m);
01925   }

Here is the call graph for this function:

void Read ( Integrator **   )  [protected]

Definition at line 1927 of file orsa_file.cc.

References orsa::make_new_integrator(), and OrsaFile::Read().

01927                                     {
01928     
01929     IntegratorType type; Read(&type);
01930     make_new_integrator(i, type);
01931     
01932     UniverseTypeAwareTimeStep ts;
01933     Read(&ts);
01934     (*i)->timestep = ts;
01935     
01936     double a;       Read(&a);
01937     unsigned int m; Read(&m);
01938     
01939     (*i)->accuracy = a;
01940     (*i)->m        = m;
01941   }

Here is the call graph for this function:

void Write ( const Interaction  )  [protected]

Definition at line 1954 of file orsa_file.cc.

References Interaction::GetType(), Newton::IsIncludingFastRelativisticEffects(), Newton::IsIncludingMultipoleMoments(), Newton::IsIncludingRelativisticEffects(), Interaction::IsSkippingJPLPlanets(), orsa::NEWTON, and OrsaFile::Write().

01954                                             {
01955     InteractionType type = i->GetType(); Write(&type); 
01956     bool b = i->IsSkippingJPLPlanets();  Write(&b);
01957     if (type == NEWTON) {
01958       const Newton * newton = dynamic_cast <const Newton *> (i);
01959       if (newton) {
01960         b = newton->IsIncludingMultipoleMoments();        Write(&b);
01961         b = newton->IsIncludingRelativisticEffects();     Write(&b);
01962         b = newton->IsIncludingFastRelativisticEffects(); Write(&b);
01963       } else {
01964         b = false;
01965         Write(&b);
01966         Write(&b);
01967         Write(&b);
01968       }
01969     }
01970   }

Here is the call graph for this function:

void Read ( Interaction **   )  [protected]

Definition at line 1972 of file orsa_file.cc.

References Newton::IncludeFastRelativisticEffects(), Newton::IncludeMultipoleMoments(), Newton::IncludeRelativisticEffects(), orsa::make_new_interaction(), orsa::NEWTON, and OrsaFile::Read().

01972                                      {
01973     InteractionType type; Read(&type);
01974     make_new_interaction(i, type);
01975     bool b; Read(&b); (*i)->SkipJPLPlanets(b);
01976     if (type == NEWTON) {
01977       Newton * newton = dynamic_cast <Newton *> (*i);
01978       if (newton) {
01979         Read(&b); newton->IncludeMultipoleMoments(b);
01980         Read(&b); newton->IncludeRelativisticEffects(b);
01981         Read(&b); newton->IncludeFastRelativisticEffects(b);
01982       } else {
01983         b = false;
01984         Read(&b);
01985         Read(&b);
01986         Read(&b);
01987       }
01988     }
01989   }

Here is the call graph for this function:

void Write ( std::string *   )  [protected]

Definition at line 1991 of file orsa_file.cc.

References File::file, ORSA_ERROR, OrsaFile::Write(), and WRITE_FILE.

01991                                     {
01992     const unsigned int size = s->size();
01993     unsigned int n = 1 + size;
01994     Write(&n);
01995     char * name = (char*)malloc(n*sizeof(char));
01996     // 
01997     // strcpy(name,s->c_str());
01998     {
01999       unsigned int i;
02000       for (i=0;i<size;++i) {
02001         name[i] = (*s)[i];
02002       }
02003       name[size] = '\0';
02004     }
02005     //
02006     WRITE_FILE(name,sizeof(char),n,file);
02007     /* 
02008     ORSA_ERROR("Write(std::string *s)  n = %i   s = %s   s->size() = %i   strlen(s->c_str()) = %i",
02009       n,s->c_str(),s->size(),strlen(s->c_str()));
02010     */
02011     free(name);
02012     { // check
02013       if (strlen(s->c_str()) > n) {
02014         ORSA_ERROR("string length problem...");
02015       }
02016     }
02017   }

Here is the call graph for this function:

void Read ( std::string *   )  [protected]

Definition at line 2019 of file orsa_file.cc.

References File::file, OrsaFile::Read(), and READ_FILE.

02019                                    {
02020     unsigned int n; 
02021     Read(&n);
02022     if (n > 0) {
02023       char * name = (char*)malloc(n*sizeof(char));
02024       READ_FILE(name,sizeof(char),n,file);
02025       *s = name;
02026       /* 
02027       ORSA_ERROR("Read(std::string *s)  n = %i   s = %s   s->size() = %i   strlen(s->c_str()) = %i   name = %s",
02028         n,s->c_str(),s->size(),strlen(s->c_str()),name);
02029       */
02030       free(name);
02031     }
02032   }

Here is the call graph for this function:

void Write ( orsa::Vector  )  [protected]

Definition at line 2034 of file orsa_file.cc.

References OrsaFile::Write(), Vector::x, Vector::y, and Vector::z.

02034                                     {
02035     Write(&v->x); 
02036     Write(&v->y);
02037     Write(&v->z);
02038   }

Here is the call graph for this function:

void Read ( orsa::Vector  )  [protected]

Definition at line 2040 of file orsa_file.cc.

References OrsaFile::Read(), Vector::x, Vector::y, and Vector::z.

02040                                    {
02041     Read(&v->x); 
02042     Read(&v->y); 
02043     Read(&v->z);
02044   }

Here is the call graph for this function:

void Write ( bool *   )  [protected]

Definition at line 2046 of file orsa_file.cc.

References File::file, and WRITE_FILE.

02046                                {
02047     WRITE_FILE(b,sizeof(bool),1,file);
02048   }

void Read ( bool *   )  [protected]

Definition at line 2050 of file orsa_file.cc.

02050                               {
02051     read_swap(b,sizeof(bool));
02052   }

void Write ( unsigned int *   )  [protected]

Definition at line 2054 of file orsa_file.cc.

References File::file, and WRITE_FILE.

02054                                        {
02055     WRITE_FILE(i,sizeof(unsigned int),1,file);
02056   }

void Read ( unsigned int *   )  [protected]

Definition at line 2058 of file orsa_file.cc.

02058                                       {
02059     read_swap(i,sizeof(unsigned int));
02060   }

void Write ( int *   )  [protected]

Definition at line 2062 of file orsa_file.cc.

References File::file, and WRITE_FILE.

02062                              {
02063     WRITE_FILE(i,sizeof(int),1,file);
02064   }

void Read ( int *   )  [protected]

Definition at line 2066 of file orsa_file.cc.

02066                             {
02067     read_swap(i,sizeof(int));
02068   }

void Write ( double *   )  [protected]

Definition at line 2070 of file orsa_file.cc.

References File::file, and WRITE_FILE.

02070                                  {
02071     WRITE_FILE(d,sizeof(double),1,file);
02072   }

void Read ( double *   )  [protected]

Definition at line 2074 of file orsa_file.cc.

02074                                 {
02075     read_swap(d,sizeof(double));
02076   }

void Write ( IntegratorType  )  [protected]

Definition at line 2093 of file orsa_file.cc.

References OrsaFile::Write().

02093                                          {
02094     // WRITE_FILE(it,sizeof(IntegratorType),1,file);
02095     unsigned int i = *it;
02096     Write(&i);
02097   }

Here is the call graph for this function:

void Read ( IntegratorType  )  [protected]

Definition at line 2099 of file orsa_file.cc.

References orsa::convert(), and OrsaFile::Read().

02099                                         {
02100     // read_swap(it,sizeof(IntegratorType));
02101     unsigned int i;
02102     Read(&i);
02103     convert(*it,i);
02104   }

Here is the call graph for this function:

void Write ( InteractionType  )  [protected]

Definition at line 2106 of file orsa_file.cc.

References OrsaFile::Write().

02106                                           {
02107     // WRITE_FILE(it,sizeof(InteractionType),1,file);
02108     unsigned int i = *it;
02109     Write(&i);
02110   }

Here is the call graph for this function:

void Read ( InteractionType  )  [protected]

Definition at line 2112 of file orsa_file.cc.

References orsa::convert(), and OrsaFile::Read().

02112                                          {
02113     // read_swap(it,sizeof(InteractionType));
02114     unsigned int i;
02115     Read(&i);
02116     convert(*it,i);
02117   }

Here is the call graph for this function:

void Write ( time_unit  )  [protected]

Definition at line 2119 of file orsa_file.cc.

References OrsaFile::Write().

02119                                     {
02120     // WRITE_FILE(tu,sizeof(time_unit),1,file);
02121     unsigned int i = *tu;
02122     Write(&i);
02123   }

Here is the call graph for this function:

void Read ( time_unit  )  [protected]

Definition at line 2125 of file orsa_file.cc.

References orsa::convert(), and OrsaFile::Read().

02125                                    {
02126     // read_swap(tu,sizeof(time_unit));
02127     unsigned int i;
02128     Read(&i);
02129     convert(*tu,i);
02130   }

Here is the call graph for this function:

void Write ( length_unit  )  [protected]

Definition at line 2132 of file orsa_file.cc.

References OrsaFile::Write().

02132                                       {
02133     // WRITE_FILE(lu,sizeof(length_unit),1,file);
02134     unsigned int i = *lu;
02135     Write(&i);
02136   }

Here is the call graph for this function:

void Read ( length_unit  )  [protected]

Definition at line 2138 of file orsa_file.cc.

References orsa::convert(), and OrsaFile::Read().

02138                                      {
02139     // read_swap(lu,sizeof(length_unit));
02140     unsigned int i;
02141     Read(&i); 
02142     convert(*lu,i);
02143   }

Here is the call graph for this function:

void Write ( mass_unit  )  [protected]

Definition at line 2145 of file orsa_file.cc.

References OrsaFile::Write().

02145                                     {
02146     // WRITE_FILE(mu,sizeof(mass_unit),1,file);
02147     unsigned int i = *mu;
02148     Write(&i);
02149   }

Here is the call graph for this function:

void Read ( mass_unit  )  [protected]

Definition at line 2151 of file orsa_file.cc.

References orsa::convert(), and OrsaFile::Read().

02151                                    {
02152     // read_swap(mu,sizeof(mass_unit));
02153     unsigned int i;
02154     Read(&i);
02155     convert(*mu,i);
02156   }

Here is the call graph for this function:

void Write ( Date  )  [protected]

Definition at line 1847 of file orsa_file.cc.

References Date::GetJulian(), and OrsaFile::Write().

01847                               {
01848     double j = d->GetJulian(); Write(&j);
01849   }

Here is the call graph for this function:

void Read ( Date  )  [protected]

Definition at line 1851 of file orsa_file.cc.

References OrsaFile::Read(), and Date::SetJulian().

01851                              {
01852     double j; Read(&j); d->SetJulian(j);
01853   }

Here is the call graph for this function:

void Write ( UniverseTypeAwareTime  )  [protected]

Definition at line 1855 of file orsa_file.cc.

References UniverseTypeAwareTime::GetDate(), UniverseTypeAwareTime::GetTime(), Universe::GetUniverseType(), orsa::Real, orsa::Simulated, orsa::universe, and OrsaFile::Write().

01855                                                 {
01856     switch (universe->GetUniverseType()) {
01857     case Real: {
01858       Date d = t->GetDate(); Write(&d);
01859       break;
01860     }
01861     case Simulated: {
01862       double tt = t->GetTime(); Write(&tt);
01863       break;
01864     }
01865     }
01866   }

Here is the call graph for this function:

void Read ( UniverseTypeAwareTime  )  [protected]

Definition at line 1868 of file orsa_file.cc.

References Universe::GetUniverseType(), OrsaFile::Read(), orsa::Real, UniverseTypeAwareTime::SetDate(), UniverseTypeAwareTime::SetTime(), orsa::Simulated, and orsa::universe.

01868                                               {
01869     switch (universe->GetUniverseType()) {
01870     case Real: {
01871       Date d; Read(&d); t->SetDate(d);
01872       break;
01873     }
01874     case Simulated: {
01875       double tt; Read(&tt); t->SetTime(tt);
01876       break;
01877     }
01878     }
01879   }

Here is the call graph for this function:

void Write ( UniverseTypeAwareTimeStep  )  [protected]

Definition at line 1881 of file orsa_file.cc.

References UniverseTypeAwareTimeStep::GetDouble(), UniverseTypeAwareTimeStep::GetTimeStep(), Universe::GetUniverseType(), orsa::Real, orsa::Simulated, orsa::universe, and OrsaFile::Write().

01881                                                        {
01882     switch (universe->GetUniverseType()) {
01883     case Real: {
01884       TimeStep _ts = ts_in->GetTimeStep(); Write(&_ts);
01885       break;
01886     }
01887     case Simulated: {
01888       double tt = ts_in->GetDouble(); Write(&tt);
01889       break;
01890     }
01891     }
01892   }

Here is the call graph for this function:

void Read ( UniverseTypeAwareTimeStep  )  [protected]

Definition at line 1894 of file orsa_file.cc.

References Universe::GetUniverseType(), OrsaFile::Read(), orsa::Real, UniverseTypeAwareTimeStep::SetDouble(), UniverseTypeAwareTimeStep::SetTimeStep(), orsa::Simulated, and orsa::universe.

01894                                                       {
01895     switch (universe->GetUniverseType()) {
01896     case Real: {
01897       TimeStep _ts; Read(&_ts); ts_in->SetTimeStep(_ts);
01898       break;
01899     }
01900     case Simulated: {
01901       double tt; Read(&tt); ts_in->SetDouble(tt);
01902       break;
01903     }
01904     }
01905   }

Here is the call graph for this function:

void Write ( ReferenceSystem  )  [protected]

Definition at line 2158 of file orsa_file.cc.

References OrsaFile::Write().

02158                                           {
02159     // WRITE_FILE(rs,sizeof(ReferenceSystem),1,file);
02160     unsigned int i = *rs;
02161     Write(&i);
02162   }

Here is the call graph for this function:

void Read ( ReferenceSystem  )  [protected]

Definition at line 2164 of file orsa_file.cc.

References orsa::convert(), and OrsaFile::Read().

02164                                          {
02165     // read_swap(rs,sizeof(ReferenceSystem));
02166     unsigned int i;
02167     Read(&i);
02168     convert(*rs,i);
02169   }

Here is the call graph for this function:

void Write ( UniverseType  )  [protected]

Definition at line 2171 of file orsa_file.cc.

References OrsaFile::Write().

02171                                        {
02172     // WRITE_FILE(ut,sizeof(UniverseType),1,file);
02173     unsigned int i = *ut;
02174     Write(&i);
02175   }

Here is the call graph for this function:

void Read ( UniverseType  )  [protected]

Definition at line 2177 of file orsa_file.cc.

References orsa::convert(), and OrsaFile::Read().

02177                                       {
02178     // read_swap(ut,sizeof(UniverseType));
02179     unsigned int i;
02180     Read(&i);
02181     convert(*ut,i);
02182   }

Here is the call graph for this function:

void Write ( TimeScale  )  [protected]

Definition at line 2184 of file orsa_file.cc.

References OrsaFile::Write().

02184                                     {
02185     // WRITE_FILE(ts,sizeof(TimeScale),1,file);
02186     unsigned int i = *ts;
02187     Write(&i);
02188   }

Here is the call graph for this function:

void Read ( TimeScale  )  [protected]

Definition at line 2190 of file orsa_file.cc.

References orsa::convert(), and OrsaFile::Read().

02190                                    {
02191     // read_swap(ts,sizeof(TimeScale));
02192     unsigned int i;
02193     Read(&i);
02194     convert(*ts,i);
02195   }

Here is the call graph for this function:

void Write ( OrsaFileDataType  )  [protected]

Definition at line 2197 of file orsa_file.cc.

References OrsaFile::Write().

02197                                              {
02198     // WRITE_FILE(ofdt,sizeof(OrsaFileDataType),1,file);
02199     unsigned int i = *ofdt;
02200     Write(&i);
02201   }

Here is the call graph for this function:

void Read ( OrsaFileDataType  )  [protected]

Definition at line 2210 of file orsa_file.cc.

References orsa::convert(), and orsa::OFDT_END_OF_FILE.

02210                                             {
02211     // const int val = read_swap(ofdt,sizeof(OrsaFileDataType));
02212     // if (val==0) *ofdt = OFDT_END_OF_FILE;
02213     unsigned int i;
02214     const int val = read_swap(&i,sizeof(unsigned int));
02215     // convert(*ofdt,i);
02216     // if (val==0) *ofdt = OFDT_END_OF_FILE;
02217     if (val==0) {
02218       *ofdt = OFDT_END_OF_FILE;
02219     } else {
02220       convert(*ofdt,i);
02221     }
02222   }

Here is the call graph for this function:

void Write ( JPL_planets  )  [protected]

Definition at line 2224 of file orsa_file.cc.

References OrsaFile::Write().

02224                                       {
02225     // WRITE_FILE(jp,sizeof(JPL_planets),1,file);
02226     unsigned int i = *jp;
02227     Write(&i);
02228   }

Here is the call graph for this function:

void Read ( JPL_planets  )  [protected]

Definition at line 2230 of file orsa_file.cc.

References orsa::convert(), and OrsaFile::Read().

02230                                      {
02231     // read_swap(jp,sizeof(JPL_planets));
02232     unsigned int i;
02233     Read(&i);
02234     convert(*jp,i);
02235   }

Here is the call graph for this function:

void Write ( TimeStep  )  [protected]

Definition at line 2237 of file orsa_file.cc.

References TimeStep::day_fraction(), TimeStep::days(), TimeStep::sign(), and OrsaFile::Write().

02237                                     {
02238     unsigned int days = ts->days(); 
02239     Write(&days);
02240     //
02241     unsigned int day_fraction = ts->day_fraction();
02242     Write(&day_fraction); 
02243     //
02244     int sign = ts->sign();
02245     Write(&sign);
02246   }

Here is the call graph for this function:

void Read ( TimeStep  )  [protected]

Definition at line 2248 of file orsa_file.cc.

References OrsaFile::Read().

02248                                    {
02249     unsigned int days;
02250     Read(&days);
02251     unsigned int day_fraction;
02252     Read(&day_fraction);
02253     int sign;
02254     Read(&sign);
02255     *ts = TimeStep(days,day_fraction,sign);
02256   }

Here is the call graph for this function:

void Open ( const FILE_STATUS  st = OPEN_R  )  [inherited]

Definition at line 84 of file orsa_file.cc.

References File::Close(), orsa::CLOSE, File::file, File::filename, OPEN_FILE, orsa::OPEN_R, OPEN_READ, orsa::OPEN_W, OPEN_WRITE, ORSA_ERROR, and File::status.

Referenced by OrsaFile::Read(), OrsaConfigFile::Read(), OrsaFile::Write(), and OrsaConfigFile::Write().

00084                                                {
00085     
00086     // already in the right status
00087     if (status == st) return;
00088     
00089     // anomalous...
00090     if (st == CLOSE) {
00091       Close();
00092       return;
00093     }
00094     
00095     Close();
00096     
00097     if ((st == OPEN_R) && ((file = OPEN_FILE(filename.c_str(),OPEN_READ)) != 0)) {
00098       status = OPEN_R;
00099       return;
00100     }
00101     
00102     if ((st == OPEN_W) && ((file = OPEN_FILE(filename.c_str(),OPEN_WRITE)) != 0)) {
00103       status = OPEN_W;
00104       return;
00105     }
00106     
00107     if (file == 0) {
00108       ORSA_ERROR("Can't open file %s",filename.c_str());
00109     }
00110     
00111     status = CLOSE;
00112   }

Here is the call graph for this function:

void Close (  )  [inherited]

Definition at line 115 of file orsa_file.cc.

References orsa::CLOSE, CLOSE_FILE, File::file, and File::status.

Referenced by SWIFTFile::AsteroidsInFile(), ReadWriteFile::Open(), OrsaFile::Read(), OrsaConfigFile::Read(), SWIFTFile::Read(), Config::read_from_file(), File::SetFileName(), OrsaFile::Write(), OrsaConfigFile::Write(), Config::write_to_file(), and File::~File().

00115                    {
00116     if (status != CLOSE) {
00117       CLOSE_FILE(file);
00118       status = CLOSE;
00119     }
00120   }

virtual std::string GetFileName (  )  const [inline, virtual, inherited]

Definition at line 99 of file orsa_file.h.

References File::filename.

Referenced by OrsaFile::Read().

00099 { return filename; }

virtual void SetFileName ( std::string  name_in  )  [inline, virtual, inherited]

Definition at line 101 of file orsa_file.h.

References File::Close(), orsa::CLOSE, File::filename, and File::status.

Referenced by OrsaConfigFile::OrsaConfigFile(), and File::SetFileName().

00101                                                         {
00102       if (status != CLOSE) Close();
00103       filename = name_in;
00104     }

Here is the call graph for this function:

virtual void SetFileName ( char *  name_in  )  [inline, virtual, inherited]

Definition at line 106 of file orsa_file.h.

References File::SetFileName().

00106                                                      {
00107       std::string n = name_in;
00108       SetFileName (n);
00109     }

Here is the call graph for this function:


Member Data Documentation

std::string filename [protected, inherited]

Definition at line 112 of file orsa_file.h.

Referenced by File::GetFileName(), ReadWriteFile::Open(), WriteFile::Open(), ReadFile::Open(), and File::SetFileName().

FILE_TYPE file [protected, inherited]

Definition at line 113 of file orsa_file.h.

Referenced by SWIFTFile::AsteroidsInFile(), File::Close(), File::File(), ReadWriteFile::Open(), WriteFile::Open(), ReadFile::Open(), Mercury5IntegrationFile::Read(), OrsaFile::Read(), OrsaConfigFile::Read(), SWIFTFile::Read(), LocationFile::Read(), RWOFile::Read(), MPCObsFile::Read(), MPCCometFile::Read(), MPCOrbFile::Read(), AstorbFile::Read(), OrsaFile::Write(), and OrsaConfigFile::Write().

FILE_STATUS status [protected, inherited]

Definition at line 114 of file orsa_file.h.

Referenced by File::Close(), File::File(), Mercury5IntegrationFile::Mercury5IntegrationFile(), ReadWriteFile::Open(), WriteFile::Open(), ReadFile::Open(), Mercury5IntegrationFile::Read(), TLEFile::Read(), NEODYSCAT::Read(), JPLDastcomCometFile::Read(), JPLDastcomUnnumFile::Read(), JPLDastcomNumFile::Read(), AstDySMatrixFile::Read(), RadauModIntegrationFile::Read(), OrsaFile::Read(), OrsaConfigFile::Read(), SWIFTFile::Read(), LocationFile::Read(), MPCObsFile::Read(), MPCCometFile::Read(), MPCOrbFile::Read(), AstorbFile::Read(), File::SetFileName(), OrsaFile::Write(), and OrsaConfigFile::Write().


The documentation for this class was generated from the following files:
Generated on Wed May 30 13:05:10 2007 for liborsa by  doxygen 1.5.2