te::da::DataSourceCatalog Class Reference

It represents the system catalog of a DataSource. More...

#include <DataSourceCatalog.h>

Inheritance diagram for te::da::DataSourceCatalog:

Classes

struct  dataset_name_cmp
 
struct  sequence_name_cmp
 

Public Member Functions

Basic Methods

Basic methods for a DataSourceCatalog.

 DataSourceCatalog ()
 It creates a new DataSourceCatalog. More...
 
 ~DataSourceCatalog ()
 Destructor. More...
 
unsigned int getId () const
 It returns the catalog identifier. More...
 
void setId (unsigned int id)
 It sets the catalog identifier. More...
 
DataSourcegetDataSource () const
 It returns the DataSource associated to the catalog. More...
 
void setDataSource (DataSource *ds)
 It sets the DataSource associated to the catalog. More...
 
void clear ()
 It clears the catalog, releasing all the resources used by it. More...
 
DataSetType Management Methods

Methods for managing DataSetTypes.

std::size_t getNumberOfDataSets () const
 It returns the number of datasets in the catalog. More...
 
bool datasetExists (const std::string &name) const
 It checks if a dataset schema with the given name is in the catalog. More...
 
void add (const DataSetTypePtr &dt)
 It adds a new dataset schema to the catalog. More...
 
void remove (DataSetType *dt, const bool cascade=false)
 It removes the dataset schema from the catalog. More...
 
void rename (DataSetType *dt, const std::string &newName)
 It renames the dataset schema in the catalog. More...
 
const DataSetTypePtrgetDataSetType (std::size_t i) const
 It returns the i-th dataset schema. More...
 
const DataSetTypePtrgetDataSetType (const std::string &name) const
 It searches for a dataset schema with the given name in the catalog. More...
 
Sequence Management Methods

Methods for managing Sequences.

std::size_t getNumberOfSequences () const
 It returns the number of sequences in the catalog. More...
 
void add (Sequence *s)
 It adds a new sequence to the catalog. More...
 
void remove (Sequence *s)
 It removes the sequence from the catalog. More...
 
void detach (Sequence *s)
 It will detaches the Sequence from the catalog. More...
 
SequencegetSequence (std::size_t i) const
 It returns the i-th Sequence. More...
 
SequencegetSequence (const std::string &name) const
 It searches for a Sequence with the given name in the catalog. More...
 
Helper Methods

Methods used to keep the associations among catalog's objects.

void addRef (ForeignKey *fk)
 It checks if the referenced DataSetType is in the catalog and associate the fk to it. More...
 
void removeRef (ForeignKey *fk)
 It drops the reference between the foreign key and its referenced DataSetType. More...
 
std::pair< std::multimap< DataSetType *, ForeignKey * >::const_iterator, std::multimap< DataSetType *, ForeignKey * >::const_iterator > getRefFK (DataSetType *dt) const
 It returns the list of fk referencing the given DataSetType in the catalog. More...
 
void dropDependentSequences (te::dt::Property *p)
 It drops Sequences that depends on the property. More...
 

Protected Member Functions

Helper Methods for Sequences

Methods used in the internals of DataSourceCatalog to manage Sequences.

void checkSequenceDependency (Sequence *s) const
 It checks if the Sequence is owned by a DataSetType property and if that DataSetType is in the catalog. More...
 
void indexSequenceDependency (Sequence *s)
 It looks if the sequence is owned by a given DataSetType property and insert this information into the sequence depency index. More...
 
void dropDependentSequences (DataSetType *dt)
 It drops Sequences that depends on the DataSetType dt. More...
 
void dropDependentSequenceEntry (Sequence *s)
 It drops the Sequence entry in the DataSetType sequence dependency list. More...
 
Helper Methods for Foreign Keys

Methods used in the internals of DataSourceCatalog to manage Foreign Keys.

void checkFKsDependency (DataSetType *dt) const
 It checks if the DataSetTypes referenced by dt's foreign keys are in the catalog. More...
 
void indexFKs (DataSetType *dt)
 It looks for foreign keys in the DataSetType dt and try to index then with respect to referenced DataSetTypes. More...
 
void dropDependentFKs (DataSetType *dt)
 It drops foreign keys from other DataSetTypes that depends on the attributes in the given DataSetType dt. More...
 

Private Types

typedef boost::multi_index::multi_index_container< DataSetTypePtr, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< dataset_name_cmp >, boost::multi_index::random_access<> > > dataset_idx_type
 
typedef boost::multi_index::multi_index_container< Sequence *, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< sequence_name_cmp >, boost::multi_index::random_access<> > > sequence_idx_type
 

Private Attributes

dataset_idx_type m_datasets
 
std::multimap< DataSetType *, ForeignKey * > m_dependentFkIdx
 A multimap : datasettype -> fk. It tells for a DataSetType the list of fk referencing it. More...
 
DataSourcem_ds
 The DataSource associated to the Catalog. More...
 
unsigned int m_id
 An identification number inside the DataSource. More...
 
std::multimap< DataSetType *, sequence_idx_type::iterator > m_seqFTIdx
 A multimap : owner-dt -> sequence-it. More...
 
sequence_idx_type m_sequences
 

Static Private Attributes

static DataSetTypePtr sm_nullds
 

Detailed Description

It represents the system catalog of a DataSource.

See also
DataSource, Property, DataSetType, Sequence

Definition at line 68 of file DataSourceCatalog.h.

Member Typedef Documentation

◆ dataset_idx_type

typedef boost::multi_index::multi_index_container< DataSetTypePtr, boost::multi_index::indexed_by< boost::multi_index::ordered_unique<dataset_name_cmp>, boost::multi_index::random_access<> > > te::da::DataSourceCatalog::dataset_idx_type
private

Definition at line 459 of file DataSourceCatalog.h.

◆ sequence_idx_type

typedef boost::multi_index::multi_index_container< Sequence*, boost::multi_index::indexed_by< boost::multi_index::ordered_unique<sequence_name_cmp>, boost::multi_index::random_access<> > > te::da::DataSourceCatalog::sequence_idx_type
private

Definition at line 474 of file DataSourceCatalog.h.

Constructor & Destructor Documentation

◆ DataSourceCatalog()

te::da::DataSourceCatalog::DataSourceCatalog ( )

It creates a new DataSourceCatalog.

◆ ~DataSourceCatalog()

te::da::DataSourceCatalog::~DataSourceCatalog ( )

Destructor.

Member Function Documentation

◆ add() [1/2]

void te::da::DataSourceCatalog::add ( const DataSetTypePtr dt)

It adds a new dataset schema to the catalog.

Parameters
dtThe dataset schema to be added to the catalog.
Precondition
The dt must not be associated to another catalog before calling this method.
There is not a dataset schema in the catalog with the same name as dt.
If the dataset schema has foreign keys the referenced schema must be already in the catalog.
Postcondition
The dataset schema will be associated to the catalog.
The catalog will keep track of foreign keys and the referenced dataset schema.
Exceptions
ExceptionIt throws an exception if the dataset schema can not be added.

◆ add() [2/2]

void te::da::DataSourceCatalog::add ( Sequence s)

It adds a new sequence to the catalog.

Parameters
sThe sequence to be added to the catalog.
Precondition
The sequence must not be associated to a catalog before calling this method.
There is not a sequence in the catalog with the same name as the sequence to be added.
There is not a sequence in the catalog with the same id as the sequence to be added.
If the sequence is owned by a given DataSetType property, the DataSetType must already be in the catalog.
Postcondition
The sequence will have the catalog associated to it.
The catalog will take the ownership of the informed sequence.
Exceptions
ExceptionIt throws an exception if the sequence can not be added.
ExceptionIt throws an exception if the sequence is owned by a given DataSetType property and this DataSetType is not in the catalog.

◆ addRef()

void te::da::DataSourceCatalog::addRef ( ForeignKey fk)

It checks if the referenced DataSetType is in the catalog and associate the fk to it.

Parameters
fkThe foreign key to keep the association.
Precondition
The DataSetType referenced by the fk must be in the catalog.
The foreign key must not have been associated before.
Postcondition
If the DataSetType referenced by the foreign key is in the catalog, it will have an association in the catalog.
Exceptions
Itthrows an exception if the referenced DataSetType is not in the DataSourceCatalog.

◆ checkFKsDependency()

void te::da::DataSourceCatalog::checkFKsDependency ( DataSetType dt) const
protected

It checks if the DataSetTypes referenced by dt's foreign keys are in the catalog.

Parameters
dtThe DataSetType we are checking the foreign key dependency is ok.
Exceptions
ExceptionIt throws an exception if one of the foreign key has a referenced FetaureType that is not in the catalog.

◆ checkSequenceDependency()

void te::da::DataSourceCatalog::checkSequenceDependency ( Sequence s) const
protected

It checks if the Sequence is owned by a DataSetType property and if that DataSetType is in the catalog.

Parameters
sThe Sequence we are checking the dependency of a FetaureType.
Exceptions
ExceptionIt throws an exception if the sequence is owned by a FetaureType that is not in the catalog nor could be determined.

◆ clear()

void te::da::DataSourceCatalog::clear ( )

It clears the catalog, releasing all the resources used by it.

◆ datasetExists()

bool te::da::DataSourceCatalog::datasetExists ( const std::string &  name) const

It checks if a dataset schema with the given name is in the catalog.

Parameters
nameThe dataset schema name to be cheked in the catalog.
Returns
True if a dataset with the given name exists in the catalog.

◆ detach()

void te::da::DataSourceCatalog::detach ( Sequence s)

It will detaches the Sequence from the catalog.

Parameters
sThe Sequence to be detached from the catalog.
Precondition
The Sequence must associated to the catalog.
Postcondition
It will drop any association to the Sequence.
The caller of this method will take the ownership of s pointer.

◆ dropDependentFKs()

void te::da::DataSourceCatalog::dropDependentFKs ( DataSetType dt)
protected

It drops foreign keys from other DataSetTypes that depends on the attributes in the given DataSetType dt.

Parameters
dtA DataSetType that belongs to the catalog.
Postcondition
All DataSetTypes foreign keys referencing dt will be dropped (released).

◆ dropDependentSequenceEntry()

void te::da::DataSourceCatalog::dropDependentSequenceEntry ( Sequence s)
protected

It drops the Sequence entry in the DataSetType sequence dependency list.

Parameters
sA Sequence to be removed from the list of dependency.
Postcondition
The entry pointing to the Sequence will be dropped (released).
Exceptions
ExceptionIt throws an exception if the sequence is owned by a dt and it is not in the catalog.

◆ dropDependentSequences() [1/2]

void te::da::DataSourceCatalog::dropDependentSequences ( te::dt::Property p)

It drops Sequences that depends on the property.

Parameters
pA Property that may owns a sequence in the catalog.
Postcondition
All Sequences referencing p will be dropped (released).

◆ dropDependentSequences() [2/2]

void te::da::DataSourceCatalog::dropDependentSequences ( DataSetType dt)
protected

It drops Sequences that depends on the DataSetType dt.

Parameters
dtA DataSetType that belongs to the catalog.
Postcondition
All Sequences referencing dt will be dropped (released).

◆ getDataSetType() [1/2]

const DataSetTypePtr& te::da::DataSourceCatalog::getDataSetType ( std::size_t  i) const

It returns the i-th dataset schema.

Parameters
iThe dataset schema index.
Returns
The i-th dataset schema.
Precondition
i must be in the range: [0, getNumberOfDataSets()).
Note
It doesn't check index range.

◆ getDataSetType() [2/2]

const DataSetTypePtr& te::da::DataSourceCatalog::getDataSetType ( const std::string &  name) const

It searches for a dataset schema with the given name in the catalog.

Parameters
nameThe name of the searched dataset schema.
Returns
A dataset schema with the given name or NULL if none is found.

◆ getDataSource()

DataSource * te::da::DataSourceCatalog::getDataSource ( ) const
inline

It returns the DataSource associated to the catalog.

Returns
The caller of this method will NOT take the ownership of the returned DataSource pointer.
Note
Every catalog that belongs to a DataSource will have an explicit association. If it has no parent, it doesn't belong to any store.

Definition at line 505 of file DataSourceCatalog.h.

References m_ds.

◆ getId()

unsigned int te::da::DataSourceCatalog::getId ( ) const
inline

It returns the catalog identifier.

Returns
A number that may be used to identify the catalog.
Warning
This value will be used by data source driver implementeers. So, don't rely on its value!

Definition at line 495 of file DataSourceCatalog.h.

References m_id.

◆ getNumberOfDataSets()

std::size_t te::da::DataSourceCatalog::getNumberOfDataSets ( ) const
inline

It returns the number of datasets in the catalog.

Returns
The number of datasets in the catalog.

Definition at line 515 of file DataSourceCatalog.h.

References m_datasets.

◆ getNumberOfSequences()

std::size_t te::da::DataSourceCatalog::getNumberOfSequences ( ) const
inline

It returns the number of sequences in the catalog.

Returns
The number of sequences in the catalog.

Definition at line 520 of file DataSourceCatalog.h.

References m_sequences.

◆ getRefFK()

std::pair<std::multimap<DataSetType*, ForeignKey*>::const_iterator, std::multimap<DataSetType*, ForeignKey*>::const_iterator> te::da::DataSourceCatalog::getRefFK ( DataSetType dt) const
inline

It returns the list of fk referencing the given DataSetType in the catalog.

Parameters
dtThe DataSetType we are searching for foreign keys referencing it.
Returns
The list of fk referencing the given DataSetType as a range defined over a pair of iterators.
Note
In the returned iterator, the second component is the end special mark.

Definition at line 340 of file DataSourceCatalog.h.

◆ getSequence() [1/2]

Sequence* te::da::DataSourceCatalog::getSequence ( std::size_t  i) const

It returns the i-th Sequence.

Parameters
iThe Sequence index.
Returns
The i-th Sequence.
Precondition
i must be in the range of [0, getNumberOfSequences()).
Note
The caller will not take the ownership of the returned Sequence.
It doesn't check the index range.

◆ getSequence() [2/2]

Sequence* te::da::DataSourceCatalog::getSequence ( const std::string &  name) const

It searches for a Sequence with the given name in the catalog.

Parameters
nameThe name of the searched Sequence.
Returns
A Sequence with the given name, or NULL if none is found.
Note
The caller will not take the ownership of the returned Sequence.

◆ indexFKs()

void te::da::DataSourceCatalog::indexFKs ( DataSetType dt)
protected

It looks for foreign keys in the DataSetType dt and try to index then with respect to referenced DataSetTypes.

Parameters
dtThe DataSetType whose foreign keys will be indexed.
Precondition
All DataSetTypes referenced by dt foreign keys must be in the catalog.
The foreign keys of dt must not have be indexed before.
Postcondition
If the DataSetType dt has foreign keys they will have an index entry to the referred DataSetType.

◆ indexSequenceDependency()

void te::da::DataSourceCatalog::indexSequenceDependency ( Sequence s)
protected

It looks if the sequence is owned by a given DataSetType property and insert this information into the sequence depency index.

Parameters
sThe sequence we want to index owner information.
Precondition
If the sequence is owned, the associated DataSetType is already in the catalog.
Postcondition
If the sequence s is owned it will have an index entry to the referred DataSetType.
Exceptions
ExceptionIt throws an exception if the sequence is owned by a FetaureType that is not in the catalog nor could be determined.

◆ remove() [1/2]

void te::da::DataSourceCatalog::remove ( DataSetType dt,
const bool  cascade = false 
)

It removes the dataset schema from the catalog.

Parameters
dtThe dataset schema to be removed from the catalog.
cascadeIf true the method will remove also all objects that depends on the dataset schema (like sequences and foreign keys).
Precondition
The dataset schema must be associated to the catalog.
Postcondition
It will drop any association to the dataset schema or its attributes (like sequences and foreign keys) if casacade is true.

◆ remove() [2/2]

void te::da::DataSourceCatalog::remove ( Sequence s)

It removes the sequence from the catalog.

Parameters
sThe sequence to be removed from the catalog.
Precondition
The sequence must associated to the catalog.
Postcondition
The s pointer will be invalidated.

◆ removeRef()

void te::da::DataSourceCatalog::removeRef ( ForeignKey fk)

It drops the reference between the foreign key and its referenced DataSetType.

Parameters
fkThe foreign key to remove the association from the catalog.
Precondition
The DataSetType referenced by the fk must be in the catalog.
The foreign key must have been associated before.
Postcondition
The association between the DataSetType and the foreign key will be removed.
Exceptions
Itthrows an exception if the referenced DataSetType is not in the DataSourceCatalog.

◆ rename()

void te::da::DataSourceCatalog::rename ( DataSetType dt,
const std::string &  newName 
)

It renames the dataset schema in the catalog.

Parameters
dtThe dataset schema to be renamed.
newNameThe new name to be assigned to dt.
Precondition
The dataset schema must be associated to the catalog.
There is not a dataset schema in the catalog with the same value as newName.
Postcondition
All internal indexes pointing to dt will be fixed and the dt will have newName set.
Exceptions
ExceptionIt throws an exception if there is already a dataset schema with the new name in the catalog, or if it doesn't belong to the catalog.

◆ setDataSource()

void te::da::DataSourceCatalog::setDataSource ( DataSource ds)
inline

It sets the DataSource associated to the catalog.

Parameters
dsThe DataSource to be associated to the catalog.
Note
Don't call this method in your code, it will be used by the driver developers!

Definition at line 510 of file DataSourceCatalog.h.

References m_ds.

◆ setId()

void te::da::DataSourceCatalog::setId ( unsigned int  id)
inline

It sets the catalog identifier.

Parameters
idA number that can be used to identify the catalog in its DataSource.
Warning
This value will be used by data source driver implementeers. So, don't rely on its value nor call it if you are not implementing a data source!

Definition at line 500 of file DataSourceCatalog.h.

References m_id.

Member Data Documentation

◆ m_datasets

dataset_idx_type te::da::DataSourceCatalog::m_datasets
private

Definition at line 477 of file DataSourceCatalog.h.

Referenced by getNumberOfDataSets().

◆ m_dependentFkIdx

std::multimap<DataSetType*, ForeignKey*> te::da::DataSourceCatalog::m_dependentFkIdx
private

A multimap : datasettype -> fk. It tells for a DataSetType the list of fk referencing it.

Definition at line 485 of file DataSourceCatalog.h.

◆ m_ds

DataSource* te::da::DataSourceCatalog::m_ds
private

The DataSource associated to the Catalog.

Definition at line 488 of file DataSourceCatalog.h.

Referenced by getDataSource(), and setDataSource().

◆ m_id

unsigned int te::da::DataSourceCatalog::m_id
private

An identification number inside the DataSource.

Definition at line 487 of file DataSourceCatalog.h.

Referenced by getId(), and setId().

◆ m_seqFTIdx

std::multimap<DataSetType*, sequence_idx_type::iterator> te::da::DataSourceCatalog::m_seqFTIdx
private

A multimap : owner-dt -> sequence-it.

Definition at line 482 of file DataSourceCatalog.h.

◆ m_sequences

sequence_idx_type te::da::DataSourceCatalog::m_sequences
private

Definition at line 480 of file DataSourceCatalog.h.

Referenced by getNumberOfSequences().

◆ sm_nullds

DataSetTypePtr te::da::DataSourceCatalog::sm_nullds
staticprivate

Definition at line 490 of file DataSourceCatalog.h.


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