soma-io  5.0.5
soma::DataSourceList Class Reference

This class allows to manipulate "lists" of pointers to DataSource. More...

#include <soma-io/datasource/datasourcelist.h>

Collaboration diagram for soma::DataSourceList:

Public Member Functions

 DataSourceList ()
 Default constructor : Builds a map containing only ( "default", empty pointer ) More...
 
 DataSourceList (const carto::rc_ptr< DataSource > &ds, const std::string &type="default")
 Constructor : builds a 1-element map This allows to construct easily a 1 element list, useful when declaring a Reader which creator takes a source as parameter. More...
 
 DataSourceList (const DataSourceList &)
 Copy constructor. More...
 
DataSourceListoperator= (const DataSourceList &)
 
virtual ~DataSourceList ()
 
bool operator== (const DataSourceList &) const
 
bool operator!= (const DataSourceList &) const
 
bool empty () const
 Returns true only if no keyword inserted. More...
 
std::set< std::string > types () const
 Returns existing keywords. More...
 
int typecount () const
 
bool exists (const std::string &) const
 
bool empty (const std::string &) const
 
int size (const std::string &) const
 
const carto::rc_ptr< DataSource > & dataSource (const std::string &s="default", int i=0) const
 Accessing an element of the list If keyword doesn't exist, or is empty, or coordinate is undefined, launches exception. More...
 
carto::rc_ptr< DataSource > & dataSource (const std::string &s="default", int i=0)
 Accessing an element of the list If keyword doesn't exist, or is empty, or coordinate is undefined, launches exception. More...
 
void addDataSource (const std::string &, const carto::rc_ptr< DataSource > &)
 Adds an element to the dictionary If new keyword, creates it. More...
 
void reset ()
 sets the list and keywords empty. More...
 

Protected Attributes

std::map< std::string, std::vector< carto::rc_ptr< DataSource > > > _dslist
 

Detailed Description

This class allows to manipulate "lists" of pointers to DataSource.

It has the design of a dictionary in order to sort sources by content (header, minf, data, ...). Since those contents depend on the format, the keywords used are defined by specific checkers and readers.

See also
FormatChecker FormatReader

The only global keyword is "default" which is used to store the DataSource defining (at construction) a reader.

See also
Reader
Note
The "default" keyword always contains at least one entry, which may be empty. I haven't for now found any use to several "default" entries.

Access to a source is done using dataSource(...) methods. Sources are ordered by increasing order of insertion and numbering starts at 0.

Definition at line 69 of file datasourcelist.h.

Constructor & Destructor Documentation

◆ DataSourceList() [1/3]

soma::DataSourceList::DataSourceList ( )

Default constructor : Builds a map containing only ( "default", empty pointer )

◆ DataSourceList() [2/3]

soma::DataSourceList::DataSourceList ( const carto::rc_ptr< DataSource > &  ds,
const std::string &  type = "default" 
)

Constructor : builds a 1-element map This allows to construct easily a 1 element list, useful when declaring a Reader which creator takes a source as parameter.

Parameters
dsElement to insert
typeCategory of the source default key is "default" : used at Reader construction

◆ DataSourceList() [3/3]

soma::DataSourceList::DataSourceList ( const DataSourceList )

Copy constructor.

◆ ~DataSourceList()

virtual soma::DataSourceList::~DataSourceList ( )
virtual

Member Function Documentation

◆ addDataSource()

void soma::DataSourceList::addDataSource ( const std::string &  ,
const carto::rc_ptr< DataSource > &   
)

Adds an element to the dictionary If new keyword, creates it.

◆ dataSource() [1/2]

const carto::rc_ptr<DataSource>& soma::DataSourceList::dataSource ( const std::string &  s = "default",
int  i = 0 
) const

Accessing an element of the list If keyword doesn't exist, or is empty, or coordinate is undefined, launches exception.

Numbering starts at 0

Referenced by soma::ImageReader< T >::read(), soma::DataSourceInfo::url(), soma::ImageWriter< T >::write(), and soma::ImageWriter< T >::writeHeader().

◆ dataSource() [2/2]

carto::rc_ptr<DataSource>& soma::DataSourceList::dataSource ( const std::string &  s = "default",
int  i = 0 
)

Accessing an element of the list If keyword doesn't exist, or is empty, or coordinate is undefined, launches exception.

Numbering starts at 0

◆ empty() [1/2]

bool soma::DataSourceList::empty ( ) const

Returns true only if no keyword inserted.

Warning
May return false while no DataSource present

Referenced by soma::Reader< T >::read().

◆ empty() [2/2]

bool soma::DataSourceList::empty ( const std::string &  ) const

◆ exists()

bool soma::DataSourceList::exists ( const std::string &  ) const

◆ operator!=()

bool soma::DataSourceList::operator!= ( const DataSourceList ) const

◆ operator=()

DataSourceList& soma::DataSourceList::operator= ( const DataSourceList )

◆ operator==()

bool soma::DataSourceList::operator== ( const DataSourceList ) const

◆ reset()

void soma::DataSourceList::reset ( )

sets the list and keywords empty.

◆ size()

int soma::DataSourceList::size ( const std::string &  ) const

◆ typecount()

int soma::DataSourceList::typecount ( ) const

◆ types()

std::set<std::string> soma::DataSourceList::types ( ) const

Returns existing keywords.

Warning
There may be existing keywords with no DataSource

Member Data Documentation

◆ _dslist

std::map<std::string,std::vector<carto::rc_ptr<DataSource> > > soma::DataSourceList::_dslist
protected

Definition at line 127 of file datasourcelist.h.


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