a Code for the Combination of Indirect and Direct Constraints on High Energy Physics Models Logo
SparseManyIndexedBlock.hpp
Go to the documentation of this file.
1/*
2 * SparseManyIndexedBlock.hpp
3 *
4 * Created on: Aug 28, 2012
5 * Author: Ben O'Leary (benjamin.oleary@gmail.com)
6 * Copyright 2012 Ben O'Leary
7 *
8 * This file is part of LesHouchesParserClasses, released under the
9 * GNU General Public License. Please see the accompanying
10 * README.LHPC_CPP.txt file for a full list of files, brief documentation
11 * on how to use these classes, and further details on the license.
12 */
13
14#ifndef SPARSEMANYINDEXEDBLOCK_HPP_
15#define SPARSEMANYINDEXEDBLOCK_HPP_
16
17
20
21namespace LHPC
22{
23 namespace SLHA
24 {
25 /* this template class interprets all the blocks with the same name, though
26 * differing scale values, which are interpreted as having a set of int
27 * indices which does not have to have entries for each value (nor even
28 * necessarily positive index values).
29 */
30 template< class ValueClass >
31 class SparseManyIndexedBlock : public IndexedBlockTemplate< ValueClass,
32 InterpreterClass::SparseManyIndexed< ValueClass > >
33 {
34 public:
35 SparseManyIndexedBlock( std::string const& blockName,
36 int const numberOfIndices,
37 ValueClass const& defaultUnsetValue,
38 bool const isVerbose = false,
39 int const indexDigits = 9 );
40 virtual
42
43 ValueClass&
44 operator()( std::vector< int > const& indexVector );
45 // this returns operator() of the lowest-scale interpreter.
46 ValueClass const&
47 operator()( std::vector< int > const& indexVector ) const;
48 // const version of above.
49 ValueClass&
50 operator()( std::string const& indicesAsString );
51 // this returns operator() of the lowest-scale interpreter.
52 ValueClass const&
53 operator()( std::string const& indicesAsString ) const;
54 // const version of above.
55 bool
56 hasEntry( std::vector< int > const& indexVector ) const;
57 // this returns hasEntry( indexVector ) of the lowest-scale interpreter.
58 bool
59 hasEntry( std::string const& indicesAsString ) const;
60 // this returns hasEntry( indicesAsString ) of the lowest-scale
61 // interpreter.
62 };
63
64
65
66
67
68 template< class ValueClass >
69 inline
71 std::string const& blockName,
72 int const numberOfIndices,
73 ValueClass const& defaultUnsetValue,
74 bool const isVerbose,
75 int const indexDigits ) :
76 IndexedBlockTemplate< ValueClass,
77 InterpreterClass::SparseManyIndexed< ValueClass > >(
78 blockName,
79 defaultUnsetValue,
80 isVerbose,
81 std::vector< int >( numberOfIndices,
82 indexDigits ) )
83 {
84 // just an initialization list.
85 }
86
87 template< class ValueClass >
88 inline
90 {
91 // does nothing.
92 }
93
94
95 template< class ValueClass >
96 inline ValueClass&
98 std::vector< int > const& indexVector )
99 // this returns operator() of the lowest-scale interpreter.
100 {
101 return this->dataBlocks[ this->lowestScaleIndex ]( indexVector );
102 }
103
104 template< class ValueClass >
105 inline ValueClass const&
107 std::vector< int > const& indexVector ) const
108 // const version of above.
109 {
110 return this->dataBlocks[ this->lowestScaleIndex ]( indexVector );
111 }
112
113 template< class ValueClass >
114 inline ValueClass&
116 std::string const& indicesAsString )
117 // this returns operator() of the lowest-scale interpreter.
118 {
119 return this->dataBlocks[ this->lowestScaleIndex ]( indicesAsString );
120 }
121
122 template< class ValueClass >
123 inline ValueClass const&
125 std::string const& indicesAsString ) const
126 // const version of above.
127 {
128 return this->dataBlocks[ this->lowestScaleIndex ]( indicesAsString );
129 }
130
131 template< class ValueClass >
132 inline bool
134 std::vector< int > const& indexVector ) const
135 // derived classes over-ride this to interpret their data as a
136 // std::string.
137 {
138 return
139 this->dataBlocks[ this->lowestScaleIndex ].hasEntry( indexVector );
140 }
141
142 template< class ValueClass >
143 inline bool
145 std::string const& indicesAsString ) const
146 // derived classes over-ride this to interpret their data as a
147 // std::string.
148 {
149 return
150 this->dataBlocks[ this->lowestScaleIndex ].hasEntry( indicesAsString );
151 }
152
153 } // end of SLHA namespace
154
155} // end of LHPC namespace
156
157
158
159#endif /* SPARSEMANYINDEXEDBLOCK_HPP_ */
ValueClass const defaultUnsetValue
Definition: SlhaBlock.hpp:139
SparseManyIndexedBlock(std::string const &blockName, int const numberOfIndices, ValueClass const &defaultUnsetValue, bool const isVerbose=false, int const indexDigits=9)
bool hasEntry(std::vector< int > const &indexVector) const
ValueClass & operator()(std::vector< int > const &indexVector)