Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Gaudi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gaudi
Gaudi
Commits
39af3af2
Commit
39af3af2
authored
3 years ago
by
Marco Clemencic
Browse files
Options
Downloads
Plain Diff
Allow entities with internal counters not implementing mergeAndRequest
See merge request
!1267
parents
27905625
3eed3348
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1267
Allow entities with internal counters not implementing mergeAndRequest
Pipeline
#3248182
passed
3 years ago
Stage: pre-build-checks
Stage: build
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
GaudiKernel/include/Gaudi/MonitoringHub.h
+31
-14
31 additions, 14 deletions
GaudiKernel/include/Gaudi/MonitoringHub.h
with
31 additions
and
14 deletions
GaudiKernel/include/Gaudi/MonitoringHub.h
+
31
−
14
View file @
39af3af2
...
...
@@ -17,6 +17,26 @@
#include
<typeinfo>
namespace
Gaudi
::
Monitoring
{
namespace
details
{
struct
MergeAndResetBase
{
virtual
void
operator
()(
void
*
,
void
*
)
const
=
0
;
virtual
~
MergeAndResetBase
()
{}
};
template
<
typename
T
,
typename
=
void
>
struct
MergeAndReset
:
MergeAndResetBase
{
void
operator
()(
void
*
,
void
*
)
const
override
{}
};
template
<
typename
T
>
struct
MergeAndReset
<
T
,
decltype
(
std
::
declval
<
T
>
().
mergeAndReset
(
nullptr
)
)
>
:
MergeAndResetBase
{
void
operator
()(
void
*
ptr
,
void
*
other
)
const
override
{
reinterpret_cast
<
T
*>
(
ptr
)
->
mergeAndReset
(
std
::
move
(
*
reinterpret_cast
<
T
*>
(
other
)
)
);
}
};
}
// namespace details
/// Central entity in a Gaudi application that manages monitoring objects (i.e. counters, histograms, etc.).
///
/// The Gaudi::Monitoring::Hub delegates the actual reports to services implementing the Gaudi::Monitoring::Hub::Sink
...
...
@@ -41,15 +61,13 @@ namespace Gaudi::Monitoring {
public:
template
<
typename
T
>
Entity
(
std
::
string
component
,
std
::
string
name
,
std
::
string
type
,
T
&
ent
)
:
component
{
std
::
move
(
component
)}
,
name
{
std
::
move
(
name
)}
,
type
{
std
::
move
(
type
)}
,
m_ptr
{
&
ent
}
,
m_reset
{[](
void
*
ptr
)
{
reinterpret_cast
<
T
*>
(
ptr
)
->
reset
();
}}
,
m_mergeAndReset
{[](
void
*
ptr
,
void
*
other
)
{
reinterpret_cast
<
T
*>
(
ptr
)
->
mergeAndReset
(
std
::
move
(
*
reinterpret_cast
<
T
*>
(
other
)
)
);
}}
,
m_getJSON
{[](
const
void
*
ptr
)
{
return
reinterpret_cast
<
const
T
*>
(
ptr
)
->
toJSON
();
}}
{}
:
component
{
std
::
move
(
component
)
}
,
name
{
std
::
move
(
name
)
}
,
type
{
std
::
move
(
type
)
}
,
m_ptr
{
&
ent
}
,
m_reset
{
[](
void
*
ptr
)
{
reinterpret_cast
<
T
*>
(
ptr
)
->
reset
();
}
}
,
m_mergeAndReset
{
std
::
make_shared
<
details
::
MergeAndReset
<
T
>>
()
}
,
m_getJSON
{
[](
const
void
*
ptr
)
{
return
reinterpret_cast
<
const
T
*>
(
ptr
)
->
toJSON
();
}
}
{}
/// name of the component owning the Entity
std
::
string
component
;
/// name of the entity
...
...
@@ -71,14 +89,14 @@ namespace Gaudi::Monitoring {
private
:
/// pointer to the actual data inside this Entity
void
*
m_ptr
{
nullptr
};
void
*
m_ptr
{
nullptr
};
// The next 3 members are needed for type erasure
// indeed, their implementation is internal type dependant
// (see Constructor above and the usage of T in the reinterpret_cast)
/// function reseting internal data.
void
(
*
m_reset
)(
void
*
);
/// function calling merge and reset on internal data with the internal data of another entity
void
(
*
m_mergeAndReset
)(
void
*
,
void
*
)
;
std
::
shared_ptr
<
details
::
MergeAndResetBase
>
m_mergeAndReset
;
/// function converting the internal data to json.
json
(
*
m_getJSON
)(
const
void
*
);
};
...
...
@@ -92,11 +110,10 @@ namespace Gaudi::Monitoring {
template
<
typename
T
>
void
registerEntity
(
std
::
string
c
,
std
::
string
n
,
std
::
string
t
,
T
&
ent
)
{
registerEntity
(
{
std
::
move
(
c
),
std
::
move
(
n
),
std
::
move
(
t
),
ent
}
);
registerEntity
(
{
std
::
move
(
c
),
std
::
move
(
n
),
std
::
move
(
t
),
ent
}
);
}
void
registerEntity
(
Entity
ent
)
{
std
::
for_each
(
begin
(
m_sinks
),
end
(
m_sinks
),
[
ent
](
auto
sink
)
{
sink
->
registerEntity
(
std
::
move
(
ent
)
);
}
);
std
::
for_each
(
begin
(
m_sinks
),
end
(
m_sinks
),
[
ent
](
auto
sink
)
{
sink
->
registerEntity
(
ent
);
}
);
m_entities
.
emplace_back
(
std
::
move
(
ent
)
);
}
template
<
typename
T
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment