ATLAS Offline Software
Loading...
Searching...
No Matches
StandaloneNavigation.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
5
6// System include(s):
7#include <iostream>
8
11
14
17
18bool HLT::StandaloneNavigation::serializeHolders( std::vector<uint32_t>& output ) const {
19 std::lock_guard<std::recursive_mutex> lock(getMutex());
20 const TrigHolderStructure& holderstorage = getHolderStorage();
21
22 for ( auto holder: holderstorage.getAllHolders()) {
23 // put size placeholder
24 const size_t holderSizeIndex = output.size();
25 output.push_back(0);
26
27 holder->serialize(output);
28
29 output[holderSizeIndex] = output.size() - holderSizeIndex -1;
30 }
31 return true;
32}
33
34
35bool HLT::StandaloneNavigation::deserializeHolders(std::vector<uint32_t>::const_iterator& start, const std::vector<uint32_t>::const_iterator& end) {
36 using namespace std;
37 std::lock_guard<std::recursive_mutex> lock(getMutex());
38 TrigHolderStructure& holderstorage = getHolderStorage();
39
40 do {
41 if ( start == end ) // no holders at all
42 break;
43
44 const size_t holderPayloadSize = *start;
45 ++start;
46
47 class_id_type clid{0};
48 std::string label;
49 sub_index_type sub{0};
50 std::vector<uint32_t>::const_iterator oneBlobIt = start;
51 bool couldRead = BaseHolder::enquireSerialized(oneBlobIt, end, clid, label, sub);
52
53 if ( couldRead == false ) // to few data words essentially
54 break;
55
56 //create holder
57 auto holder = std::make_shared<TypelessHolder>(clid, label, sub);
58
59 bool status = holderstorage.registerHolder(holder);
60 if(!status){
61 std::cerr << "ERROR registering a holder" << std::endl;
62 }
63
64 std::advance(start, holderPayloadSize);
65
66 } while(1);
67
68 return true;
69}
70
71bool HLT::StandaloneNavigation::serialize( std::vector<uint32_t>& output ) const {
72 const unsigned int version=3; //GetBack - shall we change it to 4
73 output.push_back(version);
74
76
77 if ( serializeTEs(output) == false ) {
78 return false;
79 }
80
81 if ( serializeHolders(output) == false ) {
82 return false;
83 }
84
85 return true;
86}
87
88bool HLT::StandaloneNavigation::deserialize( const std::vector<uint32_t>& input ) {
89 // using namespace std;
90 // std::cerr << "deserializing navigation of size: " << input.size() << std::endl;
91 std::vector<uint32_t>::const_iterator inputIt = input.begin();
92 const unsigned int version = *inputIt++;
93
94 // cerr << "version " << version << endl;
95
96 const size_t totalSize = *inputIt++;
97
98 //remove unused warning;
99 (void)(version);
100 (void)(totalSize);
101
102 if (!deserializeTEs(inputIt,input.size())) {
103 return false;
104 }
105
106 if (!deserializeHolders(inputIt,input.end())) {
107 return false;
108 }
109 return true;
110}
static Double_t fs
static unsigned int totalSize(const MultiDimArray< T, N > &ht)
static bool enquireSerialized(std::vector< uint32_t >::const_iterator &fromHere, const std::vector< uint32_t >::const_iterator &end, class_id_type &c, std::string &label, sub_index_type &subtypeIndex)
virtual bool serializeHolders(std::vector< uint32_t > &output) const
method serializes the helper objects allowing use of FeatureAccessHelpers w/o CLID This methods shoul...
virtual bool serialize(std::vector< uint32_t > &output) const
method serializes entire navigation
virtual bool deserialize(const std::vector< uint32_t > &input)
virtual bool deserializeHolders(std::vector< uint32_t >::const_iterator &start, const std::vector< uint32_t >::const_iterator &end)
std::vector< HolderType * > getAllHolders() const
bool registerHolder(const std::shared_ptr< BaseHolder > &holder)
bool serializeTEs(std::vector< uint32_t > &output) const
method serizlizes the navigation structure
bool deserializeTEs(std::vector< uint32_t >::const_iterator &start, unsigned int totalSize)
std::recursive_mutex & getMutex()
TrigHolderStructure & getHolderStorage()
std::string label(class_id_type clid, const index_or_label_type &sti_or_label) const
STL namespace.