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

Base class from which all file writers must inherit.

#include <Mesh/FileIO/Writers/basewriter.h>

Inheritance diagram for BaseWriter:
[legend]

Public Member Functions

 BaseWriter (const std::string &fName)
 
 BaseWriter (std::ostream &os)
 
 ~BaseWriter () override=default
 
void Close ()
 
void Flush ()
 Flush the file's contents. Not usually called directly by the user.
 
std::string GetBaseName () const
 
std::string GetBaseNameSuffix () const
 
std::string GetFileName () const
 
virtual std::string GetFormatExtension () const =0
 
virtual std::string GetFormatName () const =0
 
double GetScaleFactor () const
 
bool IsReady () const
 
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 SetScaleFactor (double scale)
 
void SetUseCompressionOff ()
 Do not use on-the-fly compression when writing to file.
 
void SetUseCompressionOn ()
 Use on-the-fly compression when writing to file.
 
bool UsingCompression () const
 
- 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 Attributes

std::string baseName_
 
std::string baseNameSuffix_
 
oautogzstream outFile_
 
int progress_ {}
 
double scaleFactor_
 
bool useCompression_
 

Additional Inherited Members

- Public Types inherited from Logger
enum  Styles { Warning , Error , Preformat }
 
- Protected Member Functions inherited from Logger
virtual void LogChanged ()
 
virtual void LogModeChanged ()
 
- Protected Member Functions inherited from Observable
 Observable ()
 
 Observable (const Observable &)
 

Constructor & Destructor Documentation

◆ BaseWriter() [1/2]

BaseWriter ( const std::string &  fName)
Parameters
fNameDefines the base file name for the writer. 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.

◆ BaseWriter() [2/2]

BaseWriter ( std::ostream &  os)
inline

◆ ~BaseWriter()

~BaseWriter ( )
overridedefault

Member Function Documentation

◆ Close()

void Close ( )
inline

Close the file previously opened for writing. It is not usually necessary to call this function directly, since the Write() function will handle opening and closing of files.

◆ Flush()

void Flush ( )
inline

◆ 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 NastranWriter.

◆ GetFormatName()

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

Implemented in NastranWriter.

◆ GetScaleFactor()

double GetScaleFactor ( ) const
inline
Returns
The scale factor being applied to the node positions.

◆ IsReady()

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

◆ Open()

std::string Open ( )

Open the output file with the current name settings. It is not usually necessary to call this function directly, since the Write() function will handle opening and closing of files.

Returns
The name of the output file including all suffixes and file extensions. If a file could not be opened, an empty string is returned.

◆ SetBaseName()

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

◆ 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 write. 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 writer 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 writing to 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

◆ SetScaleFactor()

void SetScaleFactor ( double  scale)
inline
Parameters
scaleThe node positions will be scaled by this amount when output to file.

◆ SetUseCompressionOff()

void SetUseCompressionOff ( )
inline

◆ SetUseCompressionOn()

void SetUseCompressionOn ( )
inline

◆ UsingCompression()

bool UsingCompression ( ) const
inline
Returns
True if on-the-fly compression is being used when writing to file.

Member Data Documentation

◆ baseName_

std::string baseName_
protected

◆ baseNameSuffix_

std::string baseNameSuffix_
protected

◆ outFile_

oautogzstream outFile_
protected

◆ progress_

int progress_ {}
protected

◆ scaleFactor_

double scaleFactor_
protected

◆ useCompression_

bool useCompression_
protected