sptk2 logo
SPTK Home Page

sptk::CDataSource Class Reference
[Utility Classes]

Universal data source for many SPTK widgets. More...

#include <CDataSource.h>

Inheritance diagram for sptk::CDataSource:

sptk::CMemoryDS sptk::CQuery sptk::CDirectoryDS sptk::CFtpDS sptk::CImapDS

List of all members.

Public Member Functions

 CDataSource ()
 Default constructor.
virtual ~CDataSource ()
 Destructor.
virtual const CFieldoperator[] (uint32_t fieldIndex) const =0
virtual CFieldoperator[] (uint32_t fieldIndex)=0
virtual const CFieldoperator[] (const char *fieldName) const =0
virtual CFieldoperator[] (const char *fieldName)=0
virtual uint32_t fieldCount () const =0
virtual uint32_t recordCount () const =0
virtual void * user_data () const
 Returns user_data associated with the datasource.
virtual bool readField (const char *fieldName, CVariant &fieldValue)=0
virtual bool writeField (const char *fieldName, const CVariant &fieldValue)=0
virtual bool open ()
 Opens the datasource. Implemented in derved class.
virtual bool close ()
 Closes the datasource. Implemented in derved class.
virtual bool first ()
 Moves to the first record of the datasource. Implemented in derved class.
virtual bool next ()
 Moves to the next record of the datasource. Implemented in derved class.
virtual bool prior ()
 Moves to the prior record of the datasource. Implemented in derved class.
virtual bool last ()
 Moves to the last record of the datasource. Implemented in derved class.
virtual bool find (CVariant position)
 Moves to the specified record position of the datasource. Implemented in derved class.
virtual bool eof () const
 Returns true if there are no more records in the datasource. Implemented in derved class.
bool load ()
 Loads data into the datasource.
bool save ()
 Saves data from the datasource.
void rowToXML (CXmlNode &node, bool compactXmlMode) const
 Saves dataset row data into XML.
virtual void toXML (CXmlNode &parentNode, std::string nodeName, bool compactXmlMode)
 Saves data into XML.

Protected Member Functions

virtual bool loadData ()
 Loads datasource data. Should be implemented in derived class.
virtual bool saveData ()
 Saves data from datasource. Should be implemented in derived class.

Friends

class Fl_Group


Detailed Description

Universal data source for many SPTK widgets.

It's designed as a base class for multiple datasources available in SPTK. The main idea is to provide the simple interface that allows to open the datasource with certain parameters and read or write the datasource fields. And don't you forget to close it :)


Member Function Documentation

virtual uint32_t sptk::CDataSource::fieldCount (  )  const [pure virtual]

Returns field count in the datasource. Purely virtual. Should be implemented in derived class

Returns:
field count

Implemented in sptk::CMemoryDS, and sptk::CQuery.

virtual CField& sptk::CDataSource::operator[] ( const char *  fieldName  )  [pure virtual]

Field access by the field name, const version. Purely virtual. Should be implemented in derived class

Parameters:
fieldName const char *, field name
Returns:
field reference

Implemented in sptk::CMemoryDS, and sptk::CQuery.

virtual const CField& sptk::CDataSource::operator[] ( const char *  fieldName  )  const [pure virtual]

Field access by the field name, const version. Purely virtual. Should be implemented in derived class

Parameters:
fieldName const char *, field name
Returns:
field reference

Implemented in sptk::CMemoryDS, and sptk::CQuery.

virtual CField& sptk::CDataSource::operator[] ( uint32_t  fieldIndex  )  [pure virtual]

Field access by the field index, non-const version Purely virtual. Should be implemented in derived class

Parameters:
fieldIndex uint32_t, field index
Returns:
field reference

Implemented in sptk::CMemoryDS, and sptk::CQuery.

virtual const CField& sptk::CDataSource::operator[] ( uint32_t  fieldIndex  )  const [pure virtual]

Field access by the field index, const version. Purely virtual. Should be implemented in derived class

Parameters:
fieldIndex uint32_t, field index
Returns:
field reference

Implemented in sptk::CMemoryDS, and sptk::CQuery.

virtual bool sptk::CDataSource::readField ( const char *  fieldName,
CVariant fieldValue 
) [pure virtual]

Reads the field by name from the datasource. Purely virtual. Should be implemented in derived class

Parameters:
fieldName const char *, field name
fieldValue CVariant, field value

Implemented in sptk::CMemoryDS, and sptk::CQuery.

virtual uint32_t sptk::CDataSource::recordCount (  )  const [pure virtual]

Returns record count in the datasource. Purely virtual. Should be implemented in derived class

Returns:
record count

Implemented in sptk::CMemoryDS, and sptk::CQuery.

void sptk::CDataSource::rowToXML ( CXmlNode node,
bool  compactXmlMode 
) const

Saves dataset row data into XML.

If the compactXmlMode is true, the node would have fields presented as attributues. Otherwise, the fields are stored as subnodes.

Parameters:
node CXmlNode&, the XML node to fill in
compactXmlMode bool, compact XML flag

virtual void sptk::CDataSource::toXML ( CXmlNode parentNode,
std::string  nodeName,
bool  compactXmlMode 
) [virtual]

Saves data into XML.

Opens the dataset, reads every row, and closes dataset. For every row in the dataset, creates the node with the name nodeName. If the compactXmlMode is true, the nodes would have fields presented as attributues. Otherwise, the fields are stored as subnodes.

Parameters:
parentNode CXmlNode&, the XML node to add subnodes to
nodeName std::string, the name for subnodes
compactXmlMode bool, compact XML flag

virtual bool sptk::CDataSource::writeField ( const char *  fieldName,
const CVariant fieldValue 
) [pure virtual]

Writes the field by name from the datasource. Purely virtual. Should be implemented in derived class

Parameters:
fieldName const char *, field name
fieldValue CVariant, field value

Implemented in sptk::CMemoryDS, and sptk::CQuery.


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

Mon Mar 5 11:55:56 2012: SPTK 3.5.7