Skip to content

Commit 30f9663

Browse files
committed
Updated to new storage system namespace
1 parent 99218bb commit 30f9663

File tree

17 files changed

+94
-73
lines changed

17 files changed

+94
-73
lines changed

GeneratorInterface/LHEInterface/src/LHEReader.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ namespace lhef {
4747
class LHEReader::FileSource : public LHEReader::Source {
4848
public:
4949
FileSource(const std::string &fileURL) {
50+
using namespace edm::storage;
5051
auto storage = StorageFactory::get()->open(fileURL, IOFlags::OpenRead);
5152

5253
if (!storage)

GeneratorInterface/LHEInterface/src/XMLUtils.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
XERCES_CPP_NAMESPACE_USE
2222

23+
using namespace edm::storage;
2324
namespace lhef {
2425

2526
StorageWrap::StorageWrap(std::unique_ptr<Storage> storage) : storage(std::move(storage)) {}

GeneratorInterface/LHEInterface/src/XMLUtils.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,16 @@
1616
#include <xercesc/sax2/SAX2XMLReader.hpp>
1717
#include <lzma.h>
1818

19-
class Storage;
19+
namespace edm::storage {
20+
class Storage;
21+
}
2022

2123
namespace lhef {
2224

2325
class StorageWrap {
2426
public:
27+
using Storage = edm::storage::Storage;
28+
2529
StorageWrap(std::unique_ptr<Storage> storage);
2630
~StorageWrap();
2731

IORawData/SiPixelInputSources/interface/PixelSLinkDataInputSource.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class PixelSLinkDataInputSource : public edm::ProducerSourceFromFiles {
4949

5050
int m_fedid;
5151
uint32_t m_fileindex;
52-
std::unique_ptr<Storage> storage;
52+
std::unique_ptr<edm::storage::Storage> storage;
5353
int m_runnumber;
5454
uint64_t m_data;
5555
uint32_t m_currenteventnumber;

IORawData/SiPixelInputSources/src/PixelSLinkDataInputSource.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ PixelSLinkDataInputSource::PixelSLinkDataInputSource(const edm::ParameterSet &ps
209209
edm::LogInfo("") << "now examining file " << currentfilename;
210210
m_fileindex++;
211211
// reading both castor and other ('normal'/dcap) files.
212+
using namespace edm::storage;
212213
IOOffset size = -1;
213214
StorageFactory::getToModify()->enableAccounting(true);
214215

@@ -253,7 +254,7 @@ PixelSLinkDataInputSource::~PixelSLinkDataInputSource() {}
253254
bool PixelSLinkDataInputSource::setRunAndEventInfo(edm::EventID &id,
254255
edm::TimeValue_t &time,
255256
edm::EventAuxiliary::ExperimentType &) {
256-
Storage &m_file = *storage;
257+
edm::storage::Storage &m_file = *storage;
257258

258259
// create product (raw data)
259260
buffers = std::make_unique<FEDRawDataCollection>();

Utilities/DavixAdaptor/interface/DavixFile.h

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,41 @@
55
#include "Utilities/StorageFactory/interface/Storage.h"
66
#include <davix.hpp>
77

8-
class DavixFile : public Storage {
9-
public:
10-
DavixFile(void);
11-
DavixFile(const char *name, int flags = IOFlags::OpenRead, int perms = 0666);
12-
DavixFile(const std::string &name, int flags = IOFlags::OpenRead, int perms = 0666);
13-
~DavixFile(void) override;
14-
static void configureDavixLogLevel();
15-
16-
virtual void create(const char *name, bool exclusive = false, int perms = 0666);
17-
virtual void create(const std::string &name, bool exclusive = false, int perms = 0666);
18-
virtual void open(const char *name, int flags = IOFlags::OpenRead, int perms = 0666);
19-
virtual void open(const std::string &name, int flags = IOFlags::OpenRead, int perms = 0666);
20-
21-
using Storage::position;
22-
using Storage::read;
23-
using Storage::write;
24-
25-
IOSize read(void *into, IOSize n) override;
26-
IOSize readv(IOBuffer *into, IOSize buffers) override;
27-
IOSize readv(IOPosBuffer *into, IOSize buffers) override;
28-
IOSize write(const void *from, IOSize n) override;
29-
IOOffset position(IOOffset offset, Relative whence = SET) override;
30-
void resize(IOOffset size) override;
31-
32-
void close(void) override;
33-
virtual void abort(void);
34-
35-
private:
36-
// Cannot use as C++ smart pointer for Davix_fd
37-
// Because Davix_fd is not available in C++ header files and
38-
// sizeof cannot with incomplete types
39-
Davix_fd *m_fd;
40-
std::unique_ptr<Davix::DavPosix> m_davixPosix;
41-
std::string m_name;
42-
};
43-
8+
namespace edm::storage {
9+
class DavixFile : public Storage {
10+
public:
11+
DavixFile(void);
12+
DavixFile(const char *name, int flags = IOFlags::OpenRead, int perms = 0666);
13+
DavixFile(const std::string &name, int flags = IOFlags::OpenRead, int perms = 0666);
14+
~DavixFile(void) override;
15+
static void configureDavixLogLevel();
16+
17+
virtual void create(const char *name, bool exclusive = false, int perms = 0666);
18+
virtual void create(const std::string &name, bool exclusive = false, int perms = 0666);
19+
virtual void open(const char *name, int flags = IOFlags::OpenRead, int perms = 0666);
20+
virtual void open(const std::string &name, int flags = IOFlags::OpenRead, int perms = 0666);
21+
22+
using Storage::position;
23+
using Storage::read;
24+
using Storage::write;
25+
26+
IOSize read(void *into, IOSize n) override;
27+
IOSize readv(IOBuffer *into, IOSize buffers) override;
28+
IOSize readv(IOPosBuffer *into, IOSize buffers) override;
29+
IOSize write(const void *from, IOSize n) override;
30+
IOOffset position(IOOffset offset, Relative whence = SET) override;
31+
void resize(IOOffset size) override;
32+
33+
void close(void) override;
34+
virtual void abort(void);
35+
36+
private:
37+
// Cannot use as C++ smart pointer for Davix_fd
38+
// Because Davix_fd is not available in C++ header files and
39+
// sizeof cannot with incomplete types
40+
Davix_fd *m_fd;
41+
std::unique_ptr<Davix::DavPosix> m_davixPosix;
42+
std::string m_name;
43+
};
44+
} // namespace edm::storage
4445
#endif // DAVIX_ADAPTOR_DAVIX_FILE_H

Utilities/DavixAdaptor/plugins/DavixStorageMaker.cc

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,44 +6,47 @@
66
#include <davix.hpp>
77
#include <unistd.h>
88

9-
class DavixStorageMaker : public StorageMaker {
10-
public:
11-
/** Open a storage object for the given URL (protocol + path), using the
9+
namespace edm::storage {
10+
class DavixStorageMaker : public StorageMaker {
11+
public:
12+
/** Open a storage object for the given URL (protocol + path), using the
1213
@a mode bits. No temporary files are downloaded. */
13-
std::unique_ptr<Storage> open(const std::string &proto,
14-
const std::string &path,
15-
int mode,
16-
AuxSettings const &aux) const override {
17-
const StorageFactory *f = StorageFactory::get();
18-
std::string newurl((proto == "web" ? "http" : proto) + ":" + path);
19-
auto file = std::make_unique<DavixFile>(newurl, mode);
20-
return f->wrapNonLocalFile(std::move(file), proto, std::string(), mode);
21-
}
22-
23-
bool check(const std::string &proto,
24-
const std::string &path,
25-
const AuxSettings &aux,
26-
IOOffset *size = nullptr) const override {
27-
std::string newurl((proto == "web" ? "http" : proto) + ":" + path);
28-
Davix::DavixError *err = nullptr;
29-
Davix::Context c;
30-
Davix::DavPosix davixPosix(&c);
31-
Davix::StatInfo info;
32-
davixPosix.stat64(nullptr, newurl, &info, &err);
33-
if (err) {
34-
std::unique_ptr<Davix::DavixError> davixErrManaged(err);
35-
cms::Exception ex("FileCheckError");
36-
ex << "Check failed with error " << err->getErrMsg().c_str() << " and error code" << err->getStatus();
37-
ex.addContext("Calling DavixFile::check()");
38-
throw ex;
14+
std::unique_ptr<Storage> open(const std::string &proto,
15+
const std::string &path,
16+
int mode,
17+
AuxSettings const &aux) const override {
18+
const StorageFactory *f = StorageFactory::get();
19+
std::string newurl((proto == "web" ? "http" : proto) + ":" + path);
20+
auto file = std::make_unique<DavixFile>(newurl, mode);
21+
return f->wrapNonLocalFile(std::move(file), proto, std::string(), mode);
3922
}
40-
if (size) {
41-
*size = info.size;
23+
24+
bool check(const std::string &proto,
25+
const std::string &path,
26+
const AuxSettings &aux,
27+
IOOffset *size = nullptr) const override {
28+
std::string newurl((proto == "web" ? "http" : proto) + ":" + path);
29+
Davix::DavixError *err = nullptr;
30+
Davix::Context c;
31+
Davix::DavPosix davixPosix(&c);
32+
Davix::StatInfo info;
33+
davixPosix.stat64(nullptr, newurl, &info, &err);
34+
if (err) {
35+
std::unique_ptr<Davix::DavixError> davixErrManaged(err);
36+
cms::Exception ex("FileCheckError");
37+
ex << "Check failed with error " << err->getErrMsg().c_str() << " and error code" << err->getStatus();
38+
ex.addContext("Calling DavixFile::check()");
39+
throw ex;
40+
}
41+
if (size) {
42+
*size = info.size;
43+
}
44+
return true;
4245
}
43-
return true;
44-
}
45-
};
46+
};
47+
} // namespace edm::storage
4648

49+
using namespace edm::storage;
4750
DEFINE_EDM_PLUGIN(StorageMakerFactory, DavixStorageMaker, "http");
4851
DEFINE_EDM_PLUGIN(StorageMakerFactory, DavixStorageMaker, "https");
4952
DEFINE_EDM_PLUGIN(StorageMakerFactory, DavixStorageMaker, "web");

Utilities/DavixAdaptor/src/DavixFile.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
static std::once_flag davixDebugInit;
1515

1616
using namespace Davix;
17+
using namespace edm::storage;
1718

1819
DavixFile::DavixFile(void) {}
1920

Utilities/DavixAdaptor/test/davixcheck.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
int main(int, char ** /*argv*/) try {
55
initTest();
66

7+
using namespace edm::storage;
78
IOOffset size = -1;
89
bool exists = StorageFactory::get()->check(
910
"http://opendata.cern.ch/eos/opendata"

Utilities/DavixAdaptor/test/davixread.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
int main(int, char ** /*argv*/) try {
77
initTest();
88

9+
using namespace edm::storage;
910
IOSize n;
1011
IOSize size = 1024;
1112
char buf[size];

0 commit comments

Comments
 (0)