This class encapsulates a complete fragmentation_rules
file.
More...
#include <ms_fragmentationrules.hpp>
Public Member Functions | |
ms_fragrulesfile () | |
Default constructor. | |
ms_fragrulesfile (const char *filename, const matrix_science::ms_connection_settings *cs=0) | |
Immediate-action constructor that reads the given file. | |
ms_fragrulesfile (const ms_fragrulesfile &src) | |
Copying constructor. | |
~ms_fragrulesfile () | |
Destructor. | |
void | appendErrors (const ms_errors &src) |
Copies all errors from another instance and appends them at the end of own list. | |
void | appendInstrument (const ms_fragmentationrules *item) |
Adds a new instrument definition at the end of the list. | |
void | clearAllErrors () |
Remove all errors from the current list of errors. | |
void | clearInstruments () |
Deletes all instruments definitions. | |
void | copyFrom (const ms_errors *right) |
Use this member to make a copy of another instance. | |
void | copyFrom (const ms_fragrulesfile *right) |
Can be used to make a copy of another instance. | |
void | defaultValues () |
Re-initialises the list of fragmentation rules, so the instance can be re-used. | |
bool | deleteInstrumentByName (const char *name) |
Remove an instrument from the list in memory. | |
bool | deleteInstrumentByNumber (const int num) |
Remove an instrument from the list in memory. | |
matrix_science::ms_connection_settings | getConnectionSettings () const |
Returns the sessionID and proxy server for use with an HTTP transfer. | |
const ms_errs * | getErrorHandler () const |
Retrive the error object using this function to get access to all errors and error parameters. | |
std::string | getFileName () const |
Get the currently used file name. | |
const ms_fragmentationrules * | getInstrumentByName (const char *name) const |
Returns a configuration for an instrument by name. | |
const ms_fragmentationrules * | getInstrumentByNumber (const int instrumentNum) const |
Returns a configuration for an instrument by its number from 0 to (getNumberOfInstruments()-1). | |
std::string | getInstrumentName (const int instrumentNum) const |
Returns an instrument name by its number from 0 to (getNumberOfInstruments()-1). | |
int | getLastError () const |
Return the error description of the last error that occurred. | |
std::string | getLastErrorString () const |
Return the error description of the last error that occurred. | |
int | getNumberOfInstruments () const |
Returns a number of instruments configured. | |
bool | isValid () const |
Call this function to determine if there have been any errors. | |
ms_fragrulesfile & | operator= (const ms_fragrulesfile &right) |
C++ style assignment operator. | |
void | read_buffer (const char *buffer) |
Reads and parses the string, populates the list of instruments. | |
void | read_file () |
Reads and parses the file, populates the list of instruments. | |
void | save_file () |
Stores instrument definitions in a file. | |
void | setConnectionSettings (const matrix_science::ms_connection_settings &cs) |
Sets the sessionID and proxy server for use with an HTTP transfer. | |
void | setFileName (const char *filename) |
Use this member to set a non-default file name. | |
bool | updateInstrumentByName (const char *name, const ms_fragmentationrules item) |
Update the information for a specific instrument. | |
bool | updateInstrumentByNumber (const int num, const ms_fragmentationrules item) |
Update the information for a specific instrument. | |
This class encapsulates a complete fragmentation_rules
file.
Usage of this class is simple. Just create an instance, set an explicit file name if necessary, call read_file()-member, check for errors (isValid()) and retrieve an instrument by its name or number.
ms_fragrulesfile | ( | ) |
Default constructor.
Not generally useful. The filename is set to ../config/fragmentation_rules
, but the file is not read.
ms_fragrulesfile | ( | const char * | filename, |
const matrix_science::ms_connection_settings * | cs = 0 |
||
) |
Immediate-action constructor that reads the given file.
filename | The file name parameter can be either a local file path or a Mascot server URL, it cannot be an empty string or NULL pointer. If it is a URL it should be of the form http://your-server/mascot/cgi . |
cs | is a pointer to the connection settings. This should contain a sessionID and optionally the proxy server settings. |
~ms_fragrulesfile | ( | ) |
Destructor.
Frees all memory allocated for the object.
|
inherited |
Copies all errors from another instance and appends them at the end of own list.
src | The object to copy the errors across from. See Maintaining object references: two rules of thumb. |
void appendInstrument | ( | const ms_fragmentationrules * | item | ) |
Adds a new instrument definition at the end of the list.
Typically, the file would be saved after doing this.
item | is the the new instrument definition to be added. |
|
inherited |
Remove all errors from the current list of errors.
The list of 'errors' can include fatal errors, warning messages, information messages and different levels of debugging messages.
All messages are accumulated into a list in this object, until clearAllErrors() is called.
See Error Handling.
void clearInstruments | ( | ) |
Deletes all instruments definitions.
All instruments are removed.
|
inherited |
Use this member to make a copy of another instance.
right | is the source to initialise from |
void copyFrom | ( | const ms_fragrulesfile * | right | ) |
Can be used to make a copy of another instance.
right | is the fragmentation rules file to copy values from. |
void defaultValues | ( | ) |
Re-initialises the list of fragmentation rules, so the instance can be re-used.
Clears the list of instruments and comments. Clears all errors.
bool deleteInstrumentByName | ( | const char * | name | ) |
Remove an instrument from the list in memory.
name | must be a valid instrument name. |
bool deleteInstrumentByNumber | ( | const int | num | ) |
Remove an instrument from the list in memory.
num | must be in the range 0..getNumberOfInstruments()-1. |
|
inherited |
Retrive the error object using this function to get access to all errors and error parameters.
See Error Handling.
std::string getFileName | ( | ) | const |
Get the currently used file name.
const ms_fragmentationrules * getInstrumentByName | ( | const char * | name | ) | const |
Returns a configuration for an instrument by name.
name | is the name of the instrument as specified in the title line in the fragmentation_rules file. |
const ms_fragmentationrules * getInstrumentByNumber | ( | const int | instrumentNum | ) | const |
Returns a configuration for an instrument by its number from 0 to (getNumberOfInstruments()-1).
instrumentNum | is the number of the instrument and should be between zero and getNumberOfInstruments()-1. |
std::string getInstrumentName | ( | const int | instrumentNum | ) | const |
Returns an instrument name by its number from 0 to (getNumberOfInstruments()-1).
instrumentNum | is the number of the instrument and should be between zero and getNumberOfInstruments()-1. |
title:
line in the fragmentation_rules
file.
|
inherited |
Return the error description of the last error that occurred.
All errors are accumulated into a list in this object, until clearAllErrors() is called. This function returns the last error that occurred.
See Error Handling.
|
inherited |
Return the error description of the last error that occurred.
All errors are accumulated into a list in this object, until clearAllErrors() is called. This function returns the last error that occurred.
See Error Handling.
int getNumberOfInstruments | ( | ) | const |
Returns a number of instruments configured.
|
inherited |
Call this function to determine if there have been any errors.
This will return true unless there have been any fatal errors.
See Error Handling.
ms_fragrulesfile & operator= | ( | const ms_fragrulesfile & | right | ) |
C++ style assignment operator.
right | is the fragmentation rules file to copy values from. |
void read_buffer | ( | const char * | buffer | ) |
Reads and parses the string, populates the list of instruments.
Check for possible errors with isValid()-function and retrieve errors descriptions (if any) after calling this function. If an error occurs during reading the buffer it will still contain some of the instruments that have been successfully read from the file.
buffer | buffer to read |
void read_file | ( | ) |
Reads and parses the file, populates the list of instruments.
Check for possible errors with isValid()-function and retrieve errors descriptions (if any) after calling this function. If an error occurs during reading the file it will still contain some of the instruments that have been successfully read from the file.
void save_file | ( | ) |
Stores instrument definitions in a file.
Don't forget to check for errors after this function call.
void setConnectionSettings | ( | const matrix_science::ms_connection_settings & | cs | ) |
Sets the sessionID and proxy server for use with an HTTP transfer.
This value would normally be passed in the constructor.
cs | is the new connection settings. |
void setFileName | ( | const char * | filename | ) |
Use this member to set a non-default file name.
filename | is the new file name or URL. |
bool updateInstrumentByName | ( | const char * | name, |
const ms_fragmentationrules | item | ||
) |
Update the information for a specific instrument.
name | must be a valid Instrument name. |
item | is a pointer to the new definition of the instrument. |
bool updateInstrumentByNumber | ( | const int | num, |
const ms_fragmentationrules | item | ||
) |
Update the information for a specific instrument.
num | must be in the range 0..getNumberOfInstruments()-1. |
item | is a pointer to the new definition of the instrument definition. |