VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
DtReaderWriterFile Class Reference

Using a DtReaderWriterFile allows a DtReaderWriter object to be read in from an MTL stream contained in an external file. For instance, the signature object sensor uses a DtReaderWriterFile for its "combat-identification-level-table-file" parameter. Once the file is created, setObjectToReadAndWrite must be called before use.

Inheritance diagram for DtReaderWriterFile:
Inheritance graph
[legend]

Public Member Functions

 DtReaderWriterFile ()
 
 DtReaderWriterFile (const DtString &name, DtReaderWriterRegistry *parentRegistry=NULL)
 
 DtReaderWriterFile (const DtSymbolString &name, DtReaderWriterRegistry *parentRegistry=NULL)
 
 DtReaderWriterFile (const DtString &name, const DtReaderWriterFile &orig, DtReaderWriterRegistry *parentRegistry=NULL)
 
 DtReaderWriterFile (const DtSymbolString &name, const DtReaderWriterFile &orig, DtReaderWriterRegistry *parentRegistry=NULL)
 
DtReaderWriterFile & operator= (const DtReaderWriterFile &orig)
 
DtReaderWriterFile & operator= (const DtFilename &orig)
 
virtual ~DtReaderWriterFile () override
 
DtReaderWriterFile * clone (const DtString &name, DtReaderWriterRegistry *parentRegistry=NULL)
 
DtReaderWriterFile * clone (const DtSymbolString &name, DtReaderWriterRegistry *parentRegistry=NULL)
 
virtual void getSelf (DtlObjPtr args, const DtReaderWriter::SearchPaths &searchPaths, const DtVariableBindingsList &variableBindings) override
 
virtual bool saveFile (const DtFilename &filename)
 
virtual bool loadFile (const DtReaderWriter::SearchPaths &searchPaths, const DtVariableBindingsList &variableBindings, DtlObjStringMap *commentMap=NULL)
 
virtual void putSelf (std::string &fp, int indentLevel, bool writeUnspecified, const DtFilename &path) override
 
virtual void setObjectToReadAndWrite (DtReaderWriter *object)
 
virtual const DtReaderWriter & objectToReadAndWrite () const
 
virtual void setFilename (const DtString &filename)
 
virtual void setFilename (const DtString &filename, const DtString &unsubstitutedFilename)
 
virtual const DtString & filename () const
 
virtual DtString unsubstitutedFilename () const
 
virtual void setUnsubstitudedFilename (const DtString &f)
 
virtual const DtFilename & filenameLastReadIn () const
 
virtual void setFileReadOnly (bool readOnly=true)
 
virtual bool fileReadOnly () const
 
virtual const char * readerWriterType () const override
 
virtual void substitute (const DtVariableBindingsList &variableBindings)
 
bool operator== (const DtReaderWriterFile &) const
 
- Public Member Functions inherited from DtReaderWriter
 DtReaderWriter ()
 
 DtReaderWriter (const DtString &name, DtReaderWriterRegistry *parentRegistry=NULL, bool readonly=false)
 
 DtReaderWriter (const DtSymbolString &name, DtReaderWriterRegistry *parentRegistry=NULL, bool readonly=false)
 
 DtReaderWriter (const DtString &name, const DtReaderWriter &orig, DtReaderWriterRegistry *parentRegistry=NULL)
 
 DtReaderWriter (const DtSymbolString &name, const DtReaderWriter &orig, DtReaderWriterRegistry *parentRegistry=NULL)
 
 DtReaderWriter (const DtReaderWriter &, DtReaderWriterRegistry *parentRegistry=NULL)
 
const DtReaderWriter & operator= (const DtReaderWriter &orig)
 
bool operator== (const DtReaderWriter &) const
 
bool operator!= (const DtReaderWriter &rhs) const
 
virtual ~DtReaderWriter ()
 
virtual void postPutSelf ()
 
virtual void prePutSelf ()
 
virtual void postGetSelf ()
 
virtual void preGetSelf ()
 
virtual void writeSelf (std::string &fp, int indentLevel=0, bool writeUnspecified=false, const DtFilename &path=DtFilename::nullFilename())
 
virtual DtSymbolString name () const
 
virtual void addAlias (const DtSymbolString &alias)
 
virtual void addAlias (const DtString &alias)
 
virtual bool hasAlias (const DtSymbolString &alias)
 
virtual const aliasContainer & aliases () const
 
virtual void setReadonly (bool flag)
 
bool isReadonly () const
 
virtual void reset ()
 
virtual int alignment () const
 
virtual bool variableIsBound () const
 
virtual void unbindVariable ()
 
virtual void setName (const DtString &)
 
virtual const char * xmlType () const
 
virtual DtString prettyPrint () const
 
std::string debugText () const
 
virtual void bindVariables (DtVariableBindingsList variableBindings)
 
virtual std::list
< DtVariableNameType > 
unboundVariables () const
 
bool invalid () const
 
virtual bool hasChild (const DtReaderWriter *p) const
 
virtual bool hasVariableReference () const
 
virtual void bindLocalVariables (const DtVariableBindingsList &variableBindings)
 
virtual void recordUpdateTime () const
 
virtual bool changedSinceLastChecked ()
 
virtual bool peekChangedSinceLastChecked () const
 
virtual void putData (std::string &fp, int indentLevel=0)
 
virtual DtlObjPtr getData (DtlObjPtr args, const SearchPaths &searchPaths, const DtVariableBindingsList &variableBindings)
 
virtual void setValueSpecified (bool specified, bool recurse=false)
 
virtual bool valueSpecified () const
 
virtual bool isVariableReference () const
 
virtual void setIsVariableReference (bool value)
 
virtual void clearAllVariableReferenceFlags ()
 
virtual DtSymbolString variableName () const
 
virtual void setVariableName (const DtSymbolString variableName)
 
virtual const DtReaderWriter * defaultRWValue () const
 
virtual DtReaderWriter * defaultRWValue ()
 
virtual void setDefaultRWValue (DtReaderWriter *)
 
virtual bool checkAndSetDefaultRWValue (DtlObjPtr args, const DtReaderWriter::SearchPaths &searchPaths=SearchPaths(), const DtVariableBindingsList &variableBindings=nullVariableReference())
 
const DtReaderWriterRegistry & registry () const
 
DtReaderWriterRegistry & registry ()
 
virtual DtPropertyInterface * property ()
 
virtual const DtPropertyInterface * property () const
 
virtual DtString toXml () const
 
virtual DtRwVariableBindings * generateVariableBindings () const
 
virtual bool toXml (const DtFilename &) const
 
virtual bool fromXml (const DtString &)
 
virtual bool fromXmlFile (const DtFilename &)
 
virtual void putSelf (DtEnvironmentSP, DtEnvValueSP parent) const
 
virtual void putData (DtEnvironmentSP, DtEnvValueSP value) const
 
virtual void putVariableReference (DtEnvironmentSP, DtEnvValueSP value) const
 
virtual void getSelf (const DtEnvironmentSP, const DtEnvValueSP root, const SearchPaths &searchPaths=SearchPaths(), const DtVariableBindingsList &bindings=DtVariableBindingsList())
 
virtual void getData (const DtEnvironmentSP, const DtEnvValueSP, const SearchPaths &searchPaths=SearchPaths(), const DtVariableBindingsList &bindings=DtVariableBindingsList())
 
virtual void unrecognizedItem (const DtEnvironmentSP env, const DtEnvValueSP root, const SearchPaths &searchPaths, const DtVariableBindingsList &varBindings)
 
virtual void getVariableReference (DtEnvironmentSP, DtEnvValueSP value)
 

Static Public Member Functions

static const DtFilename & appPath ()
 
static DtFilename findHighestPriorityFile (const DtFilename &filename, const DtReaderWriter::SearchPaths &searchPaths, bool warnOnNotFound=true)
 
static FILE * loadHighestPriorityFile (const DtFilename &filename, const DtReaderWriter::SearchPaths &searchPaths, bool warnOnNotFound=true)
 
static FILE * loadHighestPriorityFile (const DtFilename &filename, const DtReaderWriter::SearchPaths &searchPaths, DtFilename &successfulPath, bool warnOnNotFound=true)
 
static DtFilename createPathFragment (const DtFilename &filename, const DtReaderWriter::SearchPaths &searchPaths)
 
static std::vector< DtFilename > findFilesByExtension (const DtString &path, const DtString &extension)
 
- Static Public Member Functions inherited from DtReaderWriter
static void putIndent (std::string &fp, int indentLevel)
 
static const
DtVariableBindingsList & 
nullVariableReference ()
 
static void setPostGetSelfCallback (DtGetSelfCallbackFcn fcn, void *usrData)
 
static void setPrePutSelfCallback (DtPutSelfCallbackFcn fcn, void *usrData)
 
static void setPutIndent (bool)
 
static bool putIndent ()
 
static const char * theXmlType ()
 
static const DtFilename & appPath ()
 
static void setFactoryCreatorFunction (DtReaderWriterFactoryCreatorFcn fcn)
 
static void createReaderWriterFactory ()
 
static void cleanupFactory ()
 
static DtReaderWriterFactory * factory ()
 
static void setOutputStream (DtOutputStream *stream)
 
static DtOutputStream & outputStream ()
 
static DtReaderWriter * createFromXmlFile (const DtFilename &, bool createAsProperty=false)
 
static DtReaderWriter * createFromXml (const DtString &, bool createAsProperty=false)
 
static DtReaderWriter * createFromEnvironment (DtEnvironmentSP, bool createAsProperty=false)
 
static DtString getAttribute (DtEnvironmentSP env, const DtString &name, DtEnvValueSP root)
 

Protected Member Functions

bool getFilenameToWrite (const DtFilename &path, const DtFilename &filename, DtFilename &filenameToWrite) const
 
- Protected Member Functions inherited from DtReaderWriter
virtual void bindToRwAsVariable (const DtReaderWriter *rw)
 

Protected Attributes

DtRwString myFilename
 
DtReaderWriter * myObjectToReadAndWrite
 
bool myFileReadOnly
 
DtFilename myFilenameLastReadIn
 
DtString myVariableSubstitutedFilename
 
- Protected Attributes inherited from DtReaderWriter
const DtSymbolString myName
 
DtReaderWriterRegistry myRegistry
 
DtReaderWriterRegistry * myParentRegistry
 
bool myValueSpecified
 
bool myReadOnlyFlag
 
bool myIsVariableReference
 
DtSymbolString myVariableName
 
bool myVariableIsBound
 
DtReaderWriter * myDefaultValue
 
aliasContainer myAliases
 
bool myInvalid
 
bool myChangedFlag
 

Additional Inherited Members

- Public Types inherited from DtReaderWriter
typedef std::vector
< DtSymbolString > 
aliasContainer
 
typedef std::vector
< DtSymbolString >::iterator 
aliasIter
 
typedef std::vector
< DtSymbolString >
::const_iterator 
aliasConstIter
 
typedef std::vector< DtFilename > SearchPaths
 
typedef std::pair
< DtSymbolString, DtString > 
DtVariableNameType
 
typedef DtReaderWriterFactory *(* DtReaderWriterFactoryCreatorFcn )()
 
- Static Protected Attributes inherited from DtReaderWriter
static DtString theUnspecifiedValue
 
static DtGetSelfCallbackInfo thePostGetSelfCallback
 
static DtPutSelfCallbackInfo thePrePutSelfCallback
 
static const DtVariableBindingsList theEmptyVariableBindingsList
 
static bool theCreatorFcnSet
 
static DtReaderWriterFactory * theFactory
 
static
DtReaderWriterFactoryCreatorFcn 
theFactoryCreatorFcn
 
static bool thePutIndent
 
static DtOutputStream * theOutputStream
 

Constructor & Destructor Documentation

DtReaderWriterFile::DtReaderWriterFile ( )

default constructor

DtReaderWriterFile::DtReaderWriterFile ( const DtString &  name,
DtReaderWriterRegistry *  parentRegistry = NULL 
)

real constructor

DtReaderWriterFile::DtReaderWriterFile ( const DtSymbolString &  name,
DtReaderWriterRegistry *  parentRegistry = NULL 
)
DtReaderWriterFile::DtReaderWriterFile ( const DtString &  name,
const DtReaderWriterFile &  orig,
DtReaderWriterRegistry *  parentRegistry = NULL 
)

copy constructor

DtReaderWriterFile::DtReaderWriterFile ( const DtSymbolString &  name,
const DtReaderWriterFile &  orig,
DtReaderWriterRegistry *  parentRegistry = NULL 
)
virtual DtReaderWriterFile::~DtReaderWriterFile ( )
overridevirtual

destructor

Member Function Documentation

DtReaderWriterFile& DtReaderWriterFile::operator= ( const DtReaderWriterFile &  orig)

assignment operator

DtReaderWriterFile& DtReaderWriterFile::operator= ( const DtFilename &  orig)
DtReaderWriterFile* DtReaderWriterFile::clone ( const DtString &  name,
DtReaderWriterRegistry *  parentRegistry = NULL 
)

clone

DtReaderWriterFile* DtReaderWriterFile::clone ( const DtSymbolString &  name,
DtReaderWriterRegistry *  parentRegistry = NULL 
)
virtual void DtReaderWriterFile::getSelf ( DtlObjPtr  args,
const DtReaderWriter::SearchPaths &  searchPaths,
const DtVariableBindingsList &  variableBindings 
)
overridevirtual

Top level to read itself from an input stream. searchPath is the name of the directory in which to locate it's filename to load.

Reimplemented from DtReaderWriter.

virtual bool DtReaderWriterFile::saveFile ( const DtFilename &  filename)
virtual

Saves contents of file to specified filename.

virtual bool DtReaderWriterFile::loadFile ( const DtReaderWriter::SearchPaths &  searchPaths,
const DtVariableBindingsList &  variableBindings,
DtlObjStringMap *  commentMap = NULL 
)
virtual

Returns true if file is loaded.

Reimplemented in DtReaderWriterFileExtensible.

Referenced by DtFormationTable::FormationAdder::operator()().

virtual void DtReaderWriterFile::putSelf ( std::string &  fp,
int  indentLevel,
bool  writeUnspecified,
const DtFilename &  path 
)
overridevirtual

Top level call to write itself to file. The path prepended to the filename before writing the entry to file.

Reimplemented from DtReaderWriter.

virtual void DtReaderWriterFile::setObjectToReadAndWrite ( DtReaderWriter *  object)
virtual

Sets the DtReaderWriter to be read from and written to the file.

virtual const DtReaderWriter& DtReaderWriterFile::objectToReadAndWrite ( ) const
virtual

Returns the DtReaderWriter to be read from and written to the file.

static const DtFilename& DtReaderWriterFile::appPath ( )
static

Gets the current working directory. Calls DtReaderWriter::appPath().

virtual void DtReaderWriterFile::setFilename ( const DtString &  filename)
virtual

Name of the file to to write. If path is absolute, this is the filename that will be written in putSelf(). If filename is relative, it will be combined with the path passed into putSelf(). If variables are specified in the filename, they will be substituted with their values before being returned by this method. This sets both the full filename and the unsubstituted filename to this string, essentially removing any variables.

virtual void DtReaderWriterFile::setFilename ( const DtString &  filename,
const DtString &  unsubstitutedFilename 
)
virtual

Sets the filename in the same way as setFilename(const DtString& filename), but additionally sets the unsubstituted filename to the specified string.

Note
Use this method with caution. You must set the filename and unsubstituted filename to equivalent values if they are to be read in correctly.
virtual const DtString& DtReaderWriterFile::filename ( ) const
virtual

If variables are specified in the filename, they will be substituted with their values before being returned by this method. Use unsubstitutedFilename() to get the string with variables still in it.

virtual DtString DtReaderWriterFile::unsubstitutedFilename ( ) const
virtual
Returns
The filename of the file without any variable substitutions.
virtual void DtReaderWriterFile::setUnsubstitudedFilename ( const DtString &  f)
virtual

Sets the unsubsituted filename in the myFileame object.

virtual const DtFilename& DtReaderWriterFile::filenameLastReadIn ( ) const
virtual

Name of file most recently read in by getSelf()

virtual void DtReaderWriterFile::setFileReadOnly ( bool  readOnly = true)
virtual

By default, DtReaderWriterFile reads a file that has been specified, but when it writes itself, it only writes the filename. If you want it to write not only the filename but also write the 'objectToReadAndWrite', call setFileReadOnly(false).

virtual bool DtReaderWriterFile::fileReadOnly ( ) const
virtual
virtual const char* DtReaderWriterFile::readerWriterType ( ) const
overridevirtual

Used to supply a string type that this reader writer type is. This can be used in place of dynamic-casting. Also used by the opd editor to determine which type of control to create.

Reimplemented from DtReaderWriter.

virtual void DtReaderWriterFile::substitute ( const DtVariableBindingsList &  variableBindings)
virtual

Substitutes any variables in the list to variable substituted filename.

Reimplemented in DtReaderWriterFileExtensible.

bool DtReaderWriterFile::operator== ( const DtReaderWriterFile &  ) const

Only compares filenames, not contents.

static DtFilename DtReaderWriterFile::findHighestPriorityFile ( const DtFilename &  filename,
const DtReaderWriter::SearchPaths &  searchPaths,
bool  warnOnNotFound = true 
)
static
static FILE* DtReaderWriterFile::loadHighestPriorityFile ( const DtFilename &  filename,
const DtReaderWriter::SearchPaths &  searchPaths,
bool  warnOnNotFound = true 
)
static
static FILE* DtReaderWriterFile::loadHighestPriorityFile ( const DtFilename &  filename,
const DtReaderWriter::SearchPaths &  searchPaths,
DtFilename &  successfulPath,
bool  warnOnNotFound = true 
)
static
static DtFilename DtReaderWriterFile::createPathFragment ( const DtFilename &  filename,
const DtReaderWriter::SearchPaths &  searchPaths 
)
static
static std::vector<DtFilename> DtReaderWriterFile::findFilesByExtension ( const DtString &  path,
const DtString &  extension 
)
static
bool DtReaderWriterFile::getFilenameToWrite ( const DtFilename &  path,
const DtFilename &  filename,
DtFilename &  filenameToWrite 
) const
protected

Get the filename to write, given a path and base filename. If filename is absolute, sets filenameToWrite to filename and returns true. If filename is relative, combines the path with the filename, creating the directory if necessary.

Member Data Documentation

DtRwString DtReaderWriterFile::myFilename
protected
DtReaderWriter* DtReaderWriterFile::myObjectToReadAndWrite
protected
bool DtReaderWriterFile::myFileReadOnly
protected
DtFilename DtReaderWriterFile::myFilenameLastReadIn
protected
DtString DtReaderWriterFile::myVariableSubstitutedFilename
protected

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

Document ID: Generated on Thu Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)