Matrix Science Mascot Parser toolkit
 
Loading...
Searching...
No Matches
ms_cronoptions Class Reference

Contains parameters from the cron section of mascot.dat. More...

#include <ms_cronoptions.hpp>

Inheritance diagram for ms_cronoptions:
Collaboration diagram for ms_cronoptions:

Public Member Functions

 ms_cronoptions ()
 Default constructor.
 
 ms_cronoptions (const ms_cronoptions &src)
 Copying constructor.
 
 ~ms_cronoptions ()
 Destructor.
 
void appendCronJob (const ms_cronjob *job)
 Add a new job entry at the end of the list.
 
void appendProperty (const char *name, const char *value, const char *delimiter, const bool bFirstPlace=false)
 Adds a new property with the given parameters.
 
void appendText (const char *line, const bool bFirstPlace=false)
 Adds a new non-parsed property.
 
void clearCronJobs ()
 Delete all cron-job entries.
 
void copyFrom (const ms_cronoptions *right)
 Can be used to create a copy of another object.
 
void copyFrom (const ms_customproperty *src)
 Copies all properties and comments from another instance.
 
void defaultValues ()
 Initialises the instance with default values.
 
bool deleteCronJob (const int idx)
 Delete a single cron job.
 
void delNonEmpty ()
 Deletes all non-comment properties.
 
void delProp (const char *name)
 Deletes all properties with the specified name.
 
void delPropByNumber (const int index)
 Deletes a single property with the specified number only.
 
void delPropStart (const char *nameBeginning)
 Deletes all properties whose names start with the given string.
 
int findProperty (const char *name, const int startFrom=0) const
 Searches the list for a property with the given name.
 
int findPropertyBeginning (const char *nameBeginning, const int startFrom=0) const
 Searches the list for a property with the partially matching name.
 
const ms_cronjob getCronJob (const int idx) const
 Returns an object describing a single cron job by its number.
 
std::string getDefaultDelimiter () const
 Return current default delimiter string used for parsing/storing properties.
 
std::string getDelimiterByNumber (const int index) const
 Returns a specific delimiter used for the property.
 
std::string getLogFileName () const
 Returns the path to the log file.
 
int getLoggingLevel () const
 Returns the current logging level.
 
int getNumberOfCronJobs () const
 Returns the total number of cron-jobs configured.
 
int getNumberOfProperties () const
 Returns a total number of property/comment entries.
 
std::string getPreceedingComments () const
 Returns any comments preceeding the section.
 
std::string getPropertyName (const int index) const
 Returns a property name for a given index.
 
std::string getPropValStringByName (const char *name) const
 Retrieves property value by name.
 
std::string getPropValStringByNumber (const int index) const
 Retrieves property raw text values by number.
 
bool isCronEnabled () const
 Returns true if parameter CronEnabled is set to 1 and false otherwise.
 
bool isSectionAvailable () const
 Returns TRUE if the section was actually read from a file.
 
ms_cronoptionsoperator= (const ms_cronoptions &right)
 Assignment operator for C++ client applications.
 
void setCronEnabled (const bool value)
 Change CronEnabled.
 
bool setCronJob (const int idx, const ms_cronjob job)
 Replace the current definition of a cron job.
 
void setDefaultDelimiter (const char *delim)
 Allows to set a specific delimiter string to be used when no property-specific delimiter is supplied.
 
bool setLogFileName (const std::string &fileName)
 Sets the path to the log file.
 
bool setLoggingLevel (const int level)
 Sets a new logging level.
 
void setPreceedingComments (const std::string &comments)
 Sets any comments preceeding the section.
 
void setPropertyName (const int index, const char *name)
 Changes name of the property with the given index.
 
void setPropValBoolByName (const char *name, const bool value, const bool bFirstPlace=false)
 Changes a boolean value of the first entry with the given name or creates a new property if it is not found.
 
void setPropValCharByName (const char *name, const char value, const bool bFirstPlace=false)
 Changes a single character value of the first entry with the given name or creates a new property if it is not found.
 
void setPropValFloatByName (const char *name, const double value, const bool bFirstPlace=false)
 Changes an floating point value of the first entry with the given name or creates a new property if it is not found.
 
void setPropValInt64ByName (const char *name, const INT64 value, const bool bFirstPlace=false)
 Changes a long 64-bit integer value of the first entry with the given name or creates a new property if it is not found.
 
void setPropValIntByName (const char *name, const int value, const bool bFirstPlace=false)
 Changes an integer value of the first entry with the given name or creates a new property if it is not found.
 
void setPropValStringByName (const char *name, const char *value, const bool bFirstPlace=false)
 Changes a string value of the first entry with the given name or creates a new property if it is not found.
 
void setPropValStringByNumber (const int index, const char *value)
 Changes an string value of an existing property with the given index.
 
void setSectionAvailable (const bool value)
 Changes availability of the section, meaning whether it should be stored in a file.
 
bool uncommentProp (const int index, const char *delimeter=0)
 Uncomments a line in the configuration file.
 

Detailed Description

Contains parameters from the cron section of mascot.dat.

On Unix systems, cron can be used to automate routine procedures such as the overnight updating of sequence database files. Windows 2000 and later include an equivalent utility called Scheduled Tasks. The Mascot ms-monitor.exe service/daemon runs the cron jobs listed in mascot.dat

In Mascot 2.4 and later, the Database Manager uses the cron job to download and update fasta database files.

For detailed information on any of the cron parameters please consult the Mascot manual.

See ms_datfile::getCronOptions() and ms_datfile::setCronOptions()

The base class ms_customproperty can be used to facilitate the following tasks:

  • Retrieving an unsupported property.
  • Retrieving a raw/text/XML property representation.
  • Checking for existence of a certain property rather than dealing with its default value.
  • Accessing commented lines in a section.

More functionality is described in the documentation for ms_customproperty.

Examples
config_mascotdat.cpp.

Constructor & Destructor Documentation

◆ ms_cronoptions() [1/2]

Default constructor.

The ms_cronoptions object will normally be created using ms_datfile::getCronOptions().

◆ ms_cronoptions() [2/2]

ms_cronoptions ( const ms_cronoptions src)

Copying constructor.

Parameters
srcis a reference to the object to copy from.

◆ ~ms_cronoptions()

Destructor.

Frees all memory. Pointers returned by getCronJob() are no longer valid.

Member Function Documentation

◆ appendCronJob()

void appendCronJob ( const ms_cronjob job)

Add a new job entry at the end of the list.

Parameters
jobis a pointer to the new job

◆ appendProperty()

void appendProperty ( const char *  name,
const char *  value,
const char *  delimiter,
const bool  bFirstPlace = false 
)
inherited

Adds a new property with the given parameters.

Parameters
namea property name to use.
valuea property value to use.
delimitera specific delimiter or an empty string for a default one to be used.
bFirstPlaceforces a new property to be put on top of the list.

◆ appendText()

void appendText ( const char *  l,
const bool  bFirstPlace = false 
)
inherited

Adds a new non-parsed property.

All property elements will be retrieved from the first parameter. Before calling this method, a specific default delimiter can be set using setDefaultDelimiter().

Parameters
lraw text representation of the property to be parsed.
bFirstPlaceforces a new property to be put on top of the list.

◆ clearCronJobs()

void clearCronJobs ( )

Delete all cron-job entries.

This does not change the log file settings or the 'enabled' value.

◆ defaultValues()

void defaultValues ( )

Initialises the instance with default values.

Clears the list of cron jobs, sets the 'enabled' flag to false.

◆ deleteCronJob()

bool deleteCronJob ( const int  idx)

Delete a single cron job.

Parameters
idxa number from 0 to (getNumberOfCronJobs()-1).
Returns
true if idx is a valid index.

◆ delProp()

void delProp ( const char *  str)
inherited

Deletes all properties with the specified name.

Parameters
strProperty name to find a match and then delete.

◆ delPropStart()

void delPropStart ( const char *  str)
inherited

Deletes all properties whose names start with the given string.

Parameters
strBeginning a first part of the property name to delete.

◆ findProperty()

int findProperty ( const char *  name,
const int  startFrom = 0 
) const
inherited

Searches the list for a property with the given name.

If no property found with the given name -1 will be returned. There may be several property entries in the list with the same name.

Parameters
namea property name to be found.
startFroma minimal property index to start search from.
Returns
a property index or -1 if no property found.

◆ findPropertyBeginning()

int findPropertyBeginning ( const char *  nameBeginning,
const int  startFrom = 0 
) const
inherited

Searches the list for a property with the partially matching name.

If no property found with the given name part -1 will be returned. There may be several property entries in the list whose names start with the given string.

Parameters
nameBeginningfirst part of a property name to be found.
startFroma minimal property index to start search from.
Returns
a property index or -1 if no property found.

◆ getCronJob()

const ms_cronjob getCronJob ( const int  idx) const

Returns an object describing a single cron job by its number.

All cron jobs are assigned consecutive ID numbers (0 based).

To make changes to the returned ms_cronjob permanent, call setCronJob() followed by ms_datfile::setCronOptions

Note
In versions of Mascot Parser prior to 2.4.1, this function returned a const pointer to the ms_conjob object rather than a copy of the object.
Parameters
idxa number from 0 to (getNumberOfCronJobs()-1)
Returns
instance of ms_cronjob class describing the corresponding entry.
Examples
config_mascotdat.cpp.

◆ getDefaultDelimiter()

std::string getDefaultDelimiter ( ) const
inherited

Return current default delimiter string used for parsing/storing properties.

Returns
default delimiter

◆ getDelimiterByNumber()

std::string getDelimiterByNumber ( const int  index) const
inherited

Returns a specific delimiter used for the property.

Parameters
indexIndex for which to get a delimiter
Returns
corresponding delimiter

◆ getLogFileName()

std::string getLogFileName ( ) const

Returns the path to the log file.

The filename can be a relative or absolute path.

ParameterLogfile
Permitted valuesA non empty string
Default
(if no parameter in mascot.dat)
"../logs/cron.log"
Value in mascot.dat"../logs/cron.log"
Returns
the logging file name.

◆ getLoggingLevel()

int getLoggingLevel ( ) const

Returns the current logging level.

The value specifies the level of logging. Messages are put into the file specified by getLogFileName()

ParameterLogging
Permitted values 0..3 where:
  • 0 - No logging
  • 1 - Log successful commands (return code 0)
  • 2 - Log unsuccessful commands (return code not 0)
  • 3 - Log successful and unsuccessful commands
Default
(if no parameter in mascot.dat)
3
Value in mascot.dat3
Returns
the logging level

◆ getNumberOfCronJobs()

int getNumberOfCronJobs ( ) const

Returns the total number of cron-jobs configured.

Every line (except the first one) in the cron section represents a cron-job. This function returns a number of such lines (except commented out).

Returns
the number of cron jobs.
Examples
config_mascotdat.cpp.

◆ getNumberOfProperties()

int getNumberOfProperties ( ) const
inherited

Returns a total number of property/comment entries.

Returns
Number of property/comment entries

◆ getPreceedingComments()

std::string getPreceedingComments ( ) const
inherited

Returns any comments preceeding the section.

Sections in the mascot.dat file may have comments preceeding them. In most cases, these comments need to stay 'attached' to the section.

Multiple line comments are supported by having a single string with newline characters

See also
setPreceedingComments()
Returns
any comments preceeding the section

◆ getPropertyName()

std::string getPropertyName ( const int  index) const
inherited

Returns a property name for a given index.

Parameters
indexproperty number from 0 to (getNumberOfProperties()-1).
Returns
Rroperty name of an empty string for comments.

◆ getPropValStringByName()

std::string getPropValStringByName ( const char *  name) const
inherited

Retrieves property value by name.

Don't use this method for comments as they all have empty name. Also note that there might be several entries corresponding to the same name . – only the first value will be returned. If in doubt use findProperty() and getPropValStringByNumber() instead.

Parameters
nameName for which to get a property value
Returns
corresponding property value

◆ getPropValStringByNumber()

std::string getPropValStringByNumber ( const int  index) const
inherited

Retrieves property raw text values by number.

Parameters
indexIndex for which to get a property value
Returns
corresponding property value

◆ isCronEnabled()

bool isCronEnabled ( ) const

Returns true if parameter CronEnabled is set to 1 and false otherwise.

The first parameter in the cron section of mascot.dat is always CronEnabled parameter. The rest is a list of cron-jobs. See getNumberOfCronJobs() for more information about them.

CronEnable should be set to 1 to enable cron functionality, 0 to disable. By default it is disabled.

Returns
true if the cron functionality is enabled
Examples
config_mascotdat.cpp.

◆ setCronEnabled()

void setCronEnabled ( const bool  value)

Change CronEnabled.

See isCronEnabled() for more information.

Parameters
valueshould be true or false

◆ setCronJob()

bool setCronJob ( const int  idx,
const ms_cronjob  job 
)

Replace the current definition of a cron job.

Parameters
idxa number from 0 to (getNumberOfCronJobs()-1).
jobis the new definition for the job.
Returns
true if job is not a null pointer and idx is a valid index.

◆ setDefaultDelimiter()

void setDefaultDelimiter ( const char *  delim)
inherited

Allows to set a specific delimiter string to be used when no property-specific delimiter is supplied.

Parameters
delimString to set the default delimiter

◆ setLogFileName()

bool setLogFileName ( const std::string &  fileName)

Sets the path to the log file.

The filename can be a relative or absolute path.

ParameterLogfile
Permitted valuesA non empty string
Default
(if no parameter in mascot.dat)
"../logs/cron.log"
Value in mascot.dat"../logs/cron.log"
Parameters
fileNameis the logging file name.
Returns
true if fileName is not an empty string.

◆ setLoggingLevel()

bool setLoggingLevel ( const int  level)

Sets a new logging level.

The value specifies the level of logging. Messages are put into the file specified by getLogFileName()

ParameterLogging
Permitted values 0..3 where:
  • 0 - No logging
  • 1 - Log successful commands (return code 0)
  • 2 - Log unsuccessful commands (return code not 0)
  • 3 - Log successful and unsuccessful commands
Default
(if no parameter in mascot.dat)
3
Value in mascot.dat3
Parameters
levelis the new logging level, a value 0..3.
Returns
true if a valid logging level is supplied.

◆ setPreceedingComments()

void setPreceedingComments ( const std::string &  comments)
inherited

Sets any comments preceeding the section.

Sections in the mascot.dat file may have comments preceeding them. In most cases, these comments need to stay 'attached' to the section.

Multiple line comments are supported by having a single string with newline characters

See also
getPreceedingComments()
Parameters
commentsany comments preceeding the section

◆ setPropertyName()

void setPropertyName ( const int  index,
const char *  name 
)
inherited

Changes name of the property with the given index.

Parameters
indexproperty number from 0 to (getNumberOfProperties()-1).
namenew name to be given to the property.

◆ setPropValBoolByName()

void setPropValBoolByName ( const char *  name,
const bool  value,
const bool  bFirstPlace = false 
)
inherited

Changes a boolean value of the first entry with the given name or creates a new property if it is not found.

A new value will be converted into 1 (for TRUE) or 0 (for FALSE) character.

Parameters
namea name of the property to find or add.
valuea new boolean value for the property.
bFirstPlaceif not found a new property can be put on top of the list.

◆ setPropValCharByName()

void setPropValCharByName ( const char *  name,
const char  value,
const bool  bFirstPlace = false 
)
inherited

Changes a single character value of the first entry with the given name or creates a new property if it is not found.

Parameters
namea name of the property to find or add.
valuea new single character value for the property.
bFirstPlaceif not found a new property can be put on top of the list.

◆ setPropValFloatByName()

void setPropValFloatByName ( const char *  name,
const double  value,
const bool  bFirstPlace = false 
)
inherited

Changes an floating point value of the first entry with the given name or creates a new property if it is not found.

Parameters
namea name of the property to find or add.
valuea new floating point value for the property.
bFirstPlaceif not found a new property can be put on top of the list.

◆ setPropValInt64ByName()

void setPropValInt64ByName ( const char *  name,
const INT64  value,
const bool  bFirstPlace = false 
)
inherited

Changes a long 64-bit integer value of the first entry with the given name or creates a new property if it is not found.

Parameters
namea name of the property to find or add.
valuea new long 64-bit integer value for the property.
bFirstPlaceif not found a new property can be put on top of the list.

◆ setPropValIntByName()

void setPropValIntByName ( const char *  name,
const int  value,
const bool  bFirstPlace = false 
)
inherited

Changes an integer value of the first entry with the given name or creates a new property if it is not found.

Parameters
namea name of the property to find or add.
valuea new integer value for the property.
bFirstPlaceif not found a new property can be put on top of the list.

◆ setPropValStringByName()

void setPropValStringByName ( const char *  name,
const char *  value,
const bool  bFirstPlace = false 
)
inherited

Changes a string value of the first entry with the given name or creates a new property if it is not found.

Parameters
namea name of the property to find or add.
valuea new string value for the property.
bFirstPlaceif not found a new property can be put on top of the list.

◆ setPropValStringByNumber()

void setPropValStringByNumber ( const int  index,
const char *  str 
)
inherited

Changes an string value of an existing property with the given index.

Parameters
indexan index of an existing property.
strString value for the property.

◆ uncommentProp()

bool uncommentProp ( const int  index,
const char *  delimeter = 0 
)
inherited

Uncomments a line in the configuration file.

Removes a # and any white space. Finds the delimeter and extracts the property name and value.

Parameters
indexmust be a value between 0 and getNumberOfProperties().
delimeterwill often be a space. If not supplied, the default delimeter will be used.
Returns
true if the delimiter was found, false otherwise

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