Program Listing for File context.hpp

Return to documentation for file (include/caret_trace/context.hpp)

// Copyright 2021 Research Institute of Systems Planning, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef CARET_TRACE__CONTEXT_HPP_

#include "caret_trace/clock.hpp"
#include "caret_trace/data_container.hpp"
#include "caret_trace/trace_node.hpp"
#include "caret_trace/tracing_controller.hpp"

#include <atomic>
#include <memory>

class Context final
{
public:
  Context();

  Context(
    std::shared_ptr<DataContainer> data_container, std::shared_ptr<TracingController> controller);

  Context(const Context &) = delete;

  TracingController & get_controller();

  std::shared_ptr<DataContainer> get_data_container_ptr();

  std::shared_ptr<LttngSession> get_lttng_session_ptr();

  DataContainer & get_data_container();

  TraceNodeInterface & get_node();

  Clock & get_clock();

  void assign_node(std::shared_ptr<TraceNodeInterface> node);

  bool is_node_assigned() const;

  bool is_recording_allowed() const;

  std::atomic<bool> is_node_initializing;

private:
  std::shared_ptr<DataContainer> data_container_;
  std::shared_ptr<TracingController> controller_;
  std::shared_ptr<TraceNodeInterface> node_;
  std::shared_ptr<LttngSession> lttng_;
  std::shared_ptr<Clock> clock_;
};

#endif  // CARET_TRACE__CONTEXT_HPP_
#define CARET_TRACE__CONTEXT_HPP_