Workspace 6.21.5
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
BaseReader Class Referenceabstract

Base class from which all file readers must inherit. More...

#include <Mesh/FileIO/Readers/basereader.h>

Inheritance diagram for BaseReader:
[legend]

Public Member Functions

 BaseReader (const std::string &fName)
 
 ~BaseReader () override=default
 Have virtual functions, so also have a virtual destructor.
 
virtual void Close ()
 
std::string ExtractBaseName (const std::string &fileName)
 
int FileLength ()
 
int FilePosition ()
 
void Flush ()
 
std::string GetBaseName () const
 
std::string GetBaseNameSuffix () const
 
std::string GetFileName () const
 
virtual std::string GetFormatExtension () const =0
 
virtual std::string GetFormatName () const =0
 
bool GetTerminateExecution () const
 
bool IsOpen () const
 
bool IsReady () const
 
virtual std::string Open ()
 
void SetBaseName (const std::string &base)
 
void SetBaseNameSuffix (const std::string &suffix)
 
void SetBaseNameSuffix (double caseNum, const std::string &caseLabel="_")
 
void SetBaseNameSuffix (int caseNum, const std::string &caseLabel="_")
 
template<typename T >
void SetBaseNameSuffix (T caseNum, const std::string &caseLabel="_")
 
void SetFileName (const std::string &fileName)
 
virtual void SetProgress (int progress)
 
void SetTerminateExecution (bool b)
 
- Public Member Functions inherited from Logger
 Logger ()
 The default constructor logs to standard output with a plain text log mode.
 
 Logger (const Logger &logger)
 
virtual ~Logger ()
 We own the log mode, so delete it.
 
std::string ErrorOff () const
 
std::string ErrorOn () const
 
std::ostream & GetLog () const
 
const LogModeGetLogMode () const
 
void SetLog (std::ostream &log)
 
void SetLogMode (const LogMode &logMode)
 
void SetLogModeHTML ()
 
void SetLogModePlainText ()
 Set log mode to plain text output.
 
template<Styles s>
void StyleOff () const
 
template<Styles s>
void StyleOn () const
 
std::string WarningOff () const
 
std::string WarningOn () const
 
- Public Member Functions inherited from Observable
virtual ~Observable ()
 
void attachObserver (Observer &observer)
 
void destroy ()
 
void detachObserver (Observer &observer)
 
void notifyEvent (const ObservableEvent &event)
 

Protected Member Functions

bool GetNextNonBlankLine (std::string &inputLine)
 
virtual void postFileNameChanged ()
 
- Protected Member Functions inherited from Logger
virtual void LogChanged ()
 
virtual void LogModeChanged ()
 
- Protected Member Functions inherited from Observable
 Observable ()
 
 Observable (const Observable &)
 

Protected Attributes

std::string baseName
 
std::string baseNameSuffix
 
iautogzstream inFile
 
int progress_
 
bool terminateExecution_
 

Additional Inherited Members

- Public Types inherited from Logger
enum  Styles { Warning , Error , Preformat }
 

Detailed Description

Constructor & Destructor Documentation

◆ BaseReader()

BaseReader ( const std::string &  fName)
Parameters
fNameDefines the base file name for the reader. The file name extension can be omitted if it matches the return value of GetFormatExtension().

The constructor initially sets the baseNameSuffix data member to an empty string. This suffix is easily changed through a call to SetBaseNameSuffix(). The final file name is constructed as the base file name (fName), followed by the base filename suffix (set with SetBaseNameSuffix()) and then the filename extension if necessary.

◆ ~BaseReader()

~BaseReader ( )
overridedefault

Member Function Documentation

◆ Close()

virtual void Close ( )
inlinevirtual

Close the file, if it is open. The user would not normally need to do this, as it is handled automatically by the read functions.

◆ ExtractBaseName()

std::string ExtractBaseName ( const std::string &  fileName)
Returns
The name of the file fileName without the path, the filename suffix and the extension.

◆ FileLength()

int FileLength ( )
Returns
The total file size of the current file being read.

◆ FilePosition()

int FilePosition ( )
Returns
The current position within the file being read.

◆ Flush()

void Flush ( )
inline

Flush the file's contents. Not usually called directly by the user and questionable whether it should ever be used at all for reading a file.

◆ GetBaseName()

std::string GetBaseName ( ) const
inline
Returns
The name of the file without path. The filename extension will also typically be omitted.

◆ GetBaseNameSuffix()

std::string GetBaseNameSuffix ( ) const
inline

◆ GetFileName()

std::string GetFileName ( ) const
Returns
The name of the file without path. The filename suffix and extension will be included.

◆ GetFormatExtension()

virtual std::string GetFormatExtension ( ) const
pure virtual
Returns
The default file name extension for this format.

Implemented in IGESReader, NastranReader, STLReader, and TecPlotReader.

◆ GetFormatName()

virtual std::string GetFormatName ( ) const
pure virtual
Returns
The name of the format this reader expects.

Implemented in IGESReader, NastranReader, STLReader, and TecPlotReader.

◆ GetNextNonBlankLine()

bool GetNextNonBlankLine ( std::string &  inputLine)
protected

◆ GetTerminateExecution()

bool GetTerminateExecution ( ) const
inline

◆ IsOpen()

bool IsOpen ( ) const
inline
Returns
True if the file is currently open.

◆ IsReady()

bool IsReady ( ) const
inline
Returns
True if the file is open and ready for writing.

◆ Open()

std::string Open ( )
virtual

Open the input file with the current name settings. The user would not normally need to do this, as it is handled automatically by the various Read() functions.

Returns
The name of the input file, including any filename extension used. If a file could not be opened, an empty string is returned.

◆ postFileNameChanged()

virtual void postFileNameChanged ( )
inlineprotectedvirtual

◆ SetBaseName()

void SetBaseName ( const std::string &  base)
inline
Parameters
baseThe name of the file to read, typically without the filename extension.

If the reader currently has a file open, it will be closed by this call.

Additionally, postFileNameChanged is called; by default, it does nothing; however, since it is a virtual function, derived classes may wish to reimplement it whenever the base file has changed.

◆ SetBaseNameSuffix() [1/4]

void SetBaseNameSuffix ( const std::string &  suffix)
inline

◆ SetBaseNameSuffix() [2/4]

void SetBaseNameSuffix ( double  caseNum,
const std::string &  caseLabel = "_" 
)
inline

◆ SetBaseNameSuffix() [3/4]

void SetBaseNameSuffix ( int  caseNum,
const std::string &  caseLabel = "_" 
)
inline

◆ SetBaseNameSuffix() [4/4]

void SetBaseNameSuffix ( caseNum,
const std::string &  caseLabel = "_" 
)
inline

◆ SetFileName()

void SetFileName ( const std::string &  fileName)
Parameters
fileNameThe name of the file to read. The extension is optional, but if both compressed and uncompressed files exist, the extension should be explicitly included to ensure the right one is selected.

If the reader currently has a file open, it will be closed by this call. Note that this also checks for .gz as part of the file name extension to support reading from compressed files.

Note
Any base name suffix will be included as part of the base name by this call, so if you really want to use the suffix functionality, don't use this function. The suffix functionality will be removed in a future version anyway.

◆ SetProgress()

void SetProgress ( int  progress)
virtual

◆ SetTerminateExecution()

void SetTerminateExecution ( bool  b)
inline

Member Data Documentation

◆ baseName

std::string baseName
protected

◆ baseNameSuffix

std::string baseNameSuffix
protected

◆ inFile

iautogzstream inFile
protected

◆ progress_

int progress_
protected

◆ terminateExecution_

bool terminateExecution_
protected