Home ·
Classes ·
Annotated Classes ·
Modules ·
Members ·
Namespaces ·
Related Pages
This section contains a short introduction to three datastructures you will definitely need when programming with OpenMS. The datastructures module of the class documentation contains many more classes, which are not mentioned here in detail. The classes described in this section can be found in the DATASTRUCTURES folder.
The OpenMS string implementation String is based on the STL std::string. In order to make the OpenMS string class more convenient, a lot of methods have been implemented in addition to the methods provided by the base class. A selection of the added functionaliy is given here:
- Checking for a substring (suffix, prefix, substring, char)
- Extracting a substring (suffix, prefix, substring)
- Trimming (left, right, both sides)
- Concatenation of string and other primitive types with operator+
- Construction from QString and conversion to QString
Many OpenMS classes, especially the kernel classes, need to store some kind of d-dimensional coordinates. The template class DPosition is used for that purpose. The interface of DPosition is pretty straightforward. The operator[] is used to access the coordinate of the different dimensions. The dimensionality is stored in the enum value DIMENSION. The following example (Tutorial_DPosition.C) shows how to print a DPosition to the standard output stream.
First we need to include the header file for DPosition and iostream. Then we import all the OpenMS symbols to the scope with the using directive.
The first commands in the main method initialize a 2-dimensional DPosition :
Int main()
{
DPosition<2> pos;
pos[0] = 8.15;
pos[1] = 47.11;
Finally we print the content of the DPosition to the standard output stream:
for (UInt i = 0; i < DPosition<2>::DIMENSION; ++i)
{
std::cout << "Dimension " << i << ": "<< pos[i] << std::endl;
}
return 0;
}
The output of our first little OpenMS program is the following:
Dimension 0: 8.15
Dimension 1: 47.11
Another important datastructure we need to look at in detail is DRange. It defines a d-dimensional, half-open interval through its two DPosition members. These members are accessed by the min and max methods and can be set by the setMin and setMax methods.
DRange maintains the invariant that min is geometrically less or equal to max, i.e.
for each dimension x. The following example (Tutorial_DRange.C) demonstrates this behavior.
This time, we skip everything before the main method. In the main method, we create a range and assign values to min and max. Note that the the minimum value of the first dimension is larger than the maximum value.
Int main()
{
DRange<2> range;
range.setMin( DPosition<2>(2.0, 3.0) );
range.setMax( DPosition<2>(1.0, 5.0) );
Then we print the content of range :
for (UInt i = 0; i < DRange<2>::DIMENSION; ++i)
{
std::cout << "min " << i << ": "<< range.min()[i] << std::endl;
std::cout << "max " << i << ": "<< range.max()[i] << std::endl;
}
return 0;
}
The output is:
min 0: 1
max 0: 1
min 1: 3
max 1: 5
As you can see, the minimum value of dimension one was adjusted in order to make the maximum of 1 conform with the invariant.
DIntervalBase is the closed interval counterpart (and base class) of DRange. Another class derived from DIntervalBase is DBoundingBox. It also represents a closed interval, but differs in the methods. Please have a look at the class documentation for details.
Generated Tue Apr 1 15:36:40 2008 -- using doxygen 1.5.4 |
OpenMS / TOPP 1.1 |