New cpp folder structure

Signed-off-by: Alexander Borsuk <me@alex.bio>
This commit is contained in:
Alexander Borsuk
2025-07-17 22:35:52 +03:00
committed by Konstantin Pastbin
parent c9cbb64f12
commit 76ffc99abd
2390 changed files with 345 additions and 339 deletions

52
libs/platform/trace.hpp Normal file
View File

@@ -0,0 +1,52 @@
#pragma once
#include "base/macros.hpp"
#include <cstdint>
#include <memory>
namespace platform
{
class TraceImpl;
// API is inspired by https://developer.android.com/ndk/reference/group/tracing
class Trace
{
public:
static Trace & Instance() noexcept;
void BeginSection(char const * name) noexcept;
void EndSection() noexcept;
void SetCounter(char const * name, int64_t value) noexcept;
private:
Trace();
~Trace();
std::unique_ptr<TraceImpl> m_impl;
DISALLOW_COPY_AND_MOVE(Trace);
};
class TraceSection
{
public:
inline TraceSection(char const * section) noexcept
{
Trace::Instance().BeginSection(section);
}
inline ~TraceSection() noexcept
{
Trace::Instance().EndSection();
}
};
} // namespace platform
#if defined(ENABLE_TRACE) && defined(OMIM_OS_ANDROID)
#define TRACE_SECTION(section) platform::TraceSection ___section(section)
#define TRACE_COUNTER(name, value) platform::Trace::Instance().SetCounter(name, value)
#else
#define TRACE_SECTION(section) static_cast<void>(0)
#define TRACE_COUNTER(name, value) static_cast<void>(0)
#endif