Skip to content
Snippets Groups Projects
Commit 468801fc authored by Olivier Langella's avatar Olivier Langella
Browse files

map identifications data sources

parent e3fbd52a
No related branches found
No related tags found
No related merge requests found
...@@ -21,11 +21,21 @@ ...@@ -21,11 +21,21 @@
* Olivier Langella <Olivier.Langella@moulon.inra.fr> - initial API and implementation * Olivier Langella <Olivier.Langella@moulon.inra.fr> - initial API and implementation
******************************************************************************/ ******************************************************************************/
#include "identificationdatasource.h" #include "identificationdatasource.h"
#include "identificationxtandemfile.h"
#include <pappsomspp/pappsoexception.h>
#include <QFileInfo> #include <QFileInfo>
IdentificationDataSource::IdentificationDataSource(pappso::MsRunIdSp & ms_run_sp)
IdentificationDataSource::MapIdentificationDataSources IdentificationDataSource::_map_identification_data_sources = []
{ {
_ms_run_sp = ms_run_sp; MapIdentificationDataSources ret;
return ret;
}();
IdentificationDataSource::IdentificationDataSource(const QString resource_name)
{
_resource_name = resource_name;
} }
IdentificationDataSource::IdentificationDataSource(const IdentificationDataSource& other) IdentificationDataSource::IdentificationDataSource(const IdentificationDataSource& other)
...@@ -46,20 +56,23 @@ bool IdentificationDataSource::operator==(const IdentificationDataSource& other) ...@@ -46,20 +56,23 @@ bool IdentificationDataSource::operator==(const IdentificationDataSource& other)
IdentificationDataSource * IdentificationDataSource::getInstance(const QString & location) { IdentificationDataSource * IdentificationDataSource::getInstance(const QString & location) {
std::map< QString, IdentificationDataSource* >::iterator it = _map_identification_data_sources.find(location); std::map< QString, IdentificationDataSource* >::iterator it = IdentificationDataSource::_map_identification_data_sources.find(location);
if (it != _map_identification_data_sources.end()) { if (it != IdentificationDataSource::_map_identification_data_sources.end()) {
return it->second; return it->second;
} }
else { else {
QFileInfo location_file(location); QFileInfo location_file(location);
QString ext = location_file.suffix(); QString ext = location_file.suffix();
QString sample_name = location_file.baseName(); //QString sample_name = location_file.baseName();
if (ext.toLower() == "xml") { if (ext.toLower() == "xml") {
//X!Tandem result file //X!Tandem result file
MsRunIdSp msrunid_sp = IdentificationXtandemFile * p_xtfile = new IdentificationXtandemFile(location_file);
_map_identification_data_sources.insert(std::pair< QString, IdentificationDataSource* >(location, p_xtfile));
_map_identification_data_sources.insert(std::pair< QString, IdentificationDataSource* >(location_file.absoluteFilePath(), p_xtfile));
return p_xtfile;
} }
} }
throw pappso::PappsoException(QObject::tr("Identification resource %1 not recognized").arg(location));
} }
const QString & IdentificationDataSource::getResourceName () const { const QString & IdentificationDataSource::getResourceName () const {
...@@ -67,6 +80,9 @@ const QString & IdentificationDataSource::getResourceName () const { ...@@ -67,6 +80,9 @@ const QString & IdentificationDataSource::getResourceName () const {
} }
void IdentificationDataSource::setMsRunSp (pappso::MsRunIdSp ms_run_sp) {
_ms_run_sp = ms_run_sp;
}
pappso::MsRunIdSp IdentificationDataSource::getMsRunSp () const { pappso::MsRunIdSp IdentificationDataSource::getMsRunSp () const {
return (_ms_run_sp); return (_ms_run_sp);
} }
...@@ -31,21 +31,24 @@ ...@@ -31,21 +31,24 @@
class IdentificationDataSource class IdentificationDataSource
{ {
public: public:
using MapIdentificationDataSources = std::map<QString, IdentificationDataSource *>;
static IdentificationDataSource * getInstance(const QString & location); static IdentificationDataSource * getInstance(const QString & location);
IdentificationDataSource(pappso::MsRunIdSp & ms_run_sp); IdentificationDataSource(const QString resource_name);
IdentificationDataSource(const IdentificationDataSource& other); IdentificationDataSource(const IdentificationDataSource& other);
~IdentificationDataSource(); ~IdentificationDataSource();
bool operator==(const IdentificationDataSource& other) const; bool operator==(const IdentificationDataSource& other) const;
const QString & getResourceName () const; const QString & getResourceName () const;
void setMsRunSp (pappso::MsRunIdSp ms_run_sp);
pappso::MsRunIdSp getMsRunSp () const; pappso::MsRunIdSp getMsRunSp () const;
protected : protected :
QString _resource_name; QString _resource_name;
private : private :
static std::map<QString, IdentificationDataSource *> _map_identification_data_sources; static MapIdentificationDataSources _map_identification_data_sources;
static std::map<QString, pappso::MsRunIdSp> _map_msrunidsp; //static std::map<QString, pappso::MsRunIdSp> _map_msrunidsp;
pappso::MsRunIdSp _ms_run_sp = nullptr; pappso::MsRunIdSp _ms_run_sp = nullptr;
}; };
......
...@@ -22,13 +22,12 @@ ...@@ -22,13 +22,12 @@
******************************************************************************/ ******************************************************************************/
#include "identificationxtandemfile.h" #include "identificationxtandemfile.h"
IdentificationXtandemFile::IdentificationXtandemFile(pappso::MsRunIdSp & ms_run_sp, const QFileInfo & xtandem_file) : IdentificationDataSource(ms_run_sp), _xtandem_file(xtandem_file) IdentificationXtandemFile::IdentificationXtandemFile(const QFileInfo & xtandem_file) : IdentificationDataSource(xtandem_file.absoluteFilePath()), _xtandem_file(xtandem_file)
{ {
_resource_name = _xtandem_file.absoluteFilePath();
} }
IdentificationXtandemFile::IdentificationXtandemFile(const IdentificationXtandemFile& other) : IdentificationDataSource(other),_xtandem_file (other._xtandem_file) IdentificationXtandemFile::IdentificationXtandemFile(const IdentificationXtandemFile& other) : IdentificationDataSource(other),_xtandem_file (other._xtandem_file)
{ {
} }
IdentificationXtandemFile::~IdentificationXtandemFile() IdentificationXtandemFile::~IdentificationXtandemFile()
......
...@@ -29,13 +29,13 @@ ...@@ -29,13 +29,13 @@
class IdentificationXtandemFile: public IdentificationDataSource class IdentificationXtandemFile: public IdentificationDataSource
{ {
public: public:
IdentificationXtandemFile(pappso::MsRunIdSp & ms_run_sp, const QFileInfo & xtandem_file); IdentificationXtandemFile(const QFileInfo & xtandem_file);
IdentificationXtandemFile(const IdentificationXtandemFile& other); IdentificationXtandemFile(const IdentificationXtandemFile& other);
~IdentificationXtandemFile(); ~IdentificationXtandemFile();
bool operator==(const IdentificationXtandemFile& other) const; bool operator==(const IdentificationXtandemFile& other) const;
private: private:
const QFileInfo _xtandem_file; const QFileInfo _xtandem_file;
}; };
#endif // IDENTIFICATIONXTANDEMFILE_H #endif // IDENTIFICATIONXTANDEMFILE_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment