Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
Kea
Commits
ef7934c8
Commit
ef7934c8
authored
May 08, 2015
by
Tomek Mrugalski
🛰
Browse files
[3793] Several consts added.
parent
2a599377
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/lib/stats/context.cc
View file @
ef7934c8
...
...
@@ -18,8 +18,8 @@
namespace
isc
{
namespace
stats
{
ObservationPtr
StatContext
::
get
(
const
std
::
string
&
name
)
{
std
::
map
<
std
::
string
,
ObservationPtr
>::
iterator
obs
=
stats_
.
find
(
name
);
ObservationPtr
StatContext
::
get
(
const
std
::
string
&
name
)
const
{
std
::
map
<
std
::
string
,
ObservationPtr
>::
const_
iterator
obs
=
stats_
.
find
(
name
);
if
(
obs
==
stats_
.
end
())
{
return
(
ObservationPtr
());
}
else
{
...
...
@@ -28,8 +28,8 @@ ObservationPtr StatContext::get(const std::string& name) {
}
void
StatContext
::
add
(
const
ObservationPtr
&
obs
)
{
std
::
map
<
std
::
string
,
ObservationPtr
>::
iterator
obs
=
stats_
.
find
(
n
ame
);
if
(
obs
==
stats_
.
end
())
{
std
::
map
<
std
::
string
,
ObservationPtr
>::
iterator
existing
=
stats_
.
find
(
obs
->
getN
ame
()
);
if
(
existing
==
stats_
.
end
())
{
stats_
.
insert
(
make_pair
(
obs
->
getName
()
,
obs
));
}
else
{
isc_throw
(
InvalidStatType
,
"Statistic named "
<<
obs
->
getName
()
...
...
src/lib/stats/context.h
View file @
ef7934c8
...
...
@@ -41,7 +41,7 @@ class StatContext {
/// @brief attempts to get an observation
/// @param name name of the statistic
/// @return appropriate Observation object (or NULL)
ObservationPtr
get
(
const
std
::
string
&
name
);
ObservationPtr
get
(
const
std
::
string
&
name
)
const
;
/// @brief Adds a new observation
/// @param obs observation to be added
...
...
src/lib/stats/observation.cc
View file @
ef7934c8
...
...
@@ -84,24 +84,24 @@ void Observation::setValueInternal(SampleType value, StorageType& storage,
}
}
IntegerSample
Observation
::
getInteger
()
{
IntegerSample
Observation
::
getInteger
()
const
{
return
(
getValueInternal
<
IntegerSample
>
(
integer_samples_
,
STAT_INTEGER
));
}
FloatSample
Observation
::
getFloat
()
{
FloatSample
Observation
::
getFloat
()
const
{
return
(
getValueInternal
<
FloatSample
>
(
float_samples_
,
STAT_FLOAT
));
}
DurationSample
Observation
::
getDuration
()
{
DurationSample
Observation
::
getDuration
()
const
{
return
(
getValueInternal
<
DurationSample
>
(
duration_samples_
,
STAT_DURATION
));
}
StringSample
Observation
::
getString
()
{
StringSample
Observation
::
getString
()
const
{
return
(
getValueInternal
<
StringSample
>
(
string_samples_
,
STAT_STRING
));
}
template
<
typename
SampleType
,
typename
Storage
>
SampleType
Observation
::
getValueInternal
(
Storage
&
storage
,
Type
exp_type
)
{
SampleType
Observation
::
getValueInternal
(
Storage
&
storage
,
Type
exp_type
)
const
{
if
(
type_
!=
exp_type
)
{
isc_throw
(
InvalidStatType
,
"Invalid statistic type requested: "
<<
typeToText
(
exp_type
)
<<
", but the actual type is "
...
...
@@ -155,7 +155,7 @@ Observation::durationToText(StatsDuration dur) {
}
isc
::
data
::
ConstElementPtr
Observation
::
getJSON
()
{
Observation
::
getJSON
()
const
{
ElementPtr
entry
=
isc
::
data
::
Element
::
createList
();
// a single observation
ElementPtr
value
;
...
...
src/lib/stats/observation.h
View file @
ef7934c8
...
...
@@ -183,26 +183,26 @@ class Observation {
/// @brief Returns observed integer sample
/// @return observed sample (value + timestamp)
/// @throw InvalidStatType if statistic is not integer
IntegerSample
getInteger
();
IntegerSample
getInteger
()
const
;
/// @brief Returns observed float sample
/// @return observed sample (value + timestamp)
/// @throw InvalidStatType if statistic is not fp
FloatSample
getFloat
();
FloatSample
getFloat
()
const
;
/// @brief Returns observed duration sample
/// @return observed sample (value + timestamp)
/// @throw InvalidStatType if statistic is not time duration
DurationSample
getDuration
();
DurationSample
getDuration
()
const
;
/// @brief Returns observed string sample
/// @return observed sample (value + timestamp)
/// @throw InvalidStatType if statistic is not a string
StringSample
getString
();
StringSample
getString
()
const
;
/// @brief Returns as a JSON structure
/// @return JSON structures representing all observations
isc
::
data
::
ConstElementPtr
getJSON
();
isc
::
data
::
ConstElementPtr
getJSON
()
const
;
/// @brief Converts statistic type to string
/// @return textual name of statistic type
...
...
@@ -217,7 +217,7 @@ class Observation {
static
std
::
string
durationToText
(
StatsDuration
dur
);
/// @brief Returns observation name
std
::
string
getName
()
{
std
::
string
getName
()
const
{
return
(
name_
);
}
...
...
@@ -247,7 +247,7 @@ class Observation {
/// @throw InvalidStatType if observation type mismatches
/// @return Observed sample
template
<
typename
SampleType
,
typename
Storage
>
SampleType
getValueInternal
(
Storage
&
storage
,
Type
exp_type
);
SampleType
getValueInternal
(
Storage
&
storage
,
Type
exp_type
)
const
;
/// @brief Observation (statistic) name
std
::
string
name_
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment