forked from LLNL/Caliper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ChannelController.h
90 lines (67 loc) · 2.57 KB
/
ChannelController.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// Copyright (c) 2019, Lawrence Livermore National Security, LLC.
// See top-level LICENSE file for details.
/// \file ChannelController.h
/// ChannelController class
#pragma once
#include "cali_definitions.h"
#include <map>
#include <memory>
#include <string>
namespace cali
{
class Caliper;
class Channel;
typedef std::map<std::string, std::string> config_map_t;
/// \class ChannelController
/// \ingroup ControlChannelAPI
/// \brief Base class for %Caliper channel controllers
///
/// A channel controller wraps a %Caliper configuration and channel.
/// The underlying channel is initially inactive, and will be created
/// in the first call of the start() method. Derived classes can
/// modify the configuration before the channel is created.
///
/// ChannelController objects can be copied and moved. The underlying
/// %Caliper channel will be deleted when the last ChannelController
/// object referencing is destroyed.
class ChannelController
{
struct ChannelControllerImpl;
std::shared_ptr<ChannelControllerImpl> mP;
protected:
/// \brief Return the underlying %Caliper channel object.
Channel* channel();
/// \brief Provide access to the underlying config map.
///
/// Note that configuration modifications are only effective before
/// the underlying %Caliper channel has been created.
config_map_t& config();
/// \brief Create the channel with the controller's
/// name, flags, and config map
Channel* create();
/// \brief Callback function, invoked after the underlying channel
/// has been created.
///
/// This can be used to setup additional functionality, e.g.
/// registering %Caliper callbacks.
virtual void on_create(Caliper* c, Channel* chn) { }
public:
/// \brief Create and activate the %Caliper channel,
/// or reactivate a stopped %Caliper channel.
void start();
/// \brief Deactivate the %Caliper channel.
void stop();
/// \brief Returns true if channel exists and is active, false otherwise.
bool is_active() const;
/// \brief Returns the name of the underlying channel
std::string name() const;
/// \brief Flush the underlying %Caliper channel.
///
/// Allows derived classes to implement custom %Caliper data processing.
/// The base class implementation invokes Caliper::flush_and_write().
virtual void flush();
/// \brief Create channel controller with given name, flags, and config.
ChannelController(const char* name, int flags, const config_map_t& cfg);
virtual ~ChannelController();
};
} // namespace cali;