orsa default input-output file More...
#include <orsa_file.h>
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 |
orsa default input-output file
Definition at line 404 of file orsa_file.h.
OrsaFile | ( | ) |
Definition at line 1530 of file orsa_file.cc.
01530 : ReadWriteFile() { }
void Close | ( | ) | [inherited] |
Definition at line 116 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().
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; }
static bool GoodFile | ( | const std::string & | ) | [static] |
void Open | ( | const FILE_STATUS | st = OPEN_R |
) | [inherited] |
Definition at line 85 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().
00085 { 00086 00087 // already in the right status 00088 if (status == st) return; 00089 00090 // anomalous... 00091 if (st == CLOSE) { 00092 Close(); 00093 return; 00094 } 00095 00096 Close(); 00097 00098 if ((st == OPEN_R) && ((file = OPEN_FILE(filename.c_str(),OPEN_READ)) != 0)) { 00099 status = OPEN_R; 00100 return; 00101 } 00102 00103 if ((st == OPEN_W) && ((file = OPEN_FILE(filename.c_str(),OPEN_WRITE)) != 0)) { 00104 status = OPEN_W; 00105 return; 00106 } 00107 00108 if (file == 0) { 00109 ORSA_ERROR("Can't open file %s",filename.c_str()); 00110 } 00111 00112 status = CLOSE; 00113 }
void Read | ( | TimeStep * | ts | ) | [protected] |
Definition at line 2249 of file orsa_file.cc.
References OrsaFile::Read().
02249 { 02250 unsigned int days; 02251 Read(&days); 02252 unsigned int day_fraction; 02253 Read(&day_fraction); 02254 int sign; 02255 Read(&sign); 02256 *ts = TimeStep(days,day_fraction,sign); 02257 }
void Read | ( | JPL_planets * | jp | ) | [protected] |
Definition at line 2231 of file orsa_file.cc.
References orsa::convert(), and OrsaFile::Read().
02231 { 02232 // read_swap(jp,sizeof(JPL_planets)); 02233 unsigned int i; 02234 Read(&i); 02235 convert(*jp,i); 02236 }
void Read | ( | OrsaFileDataType * | ofdt | ) | [protected] |
Definition at line 2211 of file orsa_file.cc.
References orsa::convert(), and orsa::OFDT_END_OF_FILE.
02211 { 02212 // const int val = read_swap(ofdt,sizeof(OrsaFileDataType)); 02213 // if (val==0) *ofdt = OFDT_END_OF_FILE; 02214 unsigned int i; 02215 const int val = read_swap(&i,sizeof(unsigned int)); 02216 // convert(*ofdt,i); 02217 // if (val==0) *ofdt = OFDT_END_OF_FILE; 02218 if (val==0) { 02219 *ofdt = OFDT_END_OF_FILE; 02220 } else { 02221 convert(*ofdt,i); 02222 } 02223 }
void Read | ( | TimeScale * | ts | ) | [protected] |
Definition at line 2191 of file orsa_file.cc.
References orsa::convert(), and OrsaFile::Read().
02191 { 02192 // read_swap(ts,sizeof(TimeScale)); 02193 unsigned int i; 02194 Read(&i); 02195 convert(*ts,i); 02196 }
void Read | ( | UniverseType * | ut | ) | [protected] |
Definition at line 2178 of file orsa_file.cc.
References orsa::convert(), and OrsaFile::Read().
02178 { 02179 // read_swap(ut,sizeof(UniverseType)); 02180 unsigned int i; 02181 Read(&i); 02182 convert(*ut,i); 02183 }
void Read | ( | ReferenceSystem * | rs | ) | [protected] |
Definition at line 2165 of file orsa_file.cc.
References orsa::convert(), and OrsaFile::Read().
02165 { 02166 // read_swap(rs,sizeof(ReferenceSystem)); 02167 unsigned int i; 02168 Read(&i); 02169 convert(*rs,i); 02170 }
void Read | ( | UniverseTypeAwareTimeStep * | ts_in | ) | [protected] |
Definition at line 1895 of file orsa_file.cc.
References Universe::GetUniverseType(), OrsaFile::Read(), orsa::Real, UniverseTypeAwareTimeStep::SetDouble(), UniverseTypeAwareTimeStep::SetTimeStep(), orsa::Simulated, and orsa::universe.
01895 { 01896 switch (universe->GetUniverseType()) { 01897 case Real: { 01898 TimeStep _ts; Read(&_ts); ts_in->SetTimeStep(_ts); 01899 break; 01900 } 01901 case Simulated: { 01902 double tt; Read(&tt); ts_in->SetDouble(tt); 01903 break; 01904 } 01905 } 01906 }
void Read | ( | UniverseTypeAwareTime * | t | ) | [protected] |
Definition at line 1869 of file orsa_file.cc.
References Universe::GetUniverseType(), OrsaFile::Read(), orsa::Real, UniverseTypeAwareTime::SetDate(), UniverseTypeAwareTime::SetTime(), orsa::Simulated, and orsa::universe.
01869 { 01870 switch (universe->GetUniverseType()) { 01871 case Real: { 01872 Date d; Read(&d); t->SetDate(d); 01873 break; 01874 } 01875 case Simulated: { 01876 double tt; Read(&tt); t->SetTime(tt); 01877 break; 01878 } 01879 } 01880 }
void Read | ( | Date * | d | ) | [protected] |
Definition at line 1852 of file orsa_file.cc.
References OrsaFile::Read(), and Date::SetJulian().
01852 { 01853 double j; Read(&j); d->SetJulian(j); 01854 }
void Read | ( | mass_unit * | mu | ) | [protected] |
Definition at line 2152 of file orsa_file.cc.
References orsa::convert(), and OrsaFile::Read().
02152 { 02153 // read_swap(mu,sizeof(mass_unit)); 02154 unsigned int i; 02155 Read(&i); 02156 convert(*mu,i); 02157 }
void Read | ( | length_unit * | lu | ) | [protected] |
Definition at line 2139 of file orsa_file.cc.
References orsa::convert(), and OrsaFile::Read().
02139 { 02140 // read_swap(lu,sizeof(length_unit)); 02141 unsigned int i; 02142 Read(&i); 02143 convert(*lu,i); 02144 }
void Read | ( | time_unit * | tu | ) | [protected] |
Definition at line 2126 of file orsa_file.cc.
References orsa::convert(), and OrsaFile::Read().
02126 { 02127 // read_swap(tu,sizeof(time_unit)); 02128 unsigned int i; 02129 Read(&i); 02130 convert(*tu,i); 02131 }
void Read | ( | InteractionType * | it | ) | [protected] |
Definition at line 2113 of file orsa_file.cc.
References orsa::convert(), and OrsaFile::Read().
02113 { 02114 // read_swap(it,sizeof(InteractionType)); 02115 unsigned int i; 02116 Read(&i); 02117 convert(*it,i); 02118 }
void Read | ( | IntegratorType * | it | ) | [protected] |
Definition at line 2100 of file orsa_file.cc.
References orsa::convert(), and OrsaFile::Read().
02100 { 02101 // read_swap(it,sizeof(IntegratorType)); 02102 unsigned int i; 02103 Read(&i); 02104 convert(*it,i); 02105 }
void Read | ( | double * | d | ) | [protected] |
Definition at line 2075 of file orsa_file.cc.
void Read | ( | int * | i | ) | [protected] |
Definition at line 2067 of file orsa_file.cc.
void Read | ( | unsigned int * | i | ) | [protected] |
Definition at line 2059 of file orsa_file.cc.
void Read | ( | bool * | b | ) | [protected] |
Definition at line 2051 of file orsa_file.cc.
void Read | ( | orsa::Vector * | v | ) | [protected] |
void Read | ( | std::string * | s | ) | [protected] |
Definition at line 2020 of file orsa_file.cc.
References File::file, OrsaFile::Read(), and READ_FILE.
02020 { 02021 unsigned int n; 02022 Read(&n); 02023 if (n > 0) { 02024 char * name = (char*)malloc(n*sizeof(char)); 02025 READ_FILE(name,sizeof(char),n,file); 02026 *s = name; 02027 /* 02028 ORSA_ERROR("Read(std::string *s) n = %i s = %s s->size() = %i strlen(s->c_str()) = %i name = %s", 02029 n,s->c_str(),s->size(),strlen(s->c_str()),name); 02030 */ 02031 free(name); 02032 } 02033 }
void Read | ( | Interaction ** | i | ) | [protected] |
Definition at line 1973 of file orsa_file.cc.
References Newton::IncludeFastRelativisticEffects(), Newton::IncludeMultipoleMoments(), Newton::IncludeRelativisticEffects(), orsa::make_new_interaction(), orsa::NEWTON, and OrsaFile::Read().
01973 { 01974 InteractionType type; Read(&type); 01975 make_new_interaction(i, type); 01976 bool b; Read(&b); (*i)->SkipJPLPlanets(b); 01977 if (type == NEWTON) { 01978 Newton * newton = dynamic_cast <Newton *> (*i); 01979 if (newton) { 01980 Read(&b); newton->IncludeMultipoleMoments(b); 01981 Read(&b); newton->IncludeRelativisticEffects(b); 01982 Read(&b); newton->IncludeFastRelativisticEffects(b); 01983 } else { 01984 b = false; 01985 Read(&b); 01986 Read(&b); 01987 Read(&b); 01988 } 01989 } 01990 }
void Read | ( | Integrator ** | i | ) | [protected] |
Definition at line 1928 of file orsa_file.cc.
References orsa::make_new_integrator(), and OrsaFile::Read().
01928 { 01929 01930 IntegratorType type; Read(&type); 01931 make_new_integrator(i, type); 01932 01933 UniverseTypeAwareTimeStep ts; 01934 Read(&ts); 01935 (*i)->timestep = ts; 01936 01937 double a; Read(&a); 01938 unsigned int m; Read(&m); 01939 01940 (*i)->accuracy = a; 01941 (*i)->m = m; 01942 }
void Read | ( | BodyWithEpoch * | b | ) | [protected] |
Definition at line 1843 of file orsa_file.cc.
References OrsaFile::Read().
01843 { 01844 Read((Body*)b); 01845 UniverseTypeAwareTime b_epoch; Read(&b_epoch); b->SetEpoch(b_epoch); 01846 }
void Read | ( | Body * | b | ) | [protected] |
Definition at line 1825 of file orsa_file.cc.
References OrsaFile::Read(), Body::SetPosition(), and Body::SetVelocity().
01825 { 01826 string b_name; Read(&b_name); 01827 double b_mass; Read(&b_mass); 01828 double b_radius; Read(&b_radius); 01829 JPL_planets b_planet; Read(&b_planet); 01830 01831 *b = Body(b_name,b_mass,b_radius,b_planet); 01832 01833 Vector v; 01834 Read(&v); b->SetPosition(v); 01835 Read(&v); b->SetVelocity(v); 01836 }
void Read | ( | Frame * | f, | |
bool | read_only_r_v = false | |||
) | [protected] |
Definition at line 1793 of file orsa_file.cc.
References OrsaFile::Read(), UniverseTypeAwareTime::SetTime(), and Frame::size().
01793 { 01794 01795 UniverseTypeAwareTime f_time; 01796 Read(&f_time); 01797 f->SetTime(f_time); 01798 unsigned int n = f->size(); 01799 Read(&n); 01800 f->resize(n); 01801 unsigned int j; 01802 Vector v; 01803 if (read_only_r_v) { 01804 for(j=0;j<n;j++) { 01805 Read(&v); (*f)[j].SetPosition(v); 01806 Read(&v); (*f)[j].SetVelocity(v); 01807 } 01808 } else { 01809 for(j=0;j<n;j++) { 01810 Read(&((*f)[j])); 01811 } 01812 } 01813 }
void Read | ( | Evolution ** | e | ) | [protected] |
Definition at line 1695 of file orsa_file.cc.
References Universe::GetUniverseType(), orsa::OFDT_FRAME, OrsaFile::Read(), orsa::Real, and orsa::universe.
01695 { 01696 01697 string name; 01698 Read(&name); 01699 01700 // double sample_period; 01701 UniverseTypeAwareTimeStep sample_period; 01702 Read(&sample_period); 01703 01704 Integrator * integrator = 0; 01705 Read(&integrator); 01706 01707 Interaction * interaction = 0; 01708 Read(&interaction); 01709 01710 make_new_evolution(e); 01711 01712 (*e)->clear(); 01713 01714 (*e)->name = name; 01715 (*e)->SetSamplePeriod(sample_period); 01716 (*e)->SetIntegrator(integrator); 01717 (*e)->SetInteraction(interaction); 01718 01719 delete integrator; 01720 integrator = 0; 01721 01722 delete interaction; 01723 interaction = 0; 01724 01725 unsigned int n; 01726 Read(&n); 01727 (*e)->start_bodies.resize(n); 01728 for(unsigned int j=0;j<n;j++) { 01729 Read(&((*e)->start_bodies[j])); 01730 } 01731 // 01732 if (universe->GetUniverseType() == Real) { 01733 Read(&n); 01734 (*e)->start_JPL_bodies.clear(); 01735 01736 JPL_planets tmp_jp; 01737 for(unsigned int j=0;j<n;j++) { 01738 Read(&tmp_jp); 01739 (*e)->start_JPL_bodies.push_back(tmp_jp); 01740 } 01741 } 01742 01743 // we REALLY need a Frame to keep all the constant values.... 01744 Frame f; 01745 01746 Read(&last_ofdt_read); 01747 /* 01748 { // debug 01749 ORSA_ERROR("Read(Evolution *e) ofdt = %i",last_ofdt_read); 01750 } 01751 */ 01752 if (last_ofdt_read == OFDT_FRAME) { 01753 // the first is different from the others 01754 Read(&f); 01755 (*e)->push_back(f); 01756 } 01757 01758 Read(&last_ofdt_read); 01759 /* 01760 { // debug 01761 ORSA_ERROR("Read(Evolution *e) ofdt = %i",last_ofdt_read); 01762 } 01763 */ 01764 while (last_ofdt_read == OFDT_FRAME) { 01765 Read(&f,true); 01766 (*e)->push_back(f); 01767 Read(&last_ofdt_read); 01768 } 01769 }
void Read | ( | Universe ** | u | ) | [protected] |
Definition at line 1610 of file orsa_file.cc.
References orsa::OFDT_EVOLUTION, OrsaFile::Read(), and orsa::swap().
01610 { 01611 01612 swap_bytes = false; 01613 Read(&byte_order); 01614 if (byte_order != BYTEORDER) { 01615 swap_bytes = true; 01616 swap(&byte_order,sizeof(byte_order)); 01617 } 01618 01619 Read(&orsa_version); 01620 01621 time_unit tu; 01622 length_unit lu; 01623 mass_unit mu; 01624 // 01625 Read(&tu); 01626 Read(&lu); 01627 Read(&mu); 01628 01629 UniverseType ut; 01630 Read(&ut); 01631 01632 ReferenceSystem rs;; 01633 Read(&rs); 01634 01635 TimeScale ts; 01636 Read(&ts); 01637 01638 make_new_universe(u,lu,mu,tu,ut,rs,ts); 01639 01640 Read(&((*u)->name)); 01641 Read(&((*u)->description)); 01642 01643 Read(&last_ofdt_read); // the others are read by the Read(evol..) 01644 /* 01645 { // debug 01646 ORSA_ERROR("Read(Universe *u) ofdt = %i",last_ofdt_read); 01647 } 01648 */ 01649 while (last_ofdt_read == OFDT_EVOLUTION) { 01650 Evolution * e = 0; 01651 Read(&e); 01652 (*u)->push_back(e); 01653 } 01654 }
void Read | ( | ) | [virtual] |
Implements ReadWriteFile.
Definition at line 1553 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().
01553 { 01554 01555 Open(OPEN_R); 01556 01557 if (status != OPEN_R) { 01558 ORSA_ERROR("Status error!"); 01559 return; 01560 } 01561 01562 Read(&universe); 01563 01564 Close(); 01565 01566 ORSA_DEBUG("ORSA file %s [ORSA version: %s, byte order: %i, evolutions: %i, units: [%s,%s,%s]]", 01567 GetFileName().c_str(), orsa_version.c_str(), byte_order,universe->size(), 01568 LengthLabel().c_str(), MassLabel().c_str(),TimeLabel().c_str()); 01569 }
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 }
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().
void Write | ( | TimeStep * | ts | ) | [protected] |
Definition at line 2238 of file orsa_file.cc.
References TimeStep::day_fraction(), TimeStep::days(), TimeStep::sign(), and OrsaFile::Write().
02238 { 02239 unsigned int days = ts->days(); 02240 Write(&days); 02241 // 02242 unsigned int day_fraction = ts->day_fraction(); 02243 Write(&day_fraction); 02244 // 02245 int sign = ts->sign(); 02246 Write(&sign); 02247 }
void Write | ( | JPL_planets * | jp | ) | [protected] |
Definition at line 2225 of file orsa_file.cc.
References OrsaFile::Write().
02225 { 02226 // WRITE_FILE(jp,sizeof(JPL_planets),1,file); 02227 unsigned int i = *jp; 02228 Write(&i); 02229 }
void Write | ( | OrsaFileDataType * | ofdt | ) | [protected] |
Definition at line 2198 of file orsa_file.cc.
References OrsaFile::Write().
02198 { 02199 // WRITE_FILE(ofdt,sizeof(OrsaFileDataType),1,file); 02200 unsigned int i = *ofdt; 02201 Write(&i); 02202 }
void Write | ( | TimeScale * | ts | ) | [protected] |
Definition at line 2185 of file orsa_file.cc.
References OrsaFile::Write().
02185 { 02186 // WRITE_FILE(ts,sizeof(TimeScale),1,file); 02187 unsigned int i = *ts; 02188 Write(&i); 02189 }
void Write | ( | UniverseType * | ut | ) | [protected] |
Definition at line 2172 of file orsa_file.cc.
References OrsaFile::Write().
02172 { 02173 // WRITE_FILE(ut,sizeof(UniverseType),1,file); 02174 unsigned int i = *ut; 02175 Write(&i); 02176 }
void Write | ( | ReferenceSystem * | rs | ) | [protected] |
Definition at line 2159 of file orsa_file.cc.
References OrsaFile::Write().
02159 { 02160 // WRITE_FILE(rs,sizeof(ReferenceSystem),1,file); 02161 unsigned int i = *rs; 02162 Write(&i); 02163 }
void Write | ( | UniverseTypeAwareTimeStep * | ts_in | ) | [protected] |
Definition at line 1882 of file orsa_file.cc.
References UniverseTypeAwareTimeStep::GetDouble(), UniverseTypeAwareTimeStep::GetTimeStep(), Universe::GetUniverseType(), orsa::Real, orsa::Simulated, orsa::universe, and OrsaFile::Write().
01882 { 01883 switch (universe->GetUniverseType()) { 01884 case Real: { 01885 TimeStep _ts = ts_in->GetTimeStep(); Write(&_ts); 01886 break; 01887 } 01888 case Simulated: { 01889 double tt = ts_in->GetDouble(); Write(&tt); 01890 break; 01891 } 01892 } 01893 }
void Write | ( | UniverseTypeAwareTime * | t | ) | [protected] |
Definition at line 1856 of file orsa_file.cc.
References UniverseTypeAwareTime::GetDate(), UniverseTypeAwareTime::GetTime(), Universe::GetUniverseType(), orsa::Real, orsa::Simulated, orsa::universe, and OrsaFile::Write().
01856 { 01857 switch (universe->GetUniverseType()) { 01858 case Real: { 01859 Date d = t->GetDate(); Write(&d); 01860 break; 01861 } 01862 case Simulated: { 01863 double tt = t->GetTime(); Write(&tt); 01864 break; 01865 } 01866 } 01867 }
void Write | ( | Date * | d | ) | [protected] |
Definition at line 1848 of file orsa_file.cc.
References Date::GetJulian(), and OrsaFile::Write().
01848 { 01849 double j = d->GetJulian(); Write(&j); 01850 }
void Write | ( | mass_unit * | mu | ) | [protected] |
Definition at line 2146 of file orsa_file.cc.
References OrsaFile::Write().
02146 { 02147 // WRITE_FILE(mu,sizeof(mass_unit),1,file); 02148 unsigned int i = *mu; 02149 Write(&i); 02150 }
void Write | ( | length_unit * | lu | ) | [protected] |
Definition at line 2133 of file orsa_file.cc.
References OrsaFile::Write().
02133 { 02134 // WRITE_FILE(lu,sizeof(length_unit),1,file); 02135 unsigned int i = *lu; 02136 Write(&i); 02137 }
void Write | ( | time_unit * | tu | ) | [protected] |
Definition at line 2120 of file orsa_file.cc.
References OrsaFile::Write().
02120 { 02121 // WRITE_FILE(tu,sizeof(time_unit),1,file); 02122 unsigned int i = *tu; 02123 Write(&i); 02124 }
void Write | ( | InteractionType * | it | ) | [protected] |
Definition at line 2107 of file orsa_file.cc.
References OrsaFile::Write().
02107 { 02108 // WRITE_FILE(it,sizeof(InteractionType),1,file); 02109 unsigned int i = *it; 02110 Write(&i); 02111 }
void Write | ( | IntegratorType * | it | ) | [protected] |
Definition at line 2094 of file orsa_file.cc.
References OrsaFile::Write().
02094 { 02095 // WRITE_FILE(it,sizeof(IntegratorType),1,file); 02096 unsigned int i = *it; 02097 Write(&i); 02098 }
void Write | ( | double * | d | ) | [protected] |
Definition at line 2071 of file orsa_file.cc.
References File::file, and WRITE_FILE.
02071 { 02072 WRITE_FILE(d,sizeof(double),1,file); 02073 }
void Write | ( | int * | i | ) | [protected] |
Definition at line 2063 of file orsa_file.cc.
References File::file, and WRITE_FILE.
02063 { 02064 WRITE_FILE(i,sizeof(int),1,file); 02065 }
void Write | ( | unsigned int * | i | ) | [protected] |
Definition at line 2055 of file orsa_file.cc.
References File::file, and WRITE_FILE.
02055 { 02056 WRITE_FILE(i,sizeof(unsigned int),1,file); 02057 }
void Write | ( | bool * | b | ) | [protected] |
Definition at line 2047 of file orsa_file.cc.
References File::file, and WRITE_FILE.
02047 { 02048 WRITE_FILE(b,sizeof(bool),1,file); 02049 }
void Write | ( | orsa::Vector * | v | ) | [protected] |
void Write | ( | std::string * | s | ) | [protected] |
Definition at line 1992 of file orsa_file.cc.
References File::file, ORSA_ERROR, OrsaFile::Write(), and WRITE_FILE.
01992 { 01993 const unsigned int size = s->size(); 01994 unsigned int n = 1 + size; 01995 Write(&n); 01996 char * name = (char*)malloc(n*sizeof(char)); 01997 // 01998 // strcpy(name,s->c_str()); 01999 { 02000 unsigned int i; 02001 for (i=0;i<size;++i) { 02002 name[i] = (*s)[i]; 02003 } 02004 name[size] = '\0'; 02005 } 02006 // 02007 WRITE_FILE(name,sizeof(char),n,file); 02008 /* 02009 ORSA_ERROR("Write(std::string *s) n = %i s = %s s->size() = %i strlen(s->c_str()) = %i", 02010 n,s->c_str(),s->size(),strlen(s->c_str())); 02011 */ 02012 free(name); 02013 { // check 02014 if (strlen(s->c_str()) > n) { 02015 ORSA_ERROR("string length problem..."); 02016 } 02017 } 02018 }
void Write | ( | const Interaction * | i | ) | [protected] |
Definition at line 1955 of file orsa_file.cc.
References Interaction::GetType(), Newton::IsIncludingFastRelativisticEffects(), Newton::IsIncludingMultipoleMoments(), Newton::IsIncludingRelativisticEffects(), Interaction::IsSkippingJPLPlanets(), orsa::NEWTON, and OrsaFile::Write().
01955 { 01956 InteractionType type = i->GetType(); Write(&type); 01957 bool b = i->IsSkippingJPLPlanets(); Write(&b); 01958 if (type == NEWTON) { 01959 const Newton * newton = dynamic_cast <const Newton *> (i); 01960 if (newton) { 01961 b = newton->IsIncludingMultipoleMoments(); Write(&b); 01962 b = newton->IsIncludingRelativisticEffects(); Write(&b); 01963 b = newton->IsIncludingFastRelativisticEffects(); Write(&b); 01964 } else { 01965 b = false; 01966 Write(&b); 01967 Write(&b); 01968 Write(&b); 01969 } 01970 } 01971 }
void Write | ( | const Integrator * | i | ) | [protected] |
Definition at line 1909 of file orsa_file.cc.
References Integrator::accuracy, Integrator::GetType(), Integrator::m, Integrator::timestep, and OrsaFile::Write().
01909 { 01910 01911 // IntegratorType it = (*i)->GetType(); 01912 IntegratorType it = i->GetType(); 01913 Write(&it); 01914 01915 // UniverseTypeAwareTimeStep ts = (*i)->timestep; 01916 UniverseTypeAwareTimeStep ts = i->timestep; 01917 Write(&ts); 01918 01919 // double a = (*i)->accuracy; 01920 double a = i->accuracy; 01921 Write(&a); 01922 01923 // unsigned int m = (*i)->m; 01924 unsigned int m = i->m; 01925 Write(&m); 01926 }
void Write | ( | BodyWithEpoch * | b | ) | [protected] |
Definition at line 1838 of file orsa_file.cc.
References OrsaFile::Write().
01838 { 01839 Write((Body*)b); 01840 UniverseTypeAwareTime b_epoch = b->Epoch(); Write(&b_epoch); 01841 }
void Write | ( | Body * | b | ) | [protected] |
Definition at line 1815 of file orsa_file.cc.
References Body::JPLPlanet(), Body::mass(), Body::name(), Body::position(), Body::radius(), Body::velocity(), and OrsaFile::Write().
01815 { 01816 string b_name = b->name(); Write(&b_name); 01817 double b_mass = b->mass(); Write(&b_mass); 01818 double b_radius = b->radius(); Write(&b_radius); 01819 JPL_planets b_planet = b->JPLPlanet(); Write(&b_planet); 01820 Vector v; 01821 v = b->position(); Write(&v); 01822 v = b->velocity(); Write(&v); 01823 }
void Write | ( | Frame * | f, | |
bool | write_only_r_v = false | |||
) | [protected] |
Definition at line 1771 of file orsa_file.cc.
References orsa::OFDT_FRAME, Frame::size(), and OrsaFile::Write().
01771 { 01772 01773 OrsaFileDataType t = OFDT_FRAME; Write(&t); 01774 01775 UniverseTypeAwareTime f_time = *f; 01776 Write(&f_time); 01777 unsigned int n = f->size(); 01778 Write(&n); 01779 // unsigned int j; 01780 Vector v; 01781 if (write_only_r_v) { 01782 for(unsigned int j=0;j<n;j++) { 01783 v = (*f)[j].position(); Write(&v); 01784 v = (*f)[j].velocity(); Write(&v); 01785 } 01786 } else { 01787 for(unsigned int j=0;j<n;j++) { 01788 Write(&((*f)[j])); 01789 } 01790 } 01791 }
void Write | ( | Evolution ** | e | ) | [protected] |
Definition at line 1656 of file orsa_file.cc.
References Universe::GetUniverseType(), orsa::OFDT_EVOLUTION, orsa::Real, orsa::universe, and OrsaFile::Write().
01656 { 01657 01658 OrsaFileDataType t = OFDT_EVOLUTION; Write(&t); 01659 01660 Write(&((*e)->name)); 01661 UniverseTypeAwareTimeStep sp = (*e)->GetSamplePeriod(); Write(&sp); 01662 // const Integrator * itg = (*e)->GetIntegrator(); Write(&itg); 01663 Write((*e)->GetIntegrator()); 01664 // Write(&((*e)->interaction)); 01665 Write((*e)->GetInteraction()); 01666 01667 unsigned int n = (*e)->start_bodies.size(); 01668 Write(&n); 01669 for(unsigned int j=0;j<n;j++) { 01670 Write(&((*e)->start_bodies[j])); 01671 } 01672 // 01673 if (universe->GetUniverseType() == Real) { 01674 n = (*e)->start_JPL_bodies.size(); 01675 Write(&n); 01676 for(unsigned int j=0;j<n;++j) { 01677 Write(&((*e)->start_JPL_bodies[j])); 01678 } 01679 } 01680 01681 // the first only 01682 if ((*e)->size() > 0) Write(&((*(*e))[0])); 01683 01684 // from the second on, write only position and velocity 01685 for(unsigned int j=1;j<(*e)->size();++j) { 01686 Write(&((*(*e))[j]),true); 01687 } 01688 }
void Write | ( | Universe ** | u | ) | [protected] |
Definition at line 1571 of file orsa_file.cc.
References Units::GetLengthBaseUnit(), Units::GetMassBaseUnit(), Units::GetTimeBaseUnit(), ORSA_VERSION, orsa::units, and OrsaFile::Write().
01571 { 01572 01573 // endian issues 01574 byte_order = BYTEORDER; // from config.h 01575 Write(&byte_order); 01576 01577 // various info... 01578 orsa_version = ORSA_VERSION; 01579 Write(&orsa_version); 01580 01581 time_unit tu = units->GetTimeBaseUnit(); 01582 length_unit lu = units->GetLengthBaseUnit(); 01583 mass_unit mu = units->GetMassBaseUnit(); 01584 // 01585 Write(&tu); Write(&lu); Write(&mu); 01586 01587 UniverseType ut = (*u)->GetUniverseType(); 01588 Write(&ut); 01589 01590 ReferenceSystem rs = (*u)->GetReferenceSystem(); 01591 Write(&rs); 01592 01593 TimeScale ts = (*u)->GetTimeScale(); 01594 Write(&ts); 01595 01596 Write(&((*u)->name)); 01597 Write(&((*u)->description)); 01598 01599 unsigned int j; 01600 for(j=0;j<(*u)->size();j++) { 01601 if ((*(*u))[j]!=0) Write(&(*(*u))[j]); 01602 } 01603 }
void Write | ( | ) | [virtual] |
Implements ReadWriteFile.
Definition at line 1532 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().
01532 { 01533 01534 Open(OPEN_W); 01535 01536 if (status != OPEN_W) { 01537 ORSA_ERROR("Status error!"); 01538 return; 01539 } 01540 01541 if (!universe) { 01542 ORSA_ERROR("cannot write a non-allocated universe!"); 01543 return; 01544 } 01545 01546 Write(&universe); 01547 01548 FLUSH_FILE(file); 01549 01550 Close(); 01551 }
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().
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_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().