9 #include "CoralBase/Blob.h"
10 #include "CoralBase/Attribute.h"
11 #include "CoralBase/AttributeList.h"
12 #include "CoralBase/AttributeListSpecification.h"
14 #include "CoolKernel/ChannelSelection.h"
15 #include "CoolKernel/IDatabase.h"
16 #include "CoolKernel/IFolder.h"
19 #include <unordered_map>
25 const std::unordered_map<std::type_index, std::function<
int(
const coral::Attribute &)>>
27 {std::type_index(
typeid(
bool)), [](
const coral::Attribute & )->
int {
return 1; } },
28 {std::type_index(
typeid(
unsigned char)), [](
const coral::Attribute & )->
int {
return 1; } },
29 {std::type_index(
typeid(
char)), [](
const coral::Attribute & )->
int {
return 1; } },
31 {std::type_index(
typeid(
short)), [](
const coral::Attribute & )->
int {
return 2; } },
32 {std::type_index(
typeid(
unsigned short)), [](
const coral::Attribute & )->
int {
return 2; } },
33 {std::type_index(
typeid(
char)), [](
const coral::Attribute & )->
int {
return 2; } },
35 {std::type_index(
typeid(
int)), [](
const coral::Attribute & )->
int {
return 4; } },
36 {std::type_index(
typeid(
unsigned int)), [](
const coral::Attribute & )->
int {
return 4; } },
37 {std::type_index(
typeid(
float)), [](
const coral::Attribute & )->
int {
return 4; } },
39 {std::type_index(
typeid(
long long)), [](
const coral::Attribute & )->
int {
return 8; } },
40 {std::type_index(
typeid(
unsigned long long)), [](
const coral::Attribute & )->
int {
return 8; } },
41 {std::type_index(
typeid(
double)), [](
const coral::Attribute & )->
int {
return 8; } },
43 {std::type_index(
typeid(std::string)), [](
const coral::Attribute & attr)->
int {
return attr.data<std::string>().
size(); } },
51 const coral::AttributeListSpecification &
53 return atrlist.specification();
58 const auto &
spec{attribute.specification()};
60 return sizeFunctions.at(std::type_index(
spec.type()))(attribute);
61 }
catch (
const std::out_of_range& oor) {
68 return (sizeFunctions.find(std::type_index(attribute.specification().type())) != sizeFunctions.end());
74 for (
const auto & attribute:atrlist){
82 auto isSelected = [& selected](cool::ChannelId
id){
return selected.inSelection(
id);};
90 time.setTimestamp(
key);
107 std::pair<unsigned long long, unsigned long long>
109 return std::pair<unsigned long long, unsigned long long>{iovTime>>32, iovTime&0xFFFFFFFF};
135 std::pair<bool, std::string>
138 std::string folderdesc{};
141 cool::IDatabasePtr dbPtr=pConnection->
getCoolDb();
142 if (not dbPtr.get()) {
143 throw std::runtime_error(
"Conditions database connection " + pConnection->
name() +
" cannot be opened - STOP" );
147 throw std::runtime_error(
"Folder " +
folderName +
" does not exist" );
149 cool::IFolderPtr fldPtr=dbPtr->getFolder(
folderName);
151 multiversion=(fldPtr->versioningMode()==cool::FolderVersioning::MULTI_VERSION);
153 folderdesc=fldPtr->description();
154 return std::make_pair(multiversion, std::move(folderdesc));
159 std::pair<std::vector<cool::ChannelId>, std::vector<std::string>>
161 std::vector<cool::ChannelId> channelNumbers;
162 std::vector<std::string> channelNames;
164 cool::IDatabasePtr dbPtr=pConnection->
getCoolDb();
167 throw std::runtime_error(
"Folder " +
folderName +
" does not exist" );
169 cool::IFolderPtr fldPtr=dbPtr->getFolder(
folderName);
171 typedef std::map<cool::ChannelId,std::string> ChanMap_t;
172 const ChanMap_t & chanmap=fldPtr->listChannelsWithNames();
173 channelNumbers.reserve(chanmap.size());
174 channelNames.reserve(chanmap.size());
175 auto unzipElement = [&](
const ChanMap_t::value_type & element){
176 channelNumbers.push_back(element.first);
177 channelNames.push_back(element.second);
179 std::for_each(chanmap.begin(), chanmap.end(),unzipElement);
181 channelNumbers=fldPtr->listChannels();
183 return std::make_pair(std::move(channelNumbers), std::move(channelNames));