EPICS ARCHIVER V4
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Friends | List of all members
DataFile Class Reference

Binary Data File. More...

#include <DataFile.h>

Public Member Functions

DataFilereference ()
 Add reference to current DataFile.
 
size_t refCount () const
 Get reference count.
 
bool isTaggedFile ()
 Does the file follow the 2-1-1 format w/ cookie and tags?
 
void release ()
 De-reference a data file (Call instead of delete). More...
 
bool is_writable () const
 Returns true if DataFile is writable.
 
FileOffset getSize () const
 Get current file size in bytes. More...
 
void reopen ()
 Closes and re-opens a DataFile. More...
 
const stdString & getFilename ()
 Get full name of data file.
 
const stdString & getDirname ()
 Get directory name of data file.
 
const stdString & getBasename ()
 Get base name of data file.
 
class DataHeadergetHeader (FileOffset offset)
 Read header at given offset. More...
 
size_t getHeaderSize (const stdString &name, DbrType dbr_type, DbrCount dbr_count, size_t num_samples)
 Get size of a header with given parameters.
 
class DataHeaderaddHeader (const stdString &name, DbrType dbr_type, DbrCount dbr_count, double period, size_t num_samples)
 Add a new DataHeader to the file. More...
 
void addCtrlInfo (const CtrlInfo &info, FileOffset &offset)
 Add CtrlInfo to the data file. More...
 
void write (const CtrlInfo &ctrlInfo, FileOffset offset)
 Write ctrlInfo.
 
void read (CtrlInfo &ctrlInfo, FileOffset offset)
 Read ctrlInfo.
 

Static Public Member Functions

static DataFilereference (const stdString &dirname, const stdString &basename, bool for_write)
 Reference a data file. More...
 
static void show_all_sizes ()
 Show all size.
 
static size_t clear_cache ()
 Close as many data files as possible. More...
 
static void close_all ()
 Close all data files. More...
 

Public Attributes

bool is_new_file
 Indicates if this file was newly created.
 

Static Public Attributes

static const uint32_t cookie = 0x41444631
 == 'ADF1', Archive Data File 1
 

Friends

class DataHeader
 
class DataWriter
 
class RawDataReaderEA3
 

Detailed Description

Binary Data File.

The DataFile class handles access to the binary data files. One important feature is reference counting and caching. When the ArchiveEngine adds samples, it is very likely to add samples for several channels to the same collection of data files.

Member Function Documentation

void DataFile::addCtrlInfo ( const CtrlInfo info,
FileOffset offset 
)

Add CtrlInfo to the data file.

Parameters
infoinfo
offsetis set to offset of the info
Exceptions
GenericExceptionin case of error.
class DataHeader* DataFile::addHeader ( const stdString &  name,
DbrType  dbr_type,
DbrCount  dbr_count,
double  period,
size_t  num_samples 
)

Add a new DataHeader to the file.

Returns
Alloc'ed header. The header's data type and buffer size info will be initialized. Links (dir, prev, next) need to be configured and saved.
Exceptions
GenericExceptionin case of error.
static size_t DataFile::clear_cache ( )
static

Close as many data files as possible.

Closes all data files that are fully released. For example, the SpreadsheetReader will invoke this in its destructor. Since there might be other readers still open, only the application can decide when to close all files, which it should do via close_all.

See Also
close_all
Returns
Returns the number of files which are left open because there is still a reference to them.
static void DataFile::close_all ( )
static

Close all data files.

The application should invoke this at times where it assumes that all readers/writers are done to check consistency and prevent files left dangling open.

See Also
clear_cache
Exceptions
GenericExceptionif data files are referenced (because there's still a reader?).
class DataHeader* DataFile::getHeader ( FileOffset  offset)

Read header at given offset.

Returns
Alloc'ed DataHeader, to be relased by caller.
Exceptions
GenericExceptionin case of error.
FileOffset DataFile::getSize ( ) const

Get current file size in bytes.

Exceptions
GenericExceptionon file seek error.
static DataFile* DataFile::reference ( const stdString &  dirname,
const stdString &  basename,
bool  for_write 
)
static

Reference a data file.

Either opens a new one, or returns another reference to a file that is in the DataFile cache.

Parameters
dirname,:Path/directory up to the filename
basename,:filename inside dirname
for_write,:open for writing or read-only?

The reference call will normalize the dirname/basename/filename. As an example, it's acceptable to pass a basename that still contains pieces of a pathname, which will then be moved into the dirname.

Returns
The referenced DataFile. Do not delete; use release.
See Also
release
Exceptions
GenericExceptionon error.
void DataFile::release ( )

De-reference a data file (Call instead of delete).

See Also
clear_cache
void DataFile::reopen ( )

Closes and re-opens a DataFile.

For synchr. with a file that's actively written by another prog. is might help to reopen.

Exceptions
GenericExceptionon error.

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