Reference Manual: DSL abstractDataSource
From DSL
DSL_abstractDataSource is an abstract class that defines basic functionality for a data source. Examples of data sources are: a text file or a relational database. The role of this class is to define a set of basic methods for data access.
This class provides an interface to simple consecutive access to data. Additionally it assumes that the data source can be read only once. This may not be true for all the data sources and some implementations of data sources can provide random access to elements. A generic piece of code that allows accessing all elements for any class derived from DSL_abstractDataSource is shown below:
DSL_dataElement e;
while (dataSource.NextRecord())
{
while (dataSource.NextRecordElement(e))
std::cout << e.i << " ";
std::cout << std::endl;
}
Methods
- void GetVariablesInfo(std::vector<DSL_variableInfo> &here)
This method allows to access information about variables. The argument is a reference to a vector of DSL_variableInfo structures provided by the user.
- int NumVariables() const
This method returns the number of variables in the data source.
- bool NextRecord()
This method returns true, if there exist one or more unread records in the data source. If the method returns false, this means that all the records in the data source were read.
- bool NextRecordElement(DSL_dataElement &here)
This method provides access to a single data element. It returns true, if there are more data elements in the record. It returns falseif the read element was the last element of the record. In that case, the user should test if there are more records to read.
