Ilwis-Objects  1.0
GIS and Remote Sensing framework for data access and processing
 All Classes Functions Enumerations Pages
Public Member Functions | Protected Member Functions | List of all members
Ilwis::Table Class Referenceabstract

#include <table.h>

Inheritance diagram for Ilwis::Table:
Ilwis::IlwisObject Ilwis::Identity Ilwis::AttributeTable Ilwis::BaseTable Ilwis::DatabaseTable Ilwis::FlatTable

Public Member Functions

virtual quint32 recordCount () const =0
 
virtual quint32 columnCount () const =0
 
virtual void recordCount (quint32 r)=0
 
virtual bool createTable ()=0
 
virtual bool addColumn (const QString &name, const IDomain &domain)=0
 
virtual bool addColumn (const QString &name, const QString &domainname)=0
 
virtual bool addColumn (const ColumnDefinition &def)=0
 
virtual ColumnDefinition columndefinition (const QString &nme) const =0
 
virtual ColumnDefinition columndefinition (quint32 index) const =0
 
virtual ColumnDefinitioncolumndefinition (quint32 index)=0
 
virtual void columndefinition (const ColumnDefinition &coldef)=0
 
virtual void newRecord ()=0
 
virtual std::vector< QVariant > record (quint32 n) const =0
 
virtual void record (quint32 rec, const std::vector< QVariant > &vars, quint32 offset=0)=0
 
virtual std::vector< QVariant > column (const QString &nme, quint32 start=0, quint32 stop=2e9) const =0
 
virtual std::vector< QVariant > column (quint32 index, quint32 start=0, quint32 stop=2e9) const =0
 
virtual void column (const QString &nme, const std::vector< QVariant > &vars, quint32 offset=0)=0
 
virtual void column (const quint32 index, const std::vector< QVariant > &vars, quint32 offset=0)=0
 
virtual QVariant cell (const QString &col, quint32 rec, bool asRaw=true) const =0
 
virtual QVariant cell (const quint32 index, quint32 rec, bool asRaw=true) const =0
 
virtual void setCell (const QString &col, quint32 rec, const QVariant &var)=0
 
virtual void setCell (quint32 col, quint32 rec, const QVariant &var)=0
 
virtual quint32 columnIndex (const QString &nme) const =0
 
virtual std::vector< quint32 > select (const QString &conditions) const =0
 
virtual void dataLoaded (bool yesno)=0
 
virtual bool isDataLoaded () const =0
 
- Public Member Functions inherited from Ilwis::IlwisObject
 IlwisObject ()
 
 IlwisObject (const Resource &source)
 
virtual bool prepare ()
 
void setName (const QString &nm)
 
void setCode (const QString &cd)
 
QDateTime modifiedTime () const
 returns the moment when the object was last modified More...
 
void setModifiedTime (const Time &time)
 sets the last modified time of the object More...
 
Time createTime () const
 
void setCreateTime (const Time &time)
 
virtual QString toString ()
 translates the defintion of an object to a string representation More...
 
virtual void setConnector (ConnectorInterface *connector, int mode=cmINPUT|cmOUTPUT)
 connects an ilwisobject to an input or output source More...
 
virtual bool isEqual (const Ilwis::IlwisObject *obj) const
 isEqual compares the properties of ilwisobjects to test for equality. More...
 
virtual bool isValid () const
 isValid Tests the validity of an ilwisobject. More...
 
virtual bool isReadOnly () const
 isReadOnly tells if the source/target of the ilwisobject maybe modifiable. More...
 
virtual void setReadOnly (bool yesno)
 
virtual bool hasChanged () const
 
virtual void changed (bool yesno)
 
virtual IlwisTypes ilwisType () const =0
 
virtual bool prepare (const QString &def)
 prepare More...
 
bool fromInternal (const QSqlRecord &rec)
 
bool isAnonymous () const
 
virtual Resource source (int mode=cmINPUT) const
 source the location of the source that represents the physical read origin of this object More...
 
virtual bool store (int mode=smMETADATA|smBINARYDATA)
 target the location of the source that represents the physical write target of this object More...
 
void connectTo (const QUrl &url, const QString &format, const QString &fnamespace, ConnectorMode cmode)
 
virtual IlwisObjectclone ()
 
virtual bool merge (const IlwisObject *obj, int options=0)
 
bool isSystemObject () const
 
bool isInternalObject () const
 
- Public Member Functions inherited from Ilwis::Identity
QString code () const
 code returns the code of the identity. If no code is attached it will return sUNDEF ("?"). More...
 
quint64 id () const
 id returns a unsigned 64-bit number unique for the objects using the identity More...
 
virtual QString name () const
 name returns the name of an object. All objects have names though names need not to be unique More...
 
void setName (const QString &n)
 setName sets the name of an object. All objects have names though names need not to be unique More...
 
virtual QString description () const
 
void setDescription (const QString &desc)
 

Protected Member Functions

 Table (const Resource &resource)
 
- Protected Member Functions inherited from Ilwis::IlwisObject
QScopedPointer
< ConnectorInterface > & 
connector (int mode=cmINPUT|cmOUTPUT)
 
const QScopedPointer
< ConnectorInterface > & 
connector (int mode=cmINPUT|cmOUTPUT) const
 
bool setValid (bool yesno)
 
void copyTo (IlwisObject *obj)
 
- Protected Member Functions inherited from Ilwis::Identity
 Identity (const QString &name, qint64 id=i64UNDEF, const QString &cde=sUNDEF, const QString &descr=sUNDEF)
 
void prepare (quint64 base=0)
 
void setId (quint64 newid)
 

Additional Inherited Members

- Public Types inherited from Ilwis::IlwisObject
enum  ConnectorMode { cmINPUT =1, cmOUTPUT =2, cmEXTENDED =4 }
 The ConnectorMode enum Describes the state of the instance of the connector. More...
 
enum  StoreMode { smMETADATA =1, smBINARYDATA =2 }
 
- Static Public Member Functions inherited from Ilwis::IlwisObject
template<typename T >
static T create (const QString &def)
 
template<typename T >
static T create (quint64 id)
 
static IlwisObjectcreate (const Resource &source, const PrepareOptions &options=PrepareOptions())
 
static IlwisTypes findType (const QString &source)
 findType More...
 
static QString type2Name (IlwisTypes t)
 
static IlwisTypes name2Type (const QString &name)
 
static void addTypeFunction (IlwisTypeFunction)
 addTypeFunction More...
 
static IlwisTypes name2ExtendedType (const QString &dname)
 
- Protected Attributes inherited from Ilwis::IlwisObject
std::mutex _mutex
 
std::mutex _loadforstore
 

Detailed Description

Generic interface for tabular data in Ilwis. In Ilwis a table is a structure with rows and columns in 2D. There are two main implementations of the table

Member Function Documentation

virtual bool Ilwis::Table::addColumn ( const QString &  name,
const IDomain domain 
)
pure virtual

adds a column to the current set of columns of this table
the name string must be unique and the domain must be valid.
if this collumn creates a duplicate nothing will happen.
the collumn will be filled with appropriate defaults depending on the domain

See Also
IDomain
Parameters
namethe name of a column must be unique among the columns
domainthe domain of the new column
Returns
true if the column is succesfully added, false if some error occurred. The nature of the error can be found in the issue logger

Implemented in Ilwis::FlatTable, Ilwis::BaseTable, Ilwis::DatabaseTable, and Ilwis::AttributeTable.

virtual bool Ilwis::Table::addColumn ( const QString &  name,
const QString &  domainname 
)
pure virtual

adds a column to the current set of columns of this table.
duplicate columns wil be skipped
The new collumn contents will be set to appropriate defaults depending on the domain
The name string must be unique in the set of collumns and the domainname must be valid

Parameters
namethe name of a column must be unique among the columns
domainthe domain of the new column
Returns
true if the column is succesfully added, false if some error occurred. The nature of the error can be found in the issue logger

Implemented in Ilwis::BaseTable.

virtual bool Ilwis::Table::addColumn ( const ColumnDefinition def)
pure virtual

adds a column to the column definitions.
ColumnDefinition must be valid.
The new column contents will be set to appropriate defaults depending on the domain

Parameters
defThe ColumnDefinition of the new column
Returns
true if succesful. Duplicate columns are not allowed

Implemented in Ilwis::FlatTable, Ilwis::BaseTable, and Ilwis::AttributeTable.

virtual QVariant Ilwis::Table::cell ( const QString &  col,
quint32  rec,
bool  asRaw = true 
) const
pure virtual

returns the value of a single record/field combination ( a cell).
Disabling asRaw (setting it to false) has negative effects on performance.

Parameters
colcolumn name
recrecord number
asRawwhen set to false it will return the String value on Thematic and Identifier domains
Returns
the value of the cell or an invalid qvariant if an error occured. The nature of the error can be found in the issue logger

Implemented in Ilwis::DatabaseTable, and Ilwis::FlatTable.

virtual QVariant Ilwis::Table::cell ( const quint32  index,
quint32  rec,
bool  asRaw = true 
) const
pure virtual

returns the value of a single record/field combination ( a cell).
Disabling asRaw (setting it to false) has negative effects on performance.

Parameters
indexcolumn index
asRawwhen set to false it will return the String value on Thematic and Identifier domains
recrecord number
Returns
the value of the cell or an invalid qvariant if an error occured. The nature of the error can be found in the issue logger

Implemented in Ilwis::DatabaseTable, and Ilwis::FlatTable.

virtual std::vector<QVariant> Ilwis::Table::column ( const QString &  nme,
quint32  start = 0,
quint32  stop = 2e9 
) const
pure virtual

returns the content of a column with a name in a vector. Will return an empty vector if there is no collumn with that name

Parameters
nmename of the column to be returned
startThe index at which it should start returning values(within the collumn)
stopThe index at which it should stop returning values(within the collumn)
Returns
A filled variantlist or an empty list if an error occurred. The nature of the error can be found in the issue logger

Implemented in Ilwis::DatabaseTable, and Ilwis::FlatTable.

virtual std::vector<QVariant> Ilwis::Table::column ( quint32  index,
quint32  start = 0,
quint32  stop = 2e9 
) const
pure virtual

returns the content of a column at a index in a vector. Will return an empty vector if there is no column with that name

Parameters
indexthe index of the column to be returned
startThe index at which it should start returning values(within the collumn)
stopThe index at which it should stop returning values(within the collumn)
Returns
A filled variantlist or an empty list if an error occurred. The nature of the error can be found in the issue logger

Implemented in Ilwis::DatabaseTable, and Ilwis::FlatTable.

virtual void Ilwis::Table::column ( const QString &  nme,
const std::vector< QVariant > &  vars,
quint32  offset = 0 
)
pure virtual

sets a column with values from variantlist. The list doesnt need to contain all the rows in a column but may contain a subset.
Note that the rows are in consecutive order.

Parameters
nmename of the column to be set
varsvalues of the rows
offsetstarting row form where the values are set. If the number of values to be added goes beyond the size of the table, new records will be added

Implemented in Ilwis::DatabaseTable, and Ilwis::FlatTable.

virtual void Ilwis::Table::column ( const quint32  index,
const std::vector< QVariant > &  vars,
quint32  offset = 0 
)
pure virtual

sets a column with values from variantlist. The list doesnt need to contain all the rows in a column but may contain a subset.
Note that the rows are in consecutive order.

Parameters
indexindex of the column to be set
varsvalues of the rows
offsetstarting row form where the values are set. If the number of values to be added goes beyond the size of the table, new records will be added

Implemented in Ilwis::DatabaseTable, and Ilwis::FlatTable.

virtual quint32 Ilwis::Table::columnCount ( ) const
pure virtual

returns the number of columns in a table.
cannot be negative.

Returns
columns in the table

Implemented in Ilwis::BaseTable.

virtual ColumnDefinition Ilwis::Table::columndefinition ( const QString &  nme) const
pure virtual

retrieves the definition of the column with the given name.
if there is no collumn with that name an invalid ColumnDefinition will be returned.

See Also
ColumnDefinition
Parameters
nmename of the column definition to be retrieved
Returns
a column definition or an invalid defintion if a non existing column was retrieved

Implemented in Ilwis::BaseTable, and Ilwis::AttributeTable.

virtual ColumnDefinition Ilwis::Table::columndefinition ( quint32  index) const
pure virtual

retrieves the definition of the column at the given index.
if there is no collumn at this index an invalid ColumnDefinition will be returned.

See Also
ColumnDefinition
Parameters
indexindex of the column definition to be retrieved
Returns
a column definition or an invalid defintion if a non existing column was retrieved

Implemented in Ilwis::BaseTable.

virtual ColumnDefinition& Ilwis::Table::columndefinition ( quint32  index)
pure virtual

retrieves a reference to the definition of the column.
if there is no collumn at this index nullptr will be returned.

See Also
ColumnDefinition
Parameters
indexindex of the ColumnDefinition to be retrieved
Returns
a reference to columndefinition or an invalid defintion if a non existing column was retrieved

Implemented in Ilwis::BaseTable.

virtual void Ilwis::Table::columndefinition ( const ColumnDefinition coldef)
pure virtual

sets a new column definition. The new definition must be valid.

See Also
ColumnDefinition
Parameters
coldefthe new ColumnDefinition to be set

Implemented in Ilwis::BaseTable.

virtual quint32 Ilwis::Table::columnIndex ( const QString &  nme) const
pure virtual

Translates a String with a column name into a column index

Parameters
nmethe name of the column
Returns
the index of the column with the given name and iundef illegaal

Implemented in Ilwis::BaseTable, and Ilwis::AttributeTable.

virtual bool Ilwis::Table::createTable ( )
pure virtual

Creates a table based on the definitions in the columndefinition members. Will load the data in the specified amount of collumns and rows

Returns
true if succesfull

Implemented in Ilwis::BaseTable, Ilwis::DatabaseTable, Ilwis::FlatTable, and Ilwis::AttributeTable.

virtual void Ilwis::Table::newRecord ( )
pure virtual

Adds a new record to this table It will be filled with appropriate default values depending on the domain(s)

Implemented in Ilwis::DatabaseTable, and Ilwis::FlatTable.

virtual std::vector<QVariant> Ilwis::Table::record ( quint32  n) const
pure virtual

retrieves a record from a table. A record contains all the fields for one row. This method is implemented in the derivatives
of table as how records are organized is quite different between the derivatives

Parameters
nthe row/record number of the record
Returns
A filled variantlist or an empty list if an error occurred. The nature of the error can be found in the issue logger

Implemented in Ilwis::DatabaseTable, Ilwis::FlatTable, and Ilwis::AttributeTable.

virtual void Ilwis::Table::record ( quint32  rec,
const std::vector< QVariant > &  vars,
quint32  offset = 0 
)
pure virtual

sets a record with values from variantlist. The list doesnt need to contain all the fields in a record but may contain a subset.
Note that the fields are in consecutive order. It is up to the programmer that the order of fields in the list match the order of fields in the table

Parameters
recrecord that has to be updated. If the record number is beyond the last record or the record is iUNDEF, the record will appended to the end
varsthe list values to be set
offsetstarting point of the field to be set

Implemented in Ilwis::DatabaseTable, and Ilwis::FlatTable.

virtual quint32 Ilwis::Table::recordCount ( ) const
pure virtual

return the number of rows in a table.
cannot be negative.

Returns
rows in the table

Implemented in Ilwis::BaseTable.

virtual void Ilwis::Table::recordCount ( quint32  r)
pure virtual

sets the number of rows in a table. If the number of rows is bigger than the current number of rows is the extra records will be filled with appropriate defaults depending on the domain.
if the number is smaller the excess records will be deleted.
Negative values are not allowed.

Parameters
rthe new row number

Implemented in Ilwis::BaseTable.

virtual std::vector<quint32> Ilwis::Table::select ( const QString &  conditions) const
pure virtual

Selects the indices of all collumns that meet the conditions specified in the conditions String
so for example: if conditions is

col1 < 5 AND col2 == "two"


it will return all indices at which collumns 1 and 2 meet the requirements

This function is still under development, only the most basic expressions are implemented at this time

Parameters
conditions
Returns

Implemented in Ilwis::DatabaseTable, and Ilwis::FlatTable.

virtual void Ilwis::Table::setCell ( const QString &  col,
quint32  rec,
const QVariant &  var 
)
pure virtual

Sets the value of a single cell

Parameters
colcolumn name of the cell to be set
recrecord number of the cell to be set
varthe new value of the cell

Implemented in Ilwis::DatabaseTable, and Ilwis::FlatTable.

virtual void Ilwis::Table::setCell ( quint32  col,
quint32  rec,
const QVariant &  var 
)
pure virtual

Sets the value of a single cell

Parameters
colindex of the column of the cell to be set
recrecord number of the cell to be set
varthe new value of the cell

Implemented in Ilwis::DatabaseTable, and Ilwis::FlatTable.


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