IPPL API Reference
Independent Parallel Particle Layer C++ API
Loading...
Searching...
No Matches
LoggingBufferHandler.h
1#ifndef IPPL_LOGGING_BUFFER_HANDLER_H
2#define IPPL_LOGGING_BUFFER_HANDLER_H
3
4#include <chrono>
5#include <map>
6#include <memory>
7#include <string>
8#include <vector>
9
10#include "Communicate/BufferHandler.h"
11#include "Communicate/LogEntry.h"
12
13namespace ippl {
14
30 template <typename MemorySpace>
31 class LoggingBufferHandler : public BufferHandler<MemorySpace> {
32 public:
33 using buffer_type = typename BufferHandler<MemorySpace>::buffer_type;
34 using size_type = typename BufferHandler<MemorySpace>::size_type;
35
42 LoggingBufferHandler(std::shared_ptr<BufferHandler<MemorySpace>> handler, int rank);
43
49
60 buffer_type getBuffer(size_type size, double overallocation) override;
61
70 void freeBuffer(buffer_type buffer) override;
71
78 void freeAllBuffers() override;
79
86 void deleteAllBuffers() override;
87
92 size_type getUsedSize() const override;
93
98 size_type getFreeSize() const override;
99
104 const std::vector<LogEntry>& getLogs() const;
105
106 private:
107 std::shared_ptr<BufferHandler<MemorySpace>>
108 handler_m;
109 std::vector<LogEntry> logEntries_m;
110 int rank_m;
111
122 void logMethod(const std::string& methodName,
123 const std::map<std::string, std::string>& parameters);
124 };
125} // namespace ippl
126
127#include "Communicate/LoggingBufferHandler.hpp"
128
129#endif
Interface for memory buffer handling.
Definition BufferHandler.h:21
Decorator class for buffer management that adds logging capabilities to buffer operations.
Definition LoggingBufferHandler.h:31
LoggingBufferHandler()
Default constructor, creates an internal BufferHandler for managing buffers. This constructor also in...
Definition LoggingBufferHandler.hpp:16
buffer_type getBuffer(size_type size, double overallocation) override
Allocates or retrieves a buffer and logs the action.
Definition LoggingBufferHandler.hpp:23
void freeAllBuffers() override
Frees all buffers and logs the action.
Definition LoggingBufferHandler.hpp:37
size_type getUsedSize() const override
Retrieves the total size of allocated buffers.
Definition LoggingBufferHandler.hpp:50
const std::vector< LogEntry > & getLogs() const
Retrieves the list of log entries.
Definition LoggingBufferHandler.hpp:61
size_type getFreeSize() const override
Retrieves the total size of free buffers.
Definition LoggingBufferHandler.hpp:56
void deleteAllBuffers() override
Deletes all buffers and logs the action.
Definition LoggingBufferHandler.hpp:43
void freeBuffer(buffer_type buffer) override
Frees a buffer and logs the action.
Definition LoggingBufferHandler.hpp:31
Definition Archive.h:20