From 54fb923675140ecfa994c35cc3838eb95a6d739d Mon Sep 17 00:00:00 2001 From: cobrapitz <12397702+cobrapitz@users.noreply.github.com> Date: Sun, 26 Mar 2023 12:02:58 +0200 Subject: [PATCH] initial commit --- .gitignore | 122 +++++++++++++++++++++++++++++++++++++++ .idea/.gitignore | 8 +++ .idea/cblib.iml | 2 + .idea/misc.xml | 7 +++ .idea/modules.xml | 8 +++ .idea/vcs.xml | 6 ++ CMakeLists.txt | 39 +++++++++++++ include/cb.h | 10 ++++ include/cb/base.h | 8 +++ include/cb/test/test.h | 19 ++++++ include/cb/time/time.h | 21 +++++++ include/cb/types/types.h | 19 ++++++ src/cb/base.cpp | 2 + src/cb/test/test.cpp | 1 + src/cb/time/time.cpp | 21 +++++++ src/cb/types/types.cpp | 2 + 16 files changed, 295 insertions(+) create mode 100644 .gitignore create mode 100644 .idea/.gitignore create mode 100644 .idea/cblib.iml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 CMakeLists.txt create mode 100644 include/cb.h create mode 100644 include/cb/base.h create mode 100644 include/cb/test/test.h create mode 100644 include/cb/time/time.h create mode 100644 include/cb/types/types.h create mode 100644 src/cb/base.cpp create mode 100644 src/cb/test/test.cpp create mode 100644 src/cb/time/time.cpp create mode 100644 src/cb/types/types.cpp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a7a9f50 --- /dev/null +++ b/.gitignore @@ -0,0 +1,122 @@ +CMakeLists.txt.user +CMakeCache.txt +CMakeFiles +CMakeScripts +Testing +Makefile +cmake_install.cmake +install_manifest.txt +compile_commands.json +CTestTestfile.cmake +_deps + +# Prerequisites +*.d + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/cblib.iml b/.idea/cblib.iml new file mode 100644 index 0000000..f08604b --- /dev/null +++ b/.idea/cblib.iml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..6ac60cc --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..599e166 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..ecf1863 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,39 @@ +cmake_minimum_required(VERSION 3.24) + + +####################################################################################################################### +# Project properties +####################################################################################################################### + +project(cblib VERSION 1.0.0 DESCRIPTION "CB library") +set(CMAKE_CXX_STANDARD 17) + + +####################################################################################################################### +# Project properties +####################################################################################################################### + +add_library(${PROJECT_NAME} STATIC + src/cb/base.cpp + src/cb/types/types.cpp + src/cb/time/time.cpp + src/cb/test/test.cpp +) + + +####################################################################################################################### +# Buildling library +####################################################################################################################### + +target_include_directories(${PROJECT_NAME} PUBLIC include) + + +####################################################################################################################### +# Target properties +####################################################################################################################### + +set_target_properties(${PROJECT_NAME} PROPERTIES VERSION ${PROJECT_VERSION}) +set_target_properties(${PROJECT_NAME} PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR}) +set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER source/cb.h) + + diff --git a/include/cb.h b/include/cb.h new file mode 100644 index 0000000..4a98d00 --- /dev/null +++ b/include/cb.h @@ -0,0 +1,10 @@ + +#ifndef GODOT_HUB_MAP_CB_H +#define GODOT_HUB_MAP_CB_H + +#include "cb/test/test.h" +#include "cb/time/time.h" +#include "cb/types/types.h" + + +#endif //GODOT_HUB_MAP_CB_H diff --git a/include/cb/base.h b/include/cb/base.h new file mode 100644 index 0000000..8c99c83 --- /dev/null +++ b/include/cb/base.h @@ -0,0 +1,8 @@ + +#ifndef GODOT_HUB_MAP_BASE_H +#define GODOT_HUB_MAP_BASE_H + + + + +#endif //GODOT_HUB_MAP_BASE_H diff --git a/include/cb/test/test.h b/include/cb/test/test.h new file mode 100644 index 0000000..5fbbe6f --- /dev/null +++ b/include/cb/test/test.h @@ -0,0 +1,19 @@ + +#ifndef GODOT_HUB_MAP_TEST_H +#define GODOT_HUB_MAP_TEST_H + +#include +#include +#include +#include +#include +#include +#include + +namespace test { + #define assertm(exp, msg) = assert(((void)msg, exp)) + +} + + +#endif //GODOT_HUB_MAP_TEST_H diff --git a/include/cb/time/time.h b/include/cb/time/time.h new file mode 100644 index 0000000..e6af430 --- /dev/null +++ b/include/cb/time/time.h @@ -0,0 +1,21 @@ +#ifndef GODOT_HUB_MAP_TIME_H +#define GODOT_HUB_MAP_TIME_H + +#include +#include +#include + +namespace cb::time { + using internal_clock = std::chrono::high_resolution_clock; + using time_point = std::chrono::time_point; + + static std::map _name_to_measurement; + + time_point chrono_now(); + + void start_measure(const std::string_view& id); + + void measure(const std::string_view& id); +} + +#endif //GODOT_HUB_MAP_TIME_H diff --git a/include/cb/types/types.h b/include/cb/types/types.h new file mode 100644 index 0000000..9a3c8cc --- /dev/null +++ b/include/cb/types/types.h @@ -0,0 +1,19 @@ +#ifndef GODOT_HUB_MAP_TYPES_H +#define GODOT_HUB_MAP_TYPES_H + +#include +#include +#include +#include +#include +#include +#include + + +using i64 = int64_t; +using u64 = uint64_t; +using f64 = double; +using f32 = float; + + +#endif //GODOT_HUB_MAP_TYPES_H diff --git a/src/cb/base.cpp b/src/cb/base.cpp new file mode 100644 index 0000000..2e682d0 --- /dev/null +++ b/src/cb/base.cpp @@ -0,0 +1,2 @@ + +#include "cb/base.h" diff --git a/src/cb/test/test.cpp b/src/cb/test/test.cpp new file mode 100644 index 0000000..c500fd5 --- /dev/null +++ b/src/cb/test/test.cpp @@ -0,0 +1 @@ +#include "cb/test/test.h" diff --git a/src/cb/time/time.cpp b/src/cb/time/time.cpp new file mode 100644 index 0000000..b65b6d6 --- /dev/null +++ b/src/cb/time/time.cpp @@ -0,0 +1,21 @@ +#include "cb/time/time.h" + + +#include +#include + +namespace cb::time { + + time_point chrono_now() { + return internal_clock::now(); + } + + void start_measure(const std::string_view &id) { + _name_to_measurement[id] = chrono_now(); + } + + void measure(const std::string_view &id) { + const std::chrono::duration duration = chrono_now() - _name_to_measurement[id]; + std::cout << "measurement: " << id << " took: " << duration.count() << "\n"; + } +} diff --git a/src/cb/types/types.cpp b/src/cb/types/types.cpp new file mode 100644 index 0000000..332d983 --- /dev/null +++ b/src/cb/types/types.cpp @@ -0,0 +1,2 @@ +#include "cb/types/types.h" +