ReadWriteFile Class Reference

Read and write files class. More...

#include <orsa_file.h>

Inheritance diagram for ReadWriteFile:

Inheritance graph
[legend]
Collaboration diagram for ReadWriteFile:

Collaboration graph
[legend]

List of all members.

Public Member Functions

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

Protected Attributes

std::string filename
FILE_TYPE file
FILE_STATUS status


Detailed Description

Read and write files class.

Definition at line 136 of file orsa_file.h.


Constructor & Destructor Documentation

ReadWriteFile (  )  [inline]

Definition at line 138 of file orsa_file.h.

00138 : File() { }


Member Function Documentation

void Open ( const FILE_STATUS  st = OPEN_R  ) 

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:

virtual void Read (  )  [pure virtual]

Implemented in OrsaFile, and OrsaConfigFile.

virtual void Write (  )  [pure virtual]

Implemented in OrsaFile, and OrsaConfigFile.

void Close (  )  [inherited]

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]

FILE_TYPE file [protected, inherited]

FILE_STATUS status [protected, inherited]


The documentation for this class was generated from the following files:

Generated on Thu Feb 14 21:41:43 2008 for liborsa by  doxygen 1.5.5