Open CASCADE Technology  7.3.0
Public Member Functions | Protected Attributes

IFSelect_SessionFile Class Reference

A SessionFile is intended to manage access between a WorkSession and an Ascii Form, to be considered as a Dump. It allows to write the File from the WorkSession, and later read the File to the WorkSession, by keeping required descriptions (such as dependances). More...

#include <IFSelect_SessionFile.hxx>

Public Member Functions

 IFSelect_SessionFile (const Handle< IFSelect_WorkSession > &WS)
 Creates a SessionFile, ready to read Files in order to load them into a given WorkSession. The following Read Operations must then be called. It is also possible to perform a Write, which produces a complete File of all the content of the WorkSession. More...
 
 IFSelect_SessionFile (const Handle< IFSelect_WorkSession > &WS, const Standard_CString filename)
 Creates a SessionFile which Writes the content of a WorkSession to a File (directly calls Write) Then, IsDone aknowledges on the result of the Operation. But such a SessionFile may not Read a File to a WorkSession. More...
 
void ClearLines ()
 Clears the lines recorded whatever for writing or for reading. More...
 
Standard_Integer NbLines () const
 Returns the count of recorded lines. More...
 
const TCollection_AsciiStringLine (const Standard_Integer num) const
 Returns a line given its rank in the list of recorded lines. More...
 
void AddLine (const Standard_CString line)
 Adds a line to the list of recorded lines. More...
 
void RemoveLastLine ()
 Removes the last line. Can be called recursively. Does nothing if the list is empty. More...
 
Standard_Boolean WriteFile (const Standard_CString name)
 Writes the recorded lines to a file named <name> then clears the list of lines. Returns False (with no clearing) if the file could not be created. More...
 
Standard_Boolean ReadFile (const Standard_CString name)
 Reads the recorded lines from a file named <name>, after having cleared the list (stops if RecognizeFile fails) Returns False (with no clearing) if the file could not be read. More...
 
Standard_Boolean RecognizeFile (const Standard_CString headerline)
 Recognizes the header line. returns True if OK, False else. More...
 
Standard_Integer Write (const Standard_CString filename)
 Performs a Write Operation from a WorkSession to a File i.e. calls WriteSession then WriteEnd, and WriteFile Returned Value is : 0 for OK, -1 File could not be created, >0 Error during Write (see WriteSession) IsDone can be called too (will return True for OK) More...
 
Standard_Integer Read (const Standard_CString filename)
 Performs a Read Operation from a file to a WorkSession i.e. calls ReadFile, then ReadSession and ReadEnd Returned Value is : 0 for OK, -1 File could not be opened, >0 Error during Read (see WriteSession) IsDone can be called too (will return True for OK) More...
 
Standard_Integer WriteSession ()
 Prepares the Write operation from a WorkSession (IFSelect) to a File, i.e. fills the list of lines (the file itself remains to be written; or NbLines/Line may be called) Important Remark : this excludes the reading of the last line, which is performed by WriteEnd Returns 0 if OK, status > 0 in case of error. More...
 
Standard_Integer WriteEnd ()
 Writes the trailing line. It is separate from WriteSession, in order to allow to redefine WriteSession without touching WriteEnd (WriteSession defines the body of the file) WriteEnd fills the list of lines. Returns a status of error, 0 if OK, >0 else. More...
 
void WriteLine (const Standard_CString line, const Standard_Character follow=0)
 Writes a line to the File. If <follow> is given, it is added at the following of the line. '
' must be added for the end. More...
 
Standard_Boolean WriteOwn (const Handle< Standard_Transient > &item)
 Writes the Parameters own to each type of Item. Uses the Library of SessionDumpers Returns True if Done, False if could not be treated (hence it remains written with no Own Parameter) More...
 
Standard_Integer ReadSession ()
 Performs a Read Operation from a File to a WorkSession, i.e. reads the list of line (which must have already been loaded, by ReadFile or by calls to AddLine) Important Remark : this excludes the reading of the last line, which is performed by ReadEnd Returns 0 for OK, >0 status for Read Error (not a suitable File, or WorkSession given as Immutable at Creation Time) IsDone can be called too (will return True for OK) More...
 
Standard_Integer ReadEnd ()
 Reads the end of a file (its last line). Returns 0 if OK, status >0 in case of error (not a suitable end line). More...
 
Standard_Boolean ReadLine ()
 Reads a Line and splits it into a set of alphanumeric items, which can then be queried by NbParams/ParamValue ... More...
 
void SplitLine (const Standard_CString line)
 Internal routine which processes a line into words and prepares its exploration. More...
 
Standard_Boolean ReadOwn (Handle< Standard_Transient > &item)
 Tries to Read an Item, by calling the Library of Dumpers Sets the list of parameters of the line to be read from the first own one. More...
 
void AddItem (const Handle< Standard_Transient > &item, const Standard_Boolean active=Standard_True)
 Adds an Item to the WorkSession, taken as Name the first item of the read Line. If this Name is not a Name but a Number or if this Name is already recorded in the WorkSession, it adds the Item but with no Name. Then the Name is recorded in order to be used by the method ItemValue <active> commands to make active or not in the session. More...
 
Standard_Boolean IsDone () const
 Returns True if the last Read or Write operation has been corectly performed. ELse returns False. More...
 
Handle< IFSelect_WorkSessionWorkSession () const
 Returns the WorkSession on which a SessionFile works. Remark that it is returned as Immutable. More...
 
void NewItem (const Standard_Integer ident, const Handle< Standard_Transient > &par)
 At beginning of writing an Item, writes its basics : More...
 
void SetOwn (const Standard_Boolean mode)
 Sets Parameters to be sent as Own if <mode> is True (their Name or Number or Void Mark or Text Value is preceeded by a Column sign ':') else they are sent normally Hence, the Own Parameter are clearly identified in the File. More...
 
void SendVoid ()
 During a Write action, commands to send a Void Parameter i.e. a Parameter which is present but undefined Its form will be the dollar sign : $. More...
 
void SendItem (const Handle< Standard_Transient > &par)
 During a Write action, commands to send the identification of a Parameter : if it is Null (undefined) it is send as Void ($) if it is Named in the WorkSession, its Name is sent preceeded by ':', else a relative Ident Number is sent preceeded by '#' (relative to the present Write, i.e. starting at one, without skip, and counted part from Named Items) More...
 
void SendText (const Standard_CString text)
 During a Write action, commands to send a Text without interpretation. It will be sent as well. More...
 
void SetLastGeneral (const Standard_Integer lastgen)
 Sets the rank of Last General Parameter to a new value. It is followed by the Fist Own Parameter of the item. Used by SessionFile after reading general parameters. More...
 
Standard_Integer NbParams () const
 During a Read operation, SessionFile processes sequencially the Items to read. For each one, it gives access to the list of its Parameters : they were defined by calls to SendVoid/SendParam/SendText during Writing the File. NbParams returns the count of Parameters for the line currently read. More...
 
Standard_Boolean IsVoid (const Standard_Integer num) const
 Returns True if a Parameter, given its rank in the Own List (see NbOwnParams), is Void. Returns also True if <num> is out of range (undefined parameters) More...
 
Standard_Boolean IsText (const Standard_Integer num) const
 Returns True if a Parameter, in the Own List (see NbOwnParams) is a Text (between "..."). Else it is an Item (Parameter, Selection, Dispatch ...), which can be Void. More...
 
const TCollection_AsciiStringParamValue (const Standard_Integer num) const
 Returns a Parameter (alphanumeric item of a line) as it has been read. More...
 
TCollection_AsciiString TextValue (const Standard_Integer num) const
 Returns the content of a Text Parameter (without the quotes). Returns an empty string if the Parameter is not a Text. More...
 
Handle< Standard_TransientItemValue (const Standard_Integer num) const
 Returns a Parameter as an Item. Returns a Null Handle if the Parameter is a Text, or if it is defined as Void. More...
 
void Destroy ()
 Specific Destructor (closes the File if not yet done) More...
 
 ~IFSelect_SessionFile ()
 

Protected Attributes

Handle< IFSelect_WorkSessionthesess
 
Handle< TColStd_HArray1OfInteger > thenums
 
NCollection_DataMap< TCollection_AsciiString, Standard_Integerthenames
 
Standard_Integer thenl
 
TColStd_SequenceOfAsciiString theline
 

Detailed Description

A SessionFile is intended to manage access between a WorkSession and an Ascii Form, to be considered as a Dump. It allows to write the File from the WorkSession, and later read the File to the WorkSession, by keeping required descriptions (such as dependances).

The produced File is under an Ascii Form, then it may be easily consulted. It is possible to cumulate reading of several Files. But in case of Names conflict, the newer Names are forgottens.

The Dump supports the description of XSTEP functionnalities (Sharing an Interface File, with Selections, Dispatches, Modifiers ...) but does not refer to the Interface File which is currently loaded.

SessionFile works with a library of SessionDumper type objects

The File is Produced as follows : SessionFile produces all general Informations (such as Int and Text Parameters, Types and Inputs of Selections, Dispatches, Modifiers ...) and calls the SessionDumpers to produce all the particular Data : creation arguments, parameters to be set It is Read in the same terms : SessionFile reads and interprets all general Informations, and calls the SessionDumpers to recognize Types and for a recognized Type create the corresponding Object with its particular parameters as they were written. The best way to work is to have one SessionDumper for each consistent set of classes (e.g. a package).

Constructor & Destructor Documentation

◆ IFSelect_SessionFile() [1/2]

IFSelect_SessionFile::IFSelect_SessionFile ( const Handle< IFSelect_WorkSession > &  WS)

Creates a SessionFile, ready to read Files in order to load them into a given WorkSession. The following Read Operations must then be called. It is also possible to perform a Write, which produces a complete File of all the content of the WorkSession.

◆ IFSelect_SessionFile() [2/2]

IFSelect_SessionFile::IFSelect_SessionFile ( const Handle< IFSelect_WorkSession > &  WS,
const Standard_CString  filename 
)

Creates a SessionFile which Writes the content of a WorkSession to a File (directly calls Write) Then, IsDone aknowledges on the result of the Operation. But such a SessionFile may not Read a File to a WorkSession.

◆ ~IFSelect_SessionFile()

IFSelect_SessionFile::~IFSelect_SessionFile ( )
inline

Member Function Documentation

◆ AddItem()

void IFSelect_SessionFile::AddItem ( const Handle< Standard_Transient > &  item,
const Standard_Boolean  active = Standard_True 
)

Adds an Item to the WorkSession, taken as Name the first item of the read Line. If this Name is not a Name but a Number or if this Name is already recorded in the WorkSession, it adds the Item but with no Name. Then the Name is recorded in order to be used by the method ItemValue <active> commands to make active or not in the session.

◆ AddLine()

void IFSelect_SessionFile::AddLine ( const Standard_CString  line)

Adds a line to the list of recorded lines.

◆ ClearLines()

void IFSelect_SessionFile::ClearLines ( )

Clears the lines recorded whatever for writing or for reading.

◆ Destroy()

void IFSelect_SessionFile::Destroy ( )

Specific Destructor (closes the File if not yet done)

◆ IsDone()

Standard_Boolean IFSelect_SessionFile::IsDone ( ) const

Returns True if the last Read or Write operation has been corectly performed. ELse returns False.

◆ IsText()

Standard_Boolean IFSelect_SessionFile::IsText ( const Standard_Integer  num) const

Returns True if a Parameter, in the Own List (see NbOwnParams) is a Text (between "..."). Else it is an Item (Parameter, Selection, Dispatch ...), which can be Void.

◆ IsVoid()

Standard_Boolean IFSelect_SessionFile::IsVoid ( const Standard_Integer  num) const

Returns True if a Parameter, given its rank in the Own List (see NbOwnParams), is Void. Returns also True if <num> is out of range (undefined parameters)

◆ ItemValue()

Handle< Standard_Transient > IFSelect_SessionFile::ItemValue ( const Standard_Integer  num) const

Returns a Parameter as an Item. Returns a Null Handle if the Parameter is a Text, or if it is defined as Void.

◆ Line()

const TCollection_AsciiString& IFSelect_SessionFile::Line ( const Standard_Integer  num) const

Returns a line given its rank in the list of recorded lines.

◆ NbLines()

Standard_Integer IFSelect_SessionFile::NbLines ( ) const

Returns the count of recorded lines.

◆ NbParams()

Standard_Integer IFSelect_SessionFile::NbParams ( ) const

During a Read operation, SessionFile processes sequencially the Items to read. For each one, it gives access to the list of its Parameters : they were defined by calls to SendVoid/SendParam/SendText during Writing the File. NbParams returns the count of Parameters for the line currently read.

◆ NewItem()

void IFSelect_SessionFile::NewItem ( const Standard_Integer  ident,
const Handle< Standard_Transient > &  par 
)

At beginning of writing an Item, writes its basics :

  • either its name in the session if it has one
  • or its relative number of item in the file, else (preceeded by a '_')
  • then, its Dynamic Type (in the sense of cdl : pk_class) This basic description can be followed by the parameters which are used in the definition of the item.

◆ ParamValue()

const TCollection_AsciiString& IFSelect_SessionFile::ParamValue ( const Standard_Integer  num) const

Returns a Parameter (alphanumeric item of a line) as it has been read.

◆ Read()

Standard_Integer IFSelect_SessionFile::Read ( const Standard_CString  filename)

Performs a Read Operation from a file to a WorkSession i.e. calls ReadFile, then ReadSession and ReadEnd Returned Value is : 0 for OK, -1 File could not be opened, >0 Error during Read (see WriteSession) IsDone can be called too (will return True for OK)

◆ ReadEnd()

Standard_Integer IFSelect_SessionFile::ReadEnd ( )

Reads the end of a file (its last line). Returns 0 if OK, status >0 in case of error (not a suitable end line).

◆ ReadFile()

Standard_Boolean IFSelect_SessionFile::ReadFile ( const Standard_CString  name)

Reads the recorded lines from a file named <name>, after having cleared the list (stops if RecognizeFile fails) Returns False (with no clearing) if the file could not be read.

◆ ReadLine()

Standard_Boolean IFSelect_SessionFile::ReadLine ( )

Reads a Line and splits it into a set of alphanumeric items, which can then be queried by NbParams/ParamValue ...

◆ ReadOwn()

Standard_Boolean IFSelect_SessionFile::ReadOwn ( Handle< Standard_Transient > &  item)

Tries to Read an Item, by calling the Library of Dumpers Sets the list of parameters of the line to be read from the first own one.

◆ ReadSession()

Standard_Integer IFSelect_SessionFile::ReadSession ( )

Performs a Read Operation from a File to a WorkSession, i.e. reads the list of line (which must have already been loaded, by ReadFile or by calls to AddLine) Important Remark : this excludes the reading of the last line, which is performed by ReadEnd Returns 0 for OK, >0 status for Read Error (not a suitable File, or WorkSession given as Immutable at Creation Time) IsDone can be called too (will return True for OK)

◆ RecognizeFile()

Standard_Boolean IFSelect_SessionFile::RecognizeFile ( const Standard_CString  headerline)

Recognizes the header line. returns True if OK, False else.

◆ RemoveLastLine()

void IFSelect_SessionFile::RemoveLastLine ( )

Removes the last line. Can be called recursively. Does nothing if the list is empty.

◆ SendItem()

void IFSelect_SessionFile::SendItem ( const Handle< Standard_Transient > &  par)

During a Write action, commands to send the identification of a Parameter : if it is Null (undefined) it is send as Void ($) if it is Named in the WorkSession, its Name is sent preceeded by ':', else a relative Ident Number is sent preceeded by '#' (relative to the present Write, i.e. starting at one, without skip, and counted part from Named Items)

◆ SendText()

void IFSelect_SessionFile::SendText ( const Standard_CString  text)

During a Write action, commands to send a Text without interpretation. It will be sent as well.

◆ SendVoid()

void IFSelect_SessionFile::SendVoid ( )

During a Write action, commands to send a Void Parameter i.e. a Parameter which is present but undefined Its form will be the dollar sign : $.

◆ SetLastGeneral()

void IFSelect_SessionFile::SetLastGeneral ( const Standard_Integer  lastgen)

Sets the rank of Last General Parameter to a new value. It is followed by the Fist Own Parameter of the item. Used by SessionFile after reading general parameters.

◆ SetOwn()

void IFSelect_SessionFile::SetOwn ( const Standard_Boolean  mode)

Sets Parameters to be sent as Own if <mode> is True (their Name or Number or Void Mark or Text Value is preceeded by a Column sign ':') else they are sent normally Hence, the Own Parameter are clearly identified in the File.

◆ SplitLine()

void IFSelect_SessionFile::SplitLine ( const Standard_CString  line)

Internal routine which processes a line into words and prepares its exploration.

◆ TextValue()

TCollection_AsciiString IFSelect_SessionFile::TextValue ( const Standard_Integer  num) const

Returns the content of a Text Parameter (without the quotes). Returns an empty string if the Parameter is not a Text.

◆ WorkSession()

Handle< IFSelect_WorkSession > IFSelect_SessionFile::WorkSession ( ) const

Returns the WorkSession on which a SessionFile works. Remark that it is returned as Immutable.

◆ Write()

Standard_Integer IFSelect_SessionFile::Write ( const Standard_CString  filename)

Performs a Write Operation from a WorkSession to a File i.e. calls WriteSession then WriteEnd, and WriteFile Returned Value is : 0 for OK, -1 File could not be created, >0 Error during Write (see WriteSession) IsDone can be called too (will return True for OK)

◆ WriteEnd()

Standard_Integer IFSelect_SessionFile::WriteEnd ( )

Writes the trailing line. It is separate from WriteSession, in order to allow to redefine WriteSession without touching WriteEnd (WriteSession defines the body of the file) WriteEnd fills the list of lines. Returns a status of error, 0 if OK, >0 else.

◆ WriteFile()

Standard_Boolean IFSelect_SessionFile::WriteFile ( const Standard_CString  name)

Writes the recorded lines to a file named <name> then clears the list of lines. Returns False (with no clearing) if the file could not be created.

◆ WriteLine()

void IFSelect_SessionFile::WriteLine ( const Standard_CString  line,
const Standard_Character  follow = 0 
)

Writes a line to the File. If <follow> is given, it is added at the following of the line. '
' must be added for the end.

◆ WriteOwn()

Standard_Boolean IFSelect_SessionFile::WriteOwn ( const Handle< Standard_Transient > &  item)

Writes the Parameters own to each type of Item. Uses the Library of SessionDumpers Returns True if Done, False if could not be treated (hence it remains written with no Own Parameter)

◆ WriteSession()

Standard_Integer IFSelect_SessionFile::WriteSession ( )

Prepares the Write operation from a WorkSession (IFSelect) to a File, i.e. fills the list of lines (the file itself remains to be written; or NbLines/Line may be called) Important Remark : this excludes the reading of the last line, which is performed by WriteEnd Returns 0 if OK, status > 0 in case of error.

Field Documentation

◆ theline

TColStd_SequenceOfAsciiString IFSelect_SessionFile::theline
protected

◆ thenames

NCollection_DataMap<TCollection_AsciiString, Standard_Integer> IFSelect_SessionFile::thenames
protected

◆ thenl

Standard_Integer IFSelect_SessionFile::thenl
protected

◆ thenums

Handle< TColStd_HArray1OfInteger > IFSelect_SessionFile::thenums
protected

◆ thesess

Handle< IFSelect_WorkSession > IFSelect_SessionFile::thesess
protected

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