VR-Forces 4.0.4 Class Documentation
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
DtScenarioMergeDirector Class Reference

Utility for merging two or more VRF scenarios together into a single scenario. More...

List of all members.

Public Types

enum  FileType {
  FILE_NONE = 0, FILE_GPL, FILE_OMP, FILE_OOB,
  FILE_OVL, FILE_PLN, FILE_SGR, FILE_XTR
}

Public Member Functions

 DtScenarioMergeDirector ()
 default constructor
virtual ~DtScenarioMergeDirector ()
 destructor
 DtScenarioMergeDirector (const DtScenarioMergeDirector &orig)
 copy constructor
DtScenarioMergeDirectoroperator= (const DtScenarioMergeDirector &orig)
 assignment operator
virtual void addInputScenario (const DtFilename &scenarioFile)
 Adds the specified scenario as an input to the scenario merge project.
virtual void setOutputScenarioName (const DtFilename &scenarioFile)
 Sets the merge output scenario name in the merge project to the specified scenario name.
virtual bool executeMerge ()
 Executes the merge.
virtual DtlObjPtr arrangeDesignators (const char *pMergedOobStrBuff)
 arrangeDesignators() This is a scenario merge step that happens after OOBs have been merged, object names deconflicted, and before the final scenario is written.
virtual DtString bufferedMtlStringReplace (const char *pToFindString, const char *pReplaceWithString, const char *pInFileName)
 bufferedMtlStringReplace() Open the specified file, and replace all occurrences of pToFindString with pReplaceWithString, returning the resulting string.
virtual void clear ()
 clear() Erase all data, revert to an empty state.
virtual bool checkScenarioMergeData ()
 checkScenarioMergeData() Validate the source scenario data, checking for errors.
virtual void createNewProject ()
 createNewProject() Call this after clear().
virtual int computeMtlBufferOffset (const char *pBuffer, unsigned numFieldsToSkip, bool bFirstFieldIsList=true)
 computeMtlBufferOffset() An internal function that calculates a starting position in an mtl text stream, for string replacement operations.
virtual int lengthUnusedData (const char *pBuffer)
 Computes the length of a section of data in an mtl file between an open and closed parenthesis pair.
virtual bool deconflict ()
 deconflict() STEP THREE Examine all order of battle and global plan data for all the VR-Forces scenarios, and rename objects as needed to produce a final merged result.
bool deconflictMtlStream (const DtString &sScenarioName, const DtlObjPtr &oob)
 deconflictMtlStream() Examine the given order of battle data for the specified scenario, and deconflict the results.
virtual bool doAllSubstitutions ()
 doAllSubstitutions(); STEP FOUR (and final step) A top-level operation that is called after deconflict(); Performs string substitutions in all scenario files.
virtual bool doSubstitutions (FileType ftype, DtString &sResultsBuffer)
virtual bool doSimpleFileTransfer (const DtFilename &sFrom, const DtFilename &sTo)
 doSimpleFileTransfer() This is a helper function that is used during the merge process to copy a file from one location to another.
virtual bool getFilenameForType (FileType ftype, const DtScenario &scn, DtFilename &fnameOut) const
 getFilenameForType() This is a helper function that is used during the merge process.
virtual bool loadProject ()
 loadProject() STEP ONE Loads the specified scenario merge project.
virtual bool loadProject (const DtFilename &fname)
virtual bool loadScenarioMergeData ()
 loadScenarioMergeData STEP TWO Examines a loaded scenario merge project, then loads up the DtScenarios.
virtual bool loadScenarioMergeData (const DtFilename &fname)
virtual void mergeAdditionalOpdLists (DtScenario &outputScenario)
 mergeAdditionalOpdLists() A helper function invoked by doAllSubstitutions().
virtual void mergeSimulationModelSetLists (DtScenario &outputScenario)
 mergeSimulationModelSetLists() A helper function invoked by doAllSubstitutions().
virtual DtScenarioMergeProjectproject ()
 project(); Returns a pointer to a DtScenarioMergeProject or NULL.
virtual const
DtScenarioMergeProject
project () const
virtual void replaceObjectNames (DtString &sBuffer, const DtString &sForScnName, const char *pFormatString="%s")
 replaceObjectNames() A helper function that replaces old object names with deconflicted ones for the specified scenario, into the buffer provided.
virtual void reportObjectNameSubstitutions () const
 reportObjectNameSubstitutions() After deconflict() has been called, this fuction will dump the object name deconfliction table to the console window.
virtual bool saveAsProject (const DtFilename &fname)
 saveAsProject() Save the scenario merge project to the location specified.
virtual bool saveProject ()
virtual DtScenarioMergeDatascenarioMergeData ()
 scenarioMergeData() Accessor for myScenarioMergeData
virtual const DtScenarioMergeDatascenarioMergeData () const
virtual bool validate (const DtScenario &keyScenario, const DtScenario &otherScenario)
 Validate Compare data members in "otherScenario" to "keyScenario", warn of conflicts.

Protected Member Functions

virtual void readOOBFile (char *pReadBuffer, FILE *fpIn, bool isKeyScenario)
 Reads in an OOB file from fpIn into pReadBuffer checking with acceptOOOBObject before allowing objects from the file into the buffer.
virtual bool acceptOOBObject (const std::string &objStr, bool isKeyScenario) const
 Called by readOOBFile to determine if a given OOB object (in string form) should be accepted into the merge.
virtual bool transferScenarioFiles (DtScenario &outputScenario, const DtFilename &outputName)

Protected Attributes

DtScenarioMergeData myScenarioMergeData
DtScenarioMergeProjectpMyProject

Detailed Description

Utility for merging two or more VRF scenarios together into a single scenario.

Works on scenario files only, rather than scenario in memory.

Basic Usage
 DtScenarioMergeDirector director;
 director.createNewProject();
 director.addInputScenario("../data/scenario/scenario1.scn");
 director.addInputScenario("../data/scenario/scenario2.scn");
 director.setOutputScenarioName("../data/scenario/mergeOutput.scn");
 director.executeMerge();

Member Enumeration Documentation

Enumerator:
FILE_NONE 
FILE_GPL 
FILE_OMP 
FILE_OOB 
FILE_OVL 
FILE_PLN 
FILE_SGR 
FILE_XTR 

Constructor & Destructor Documentation

default constructor

destructor

copy constructor


Member Function Documentation

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

assignment operator

virtual void DtScenarioMergeDirector::addInputScenario ( const DtFilename &  scenarioFile) [virtual]

Adds the specified scenario as an input to the scenario merge project.

The director must has a merge project before calling this. Call createNewProject() to do this.

virtual void DtScenarioMergeDirector::setOutputScenarioName ( const DtFilename &  scenarioFile) [virtual]

Sets the merge output scenario name in the merge project to the specified scenario name.

This is the scenario that will be created when the merge is executed. The director must has a merge project before calling this. Call createNewProject() to do this.

Executes the merge.

All inputs and outputs must be set up prior to making this call. This call will write the merged scenario to the filename that has been specified previously.

Returns:
True if the scenario merge was a success. False if there are any errors.
virtual DtlObjPtr DtScenarioMergeDirector::arrangeDesignators ( const char *  pMergedOobStrBuff) [virtual]

arrangeDesignators() This is a scenario merge step that happens after OOBs have been merged, object names deconflicted, and before the final scenario is written.

It iterates through the deconfliction table, and corrects VR-Forces object designators in the given order-of-battle data stream. Returns a DtlObjPtr representing the order of battle in MAK Lisp format.

virtual DtString DtScenarioMergeDirector::bufferedMtlStringReplace ( const char *  pToFindString,
const char *  pReplaceWithString,
const char *  pInFileName 
) [virtual]

bufferedMtlStringReplace() Open the specified file, and replace all occurrences of pToFindString with pReplaceWithString, returning the resulting string.

virtual void DtScenarioMergeDirector::clear ( ) [virtual]

clear() Erase all data, revert to an empty state.

checkScenarioMergeData() Validate the source scenario data, checking for errors.

Returns true if the data is OK, false if error detected.

virtual void DtScenarioMergeDirector::createNewProject ( ) [virtual]

createNewProject() Call this after clear().

It will cause the director and its data members to initialize to a state ready to accept new data.

virtual int DtScenarioMergeDirector::computeMtlBufferOffset ( const char *  pBuffer,
unsigned  numFieldsToSkip,
bool  bFirstFieldIsList = true 
) [virtual]

computeMtlBufferOffset() An internal function that calculates a starting position in an mtl text stream, for string replacement operations.

Called in doSubstitutions(). It is used to skip over the open parenthesis and name, and sometimes the next nested parenthesis and name. For example, computeMtlBufferOffset() skips over "(order-of-battle" to set the buffer at "(local-vrf-object ...", the first VR-Forces object entry in an order-of-battle MTL stream.

virtual int DtScenarioMergeDirector::lengthUnusedData ( const char *  pBuffer) [virtual]

Computes the length of a section of data in an mtl file between an open and closed parenthesis pair.

This is used to skip over the force-hostility sections of xtr files in scenarios after the first scenario in the project, since only one set of force-hostility is needed. If other data is added to the xtr file, and it does not need to be merged, then doSubstitutions() can call this for each such section of data.

deconflict() STEP THREE Examine all order of battle and global plan data for all the VR-Forces scenarios, and rename objects as needed to produce a final merged result.

bool DtScenarioMergeDirector::deconflictMtlStream ( const DtString sScenarioName,
const DtlObjPtr &  oob 
)

deconflictMtlStream() Examine the given order of battle data for the specified scenario, and deconflict the results.

Returns true for OK, false if not.

doAllSubstitutions(); STEP FOUR (and final step) A top-level operation that is called after deconflict(); Performs string substitutions in all scenario files.

Writes the final scenario result.

virtual bool DtScenarioMergeDirector::doSubstitutions ( FileType  ftype,
DtString sResultsBuffer 
) [virtual]
virtual bool DtScenarioMergeDirector::doSimpleFileTransfer ( const DtFilename &  sFrom,
const DtFilename &  sTo 
) [virtual]

doSimpleFileTransfer() This is a helper function that is used during the merge process to copy a file from one location to another.

The original is preserved in its original location.

virtual bool DtScenarioMergeDirector::getFilenameForType ( FileType  ftype,
const DtScenario scn,
DtFilename &  fnameOut 
) const [virtual]

getFilenameForType() This is a helper function that is used during the merge process.

Given a DtScenarioMergeDirector::FileType, above, and a scenario, extract the corresponding filename. Return true if OK, false if not. this is called by doSubstitutions().

loadProject() STEP ONE Loads the specified scenario merge project.

Returns true if success, false if failure. Does not perform a merge operation.

virtual bool DtScenarioMergeDirector::loadProject ( const DtFilename &  fname) [virtual]

loadScenarioMergeData STEP TWO Examines a loaded scenario merge project, then loads up the DtScenarios.

virtual bool DtScenarioMergeDirector::loadScenarioMergeData ( const DtFilename &  fname) [virtual]
virtual void DtScenarioMergeDirector::mergeAdditionalOpdLists ( DtScenario outputScenario) [virtual]

mergeAdditionalOpdLists() A helper function invoked by doAllSubstitutions().

Combines the additional OPD lists specified by the scenarios.

virtual void DtScenarioMergeDirector::mergeSimulationModelSetLists ( DtScenario outputScenario) [virtual]

mergeSimulationModelSetLists() A helper function invoked by doAllSubstitutions().

Combines the simulation model set files specified by the scenarios.

project(); Returns a pointer to a DtScenarioMergeProject or NULL.

virtual const DtScenarioMergeProject* DtScenarioMergeDirector::project ( ) const [virtual]
virtual void DtScenarioMergeDirector::replaceObjectNames ( DtString sBuffer,
const DtString sForScnName,
const char *  pFormatString = "%s" 
) [virtual]

replaceObjectNames() A helper function that replaces old object names with deconflicted ones for the specified scenario, into the buffer provided.

Buffer contains the original content, and is altered to contain the modified result. Invoked by doSubstitutions()

reportObjectNameSubstitutions() After deconflict() has been called, this fuction will dump the object name deconfliction table to the console window.

virtual bool DtScenarioMergeDirector::saveAsProject ( const DtFilename &  fname) [virtual]

saveAsProject() Save the scenario merge project to the location specified.

This saves the project metadata. This does not merge anything, nor write a final scenario.

scenarioMergeData() Accessor for myScenarioMergeData

virtual bool DtScenarioMergeDirector::validate ( const DtScenario keyScenario,
const DtScenario otherScenario 
) [virtual]

Validate Compare data members in "otherScenario" to "keyScenario", warn of conflicts.

Returns true if OK, false if conflicts detected.

virtual void DtScenarioMergeDirector::readOOBFile ( char *  pReadBuffer,
FILE *  fpIn,
bool  isKeyScenario 
) [protected, virtual]

Reads in an OOB file from fpIn into pReadBuffer checking with acceptOOOBObject before allowing objects from the file into the buffer.

The OOB file is parsed based on parenthesis searching which pulls each object out into a std::string which gets passed to acceptOOBObject. NOTE: this function should only be called by doSubstitutions which is responsible for allocating the buffer and opening the file. It also sets isKeyScenario to true for the first (key) OOB file read in.

virtual bool DtScenarioMergeDirector::acceptOOBObject ( const std::string &  objStr,
bool  isKeyScenario 
) const [protected, virtual]

Called by readOOBFile to determine if a given OOB object (in string form) should be accepted into the merge.

If isKeyScenario is true, objects are always accepted. Otherwise, if the object's type has the kind field set to DtWeatherObjectKind it is rejected as only one weather object is used per scenario.

Returns:
true if the object is accepted
virtual bool DtScenarioMergeDirector::transferScenarioFiles ( DtScenario outputScenario,
const DtFilename &  outputName 
) [protected, virtual]

Member Data Documentation


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

Document ID: Generated on Fri Jun 29 16:33:32 EDT 2012 from SVN revision 116588
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)