Ilwis-Objects
1.0
GIS and Remote Sensing framework for data access and processing
|
#include <resource.h>
Public Member Functions | |
Resource () | |
Resource (const Resource &resource) | |
Resource (const QUrl &url, quint64 tp, bool isNew=true) | |
Resource (const QString &name, quint64 tp, bool isNew=true) | |
Resource (quint64 tp, const QUrl &url=INTERNAL_OBJECT) | |
Resource (const QSqlRecord &rec) | |
void | setName (const QString &nm, bool adaptUrl=true) |
QVariant | operator[] (const QString &property) const |
bool | hasProperty (const QString &property) const |
void | addProperty (const QString &key, const QVariant &value) |
QUrl | url () const |
void | setUrl (const QUrl &url) |
QUrlQuery | urlQuery () const |
bool | hasUrlQuery () const |
QString | toLocalFile (bool relative=false) const |
QUrl | container (int level=0) const |
void | addContainer (const QUrl &url, int level=0) |
quint64 | size () const |
QString | dimensions () const |
IlwisTypes | ilwisType () const |
IlwisTypes | extendedType () const |
void | setIlwisType (IlwisTypes tp) |
void | setExtendedType (IlwisTypes tp) |
void | prepare () |
bool | store (QSqlQuery &queryItem, QSqlQuery &queryProperties) const |
bool | isValid () const |
bool | operator() (const Ilwis::Resource &resource) |
void | setId (quint64 newid) |
Resource | copy (quint64 id) const |
bool | isRoot () const |
![]() | |
virtual void | setCode (const QString &code) |
sets the code for this instance More... | |
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) |
Static Public Member Functions | |
static QString | toLocalFile (const QUrl &url, bool relative=false, const QString &ext=sUNDEF) |
static bool | isRoot (const QString &txt) |
Protected Member Functions | |
void | stringAsUrl (const QString &txt, IlwisTypes tp, bool isNew) |
void | checkUrl (IlwisTypes tp) |
![]() | |
Identity (const QString &name, qint64 id=i64UNDEF, const QString &cde=sUNDEF, const QString &descr=sUNDEF) | |
void | prepare (quint64 base=0) |
void | setId (quint64 newid) |
Design In Ilwis a Resource is a unique definition of data or processing that can be translated
into a single IlwisObject or Catalog. For example the location to a shape file or a query
on a certain database. A Resource is identified by a unique combination of location
(an url) and type. Often a single data source can be mapped to several resources. E.g
a GeoTiff can be mapped to a GridCoverage obviously but it can also be mapped to a
CoordinateSystem as the data for a full definition of the CoordinateSystem is also part
of the GeoTiff file. Resources can be sub divided into three categories: data objects,
operation objects and catalogs. The data objects can be seen as “Ilwis objects light”
and the catalogs are the containers for these data objects. Containers are defined as
queries on the MasterCatalog).
Resources expose the following properties
Resource::Resource | ( | ) |
Constructs an empty Resource
Resource::Resource | ( | const Resource & | resource | ) |
Copy constructor, other resource must not be null
resource | the Resource that should be copied |
Resource::Resource | ( | const QUrl & | url, |
quint64 | tp, | ||
bool | isNew = true |
||
) |
Creates a resource from an url and a type Will fail if the url or the type is invalid/undefined
url | the url that should be used to create this resource |
tp | the type of the resource |
isNew | set to false if you are not making a new Resource defaults to true (singletons) |
Resource::Resource | ( | const QString & | name, |
quint64 | tp, | ||
bool | isNew = true |
||
) |
Resource::Resource | ( | quint64 | tp, |
const QUrl & | url = INTERNAL_OBJECT |
||
) |
Creates an resource from a file, the file has to be specified with a valid url
tp | the type of the resource |
url | The url to the file you want to load in this resource |
Resource::Resource | ( | const QSqlRecord & | rec | ) |
Creates a new Resource from a Database record, this record should come from the mastercatalog
rec |
void Resource::addContainer | ( | const QUrl & | url, |
int | level = 0 |
||
) |
adds a container to this resource, defines the container this resource is in inside ilwis
url | The container that has to be set |
level | The level of the new container |
void Resource::addProperty | ( | const QString & | key, |
const QVariant & | value | ||
) |
Adds a property to this resource, a propert is a combination of a key and a value.
the key can also be seen as the name of the property.
key | |
value |
Resource Resource::copy | ( | quint64 | id | ) | const |
Copies this resource, only difference is the id, since Resources are always singletons.
The new Resource will be prepared and than returned
id | the id of the copy |
QString Resource::dimensions | ( | ) | const |
IlwisTypes Resource::extendedType | ( | ) | const |
bool Resource::hasProperty | ( | const QString & | property | ) | const |
Checks whether this Resource has a certain property, a resource always has a "name" and a "id"
property | the property that should be checked |
bool Resource::hasUrlQuery | ( | ) | const |
Indicates if the Resource has been created with a url containing a query string. If so it can be accessed by urlQuery().
IlwisTypes Resource::ilwisType | ( | ) | const |
Returns the ilwis type of this Resource, anything is possible
bool Resource::isValid | ( | ) | const |
Checks if this Resource is valid a resource is valid if it has a valid name, a valid IlwisType and the url to the resource is valid
bool Resource::operator() | ( | const Ilwis::Resource & | resource | ) |
override of the operater, checks whether this Resource is smaller than the supplied resource, returns true if this is the case.
This method is for sorting purposes, it gets sorted first on url, and afterwards on ilwistype
resource | the resource this should be compared with |
QVariant Resource::operator[] | ( | const QString & | property | ) | const |
override of the [] operator, allows you to query this resource for some of its data.
You can query either for an "id" or an "name", these will always work, any other property might fail.
property | the property that should be retrieved from the attributetable |
void Resource::prepare | ( | ) |
Prepares this Resource
void Resource::setExtendedType | ( | IlwisTypes | tp | ) |
Sets the extendedType of this Resource
tp | the new extended type of this resource |
void Resource::setId | ( | quint64 | newid | ) |
Sets a new id on this Resource. A new id has to be unique, and not registered in the catalog
newid | the new id of this resource |
void Resource::setIlwisType | ( | IlwisTypes | tp | ) |
Sets the ilwistype of this Resource.
usefull in the case the type of this resource can not be resolved from the filename / extension
tp | the new ilwistype of this resource |
void Resource::setName | ( | const QString & | nm, |
bool | adaptUrl = true |
||
) |
Changes the name of this resource, can adapt the file name on the disk
nm | the new name of this Resource |
adaptUrl | set to false if you do not want to change the file name |
void Resource::setUrl | ( | const QUrl & | url | ) |
quint64 Resource::size | ( | ) | const |
bool Resource::store | ( | QSqlQuery & | queryItem, |
QSqlQuery & | queryProperties | ||
) | const |
Store this resource in the sql database
queryItem | The item that should be stored |
queryProperties | The properties of the item that should be stored |
QString Resource::toLocalFile | ( | bool | relative = false | ) | const |
Generates the path to the local file of this Resource (C://etc/etc/etc)
relative | set to true if you want to generate the path relative to the current working directory |
|
static |
Creates a localfile path representing this Resource.
The url must be valid.
url | The location of the file |
relative | set to true if you want a path relative to the workingcatalog |
QUrl Resource::url | ( | ) | const |
QUrlQuery Resource::urlQuery | ( | ) | const |
Gives access to the query when this Resource has been created with a url containing a query string. If there the url did not contain a query string the returned QUrlQuery is empty. This however can be checked via hasUrlQuery() beforehand.