├── .github ├── codecov.yml └── workflows │ ├── cd.yml │ └── ci.yml ├── misc ├── cicd │ ├── conan │ │ ├── msvc17 │ │ ├── gcc11 │ │ ├── clang14 │ │ └── copy_conan_profiles.sh │ ├── codecov │ │ └── generate_coverage_xml.sh │ └── consumer │ │ ├── CMakeLists.txt │ │ └── conanfile.py └── scripts │ └── coverage_and_host.sh ├── TODO.md ├── cmake └── xvizConfig.cmake.in ├── .gitignore ├── examples ├── CMakeLists.txt ├── example.cc └── example_server.cc ├── proto └── xviz │ └── v2 │ ├── options.proto │ ├── envelope.proto │ ├── annotation.proto │ ├── uiprimitives.proto │ ├── declarativeui.proto │ ├── primitives.proto │ ├── style.proto │ ├── core.proto │ └── session.proto ├── CMakeLists.txt ├── tests ├── CMakeLists.txt ├── utils │ ├── cleanup.h │ ├── macros.h │ ├── converters.h │ ├── comparators.h │ ├── types.h │ ├── converters.cc │ └── checker.h └── test_metadata_builder.cc ├── LICENSE.md ├── src ├── xviz.cc ├── CMakeLists.txt └── utils │ ├── utils.cc │ └── base64.cc ├── include └── xviz │ ├── xviz.h │ ├── utils │ ├── base64.h │ ├── concepts.h │ ├── utils.h │ └── style_utils.h │ ├── def.h │ ├── builder │ ├── primitive │ │ ├── circle.h │ │ ├── polygon.h │ │ ├── polyline.h │ │ ├── image.h │ │ ├── text.h │ │ ├── point.h │ │ ├── primitive_mixin.h │ │ ├── primitive_base.h │ │ └── primitive.h │ ├── metadata │ │ ├── metadata_mixin.h │ │ ├── metadata.h │ │ ├── ui_metadata.h │ │ └── stream_metadata.h │ ├── builder_mixin.h │ ├── pose.h │ ├── time_series.h │ ├── ui_primitive.h │ └── builder.h │ └── message.h ├── README.md ├── .clang-format └── conanfile.py /.github/codecov.yml: -------------------------------------------------------------------------------- 1 | coverage: 2 | status: 3 | patch: off # TODO enable this one later 4 | project: 5 | default: 6 | target: 85% 7 | threshold: 1% 8 | comment: false -------------------------------------------------------------------------------- /misc/cicd/conan/msvc17: -------------------------------------------------------------------------------- 1 | [settings] 2 | os=Windows 3 | os_build=Windows 4 | arch=x86_64 5 | arch_build=x86_64 6 | compiler=Visual Studio 7 | compiler.cppstd=20 8 | compiler.version=17 9 | build_type=Debug 10 | [options] 11 | [build_requires] -------------------------------------------------------------------------------- /TODO.md: -------------------------------------------------------------------------------- 1 | # TODO List 2 | Priority from high to low. 3 | 1. [x] UIPrimitive and Timeseries Builder 4 | 2. [ ] Add more tests for primitive builder. 5 | 3. [ ] Auto CD to Conan center. 6 | 4. [ ] Documents and comments in codes. 7 | 5. [ ] Complete functionalities. 8 | -------------------------------------------------------------------------------- /cmake/xvizConfig.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | include(CMakeFindDependencyMacro) 4 | find_dependency(protobuf REQUIRED) 5 | find_dependency(fmt REQUIRED) 6 | 7 | include("${CMAKE_CURRENT_LIST_DIR}/xvizTargets.cmake") 8 | check_required_components("@PROJECT_NAME@") -------------------------------------------------------------------------------- /misc/cicd/conan/gcc11: -------------------------------------------------------------------------------- 1 | [settings] 2 | os=Linux 3 | os_build=Linux 4 | arch=x86_64 5 | arch_build=x86_64 6 | compiler=gcc 7 | compiler.cppstd=20 8 | compiler.version=11 9 | compiler.libcxx=libstdc++11 10 | build_type=Debug 11 | [options] 12 | [build_requires] 13 | [env] 14 | CXX=g++-11 15 | CC=gcc-11 -------------------------------------------------------------------------------- /misc/cicd/conan/clang14: -------------------------------------------------------------------------------- 1 | [settings] 2 | os=Linux 3 | os_build=Linux 4 | arch=x86_64 5 | arch_build=x86_64 6 | compiler=clang 7 | compiler.cppstd=20 8 | compiler.version=14 9 | compiler.libcxx=libc++ 10 | build_type=Debug 11 | [options] 12 | [build_requires] 13 | [env] 14 | CXX=clang++-14 15 | CC=clang-14 16 | CXXFLAGS="-stdlib=libc++" -------------------------------------------------------------------------------- /misc/cicd/conan/copy_conan_profiles.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | DESTINATION_FOLDER=${1} 4 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) 5 | 6 | echo "copying ${SCRIPT_DIR}/clang14, ${SCRIPT_DIR}/gcc11 and ${SCRIPT_DIR}/msvc17 to ${DESTINATION_FOLDER}/" 7 | cp ${SCRIPT_DIR}/clang14 ${SCRIPT_DIR}/gcc11 ${SCRIPT_DIR}/msvc17 ${DESTINATION_FOLDER}/ 8 | -------------------------------------------------------------------------------- /misc/scripts/coverage_and_host.sh: -------------------------------------------------------------------------------- 1 | SOURCE_DIR=$(realpath $( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/../../) 2 | echo $SOURCE_DIR 3 | lcov -c -b $SOURCE_DIR/include -d $SOURCE_DIR/build -o $SOURCE_DIR/build/coverage.info --include "$SOURCE_DIR/*" --exclude "$SOURCE_DIR/build/*" 4 | genhtml $SOURCE_DIR/build/coverage.info --output-directory $SOURCE_DIR/build/html/ 5 | python3 -m http.server -d $SOURCE_DIR/build/html/ -b 0.0.0.0 -------------------------------------------------------------------------------- /misc/cicd/codecov/generate_coverage_xml.sh: -------------------------------------------------------------------------------- 1 | 2 | TEST_FOLDER=$(realpath ${1:-.}) 3 | echo "test path: $TEST_FOLDER" 4 | SOURCE_DIR=$(realpath $( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/../../../) 5 | echo "source path: $SOURCE_DIR" 6 | lcov -c -d $SOURCE_DIR -o $SOURCE_DIR/coverage.info --include "$SOURCE_DIR/*" --exclude "$SOURCE_DIR/build/*" 7 | lcov_cobertura coverage.info -d -b $TEST_FOLDER -e "tests/*" -o coverage.xml 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.vscode 2 | /pb/**/ 3 | /bin 4 | /build 5 | /consumer 6 | 7 | # Prerequisites 8 | *.d 9 | 10 | # Compiled Object files 11 | *.slo 12 | *.lo 13 | *.o 14 | *.obj 15 | 16 | # Precompiled Headers 17 | *.gch 18 | *.pch 19 | 20 | # Compiled Dynamic libraries 21 | *.so 22 | *.dylib 23 | *.dll 24 | 25 | # Fortran module files 26 | *.mod 27 | *.smod 28 | 29 | # Compiled Static libraries 30 | *.lai 31 | *.la 32 | *.a 33 | *.lib 34 | 35 | # Executables 36 | *.exe 37 | *.out 38 | *.app 39 | 40 | CMakeUserPresets.json -------------------------------------------------------------------------------- /examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_package(websocketpp REQUIRED) 2 | find_package(lodepng REQUIRED) 3 | 4 | function(build_examples) 5 | foreach(example_file ${ARGV}) 6 | get_filename_component(example_name ${example_file} NAME_WE) 7 | add_executable(${example_name} ${example_file}) 8 | target_link_libraries(${example_name} xviz websocketpp::websocketpp 9 | lodepng::lodepng) 10 | endforeach(example_file ${ARGV}) 11 | endfunction() 12 | 13 | file(GLOB example_files ${CMAKE_CURRENT_SOURCE_DIR}/*.cc) 14 | 15 | build_examples(${example_files}) 16 | -------------------------------------------------------------------------------- /proto/xviz/v2/options.proto: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------- 2 | // WARNING: XVIZ Protobuf files are unstable, do not use 3 | // -------------------------------------------------------- 4 | 5 | syntax = "proto3"; 6 | 7 | package xviz.v2; 8 | 9 | option csharp_namespace = "xviz.V2"; 10 | option go_package = "v2pb"; 11 | option java_multiple_files = true; 12 | option java_outer_classname = "OptionsProto"; 13 | option java_package = "com.xviz.v2"; 14 | option objc_class_prefix = "XVIZ"; 15 | option php_namespace = "Xviz\\V2"; 16 | 17 | import "google/protobuf/descriptor.proto"; 18 | 19 | extend google.protobuf.MessageOptions { 20 | string xviz_json_schema = 54200; 21 | } 22 | -------------------------------------------------------------------------------- /misc/cicd/consumer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | 3 | project(xviz_test_package) 4 | 5 | find_package(websocketpp REQUIRED) 6 | find_package(lodepng REQUIRED) 7 | find_package(xviz REQUIRED) 8 | 9 | function(build_examples) 10 | foreach(example_file ${ARGV}) 11 | get_filename_component(example_name ${example_file} NAME_WE) 12 | add_executable(${example_name} ${example_file}) 13 | target_link_libraries(${example_name} xviz::xviz websocketpp::websocketpp 14 | lodepng::lodepng) 15 | endforeach(example_file ${ARGV}) 16 | endfunction() 17 | 18 | file(GLOB example_files ${CMAKE_CURRENT_SOURCE_DIR}/*.cc) 19 | 20 | build_examples(${example_files}) 21 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | 3 | if(NOT XVIZ_VERSION) 4 | set(XVIZ_VERSION "l.0.0") 5 | endif() 6 | 7 | project( 8 | xviz 9 | VERSION ${XVIZ_VERSION} 10 | DESCRIPTION "C++ Implementation of XVIZ Protocol" 11 | LANGUAGES CXX) 12 | 13 | set(CMAKE_CXX_STANDARD 20) 14 | 15 | if(XVIZ_BUILD_TESTS AND XVIZ_TEST_COVERAGE) 16 | message(STATUS "Appending coverage flags to compile command") 17 | include(cmake/CodeCoverage.cmake) 18 | append_coverage_compiler_flags() 19 | endif() 20 | 21 | add_subdirectory("src") 22 | 23 | if(XVIZ_BUILD_TESTS) 24 | enable_testing() 25 | add_subdirectory("tests") 26 | endif() 27 | 28 | if (XVIZ_BUILD_EXAMPLES) 29 | add_subdirectory("examples") 30 | endif() 31 | -------------------------------------------------------------------------------- /tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_package(GTest REQUIRED) 2 | 3 | add_library(xviz_tests 4 | ${CMAKE_CURRENT_SOURCE_DIR}/utils/converters.cc 5 | ) 6 | 7 | target_link_libraries(xviz_tests xviz) 8 | 9 | function(build_tests) 10 | foreach(test_file ${ARGV}) 11 | get_filename_component(test_name ${test_file} NAME_WE) 12 | add_executable(${test_name} ${test_file}) 13 | target_link_libraries(${test_name} xviz_tests GTest::gtest GTest::gtest_main) 14 | add_test(${test_name} ${test_name}) 15 | # Any test should exceed the time limit 16 | set_tests_properties(${test_name} PROPERTIES TIMEOUT 60) 17 | endforeach(test_file ${ARGV}) 18 | endfunction() 19 | 20 | file(GLOB test_files ${CMAKE_SOURCE_DIR}/tests/test_*.cc) 21 | build_tests(${test_files}) 22 | -------------------------------------------------------------------------------- /proto/xviz/v2/envelope.proto: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------- 2 | // WARNING: XVIZ Protobuf files are unstable, do not use 3 | // -------------------------------------------------------- 4 | 5 | syntax = "proto3"; 6 | 7 | package xviz.v2; 8 | 9 | option csharp_namespace = "xviz.V2"; 10 | option go_package = "v2pb"; 11 | option java_multiple_files = true; 12 | option java_outer_classname = "EnvelopeProto"; 13 | option java_package = "com.xviz.v2"; 14 | option objc_class_prefix = "XVIZ"; 15 | option php_namespace = "Xviz\\V2"; 16 | 17 | import "google/protobuf/any.proto"; 18 | 19 | message Envelope { 20 | // Categorize the message, recommend pattern: "namespace/type" 21 | // This allows for two levels of routing and filtering in an 22 | // application. And for subscription to just some messages. 23 | string type = 1; 24 | 25 | google.protobuf.Any data = 2; 26 | } 27 | -------------------------------------------------------------------------------- /proto/xviz/v2/annotation.proto: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------- 2 | // WARNING: XVIZ Protobuf files are unstable, do not use 3 | // -------------------------------------------------------- 4 | 5 | syntax = "proto3"; 6 | 7 | package xviz.v2; 8 | 9 | option csharp_namespace = "xviz.V2"; 10 | option go_package = "v2pb"; 11 | option java_multiple_files = true; 12 | option java_outer_classname = "AnnotationProto"; 13 | option java_package = "com.xviz.v2"; 14 | option objc_class_prefix = "XVIZ"; 15 | option php_namespace = "Xviz\\V2"; 16 | 17 | import "xviz/v2/options.proto"; 18 | import "xviz/v2/style.proto"; 19 | 20 | message VisualBase { 21 | option (xviz_json_schema) = "core/annotation_base"; 22 | string object_id = 1; 23 | } 24 | 25 | message Visual { 26 | option (xviz_json_schema) = "core/annotation_visual"; 27 | VisualBase base = 1; 28 | repeated string style_classes = 2; 29 | StyleObjectValue inline_style = 3; 30 | } 31 | -------------------------------------------------------------------------------- /proto/xviz/v2/uiprimitives.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package xviz.v2; 4 | 5 | option csharp_namespace = "xviz.V2"; 6 | option go_package = "v2pb"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "UiprimitivesProto"; 9 | option java_package = "com.xviz.v2"; 10 | option objc_class_prefix = "XVIZ"; 11 | option php_namespace = "Xviz\\V2"; 12 | 13 | import "xviz/v2/options.proto"; 14 | 15 | message TreeTable { 16 | option (xviz_json_schema) = "ui-primitives/treetable"; 17 | repeated TreeTableColumn columns = 1; 18 | repeated TreeTableNode nodes = 2; 19 | } 20 | 21 | message TreeTableColumn { 22 | enum ColumnType { 23 | TREE_TABLE_COLUMN_COLUMN_TYPE_INVALID = 0; 24 | INT32 = 1; 25 | DOUBLE = 2; 26 | STRING = 3; 27 | BOOLEAN = 4; 28 | } 29 | string display_text = 1; 30 | ColumnType type = 2; 31 | string unit = 3; 32 | } 33 | 34 | message TreeTableNode { 35 | int32 id = 1; 36 | int32 parent = 2; 37 | repeated string column_values = 3; 38 | } 39 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Minjun Xu 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /src/xviz.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Project: libxviz 3 | * Description: C++ Implementation of XVIZ Protocol 4 | * Author: Minjun Xu (mjxu96@outlook.com) 5 | * ----- 6 | * MIT License 7 | * Copyright (c) 2023 Minjun Xu 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to 11 | * deal in the Software without restriction, including without limitation the 12 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 13 | * sell copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 25 | * IN THE SOFTWARE. 26 | */ 27 | 28 | #include 29 | 30 | const std::string_view xviz::Version() { return XVIZ_VERSION; } 31 | -------------------------------------------------------------------------------- /include/xviz/xviz.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Project: libxviz 3 | * Description: C++ Implementation of XVIZ Protocol 4 | * Author: Minjun Xu (mjxu96@outlook.com) 5 | * ----- 6 | * MIT License 7 | * Copyright (c) 2023 Minjun Xu 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to 11 | * deal in the Software without restriction, including without limitation the 12 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 13 | * sell copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 25 | * IN THE SOFTWARE. 26 | */ 27 | 28 | #pragma once 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | #include 35 | 36 | namespace xviz { 37 | 38 | const std::string_view Version(); 39 | 40 | } // namespace xviz 41 | -------------------------------------------------------------------------------- /proto/xviz/v2/declarativeui.proto: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------- 2 | // WARNING: XVIZ Protobuf files are unstable, do not use 3 | // -------------------------------------------------------- 4 | 5 | syntax = "proto3"; 6 | 7 | package xviz.v2; 8 | 9 | option csharp_namespace = "xviz.V2"; 10 | option go_package = "v2pb"; 11 | option java_multiple_files = true; 12 | option java_outer_classname = "UiprimitivesProto"; 13 | option java_package = "com.xviz.v2"; 14 | option objc_class_prefix = "XVIZ"; 15 | option php_namespace = "Xviz\\V2"; 16 | 17 | import "xviz/v2/options.proto"; 18 | 19 | enum LayoutType { 20 | VERTICAL = 0; 21 | HORIZONTAL = 1; 22 | } 23 | 24 | enum ComponentType { 25 | NONE = 0; 26 | TABLE = 1; 27 | METRIC = 2; 28 | PLOT = 3; 29 | TREETABLE = 4; 30 | VIDEO = 5; 31 | SELECT = 6; 32 | CONTAINER = 7; 33 | } 34 | 35 | // LAYOUT INTERACTION TYPE AND COMPONENT INTERACTION TYPE 36 | 37 | message UIPanel { 38 | option (xviz_json_schema) = "declarativeui/ui_panel"; 39 | string name = 1; 40 | ComponentType type = 2; 41 | LayoutType layout = 3; 42 | 43 | string title = 4; 44 | string description = 5; 45 | 46 | // for contanier type only 47 | repeated UIPanel children = 6; 48 | 49 | // for video type only 50 | repeated string cameras = 7; 51 | 52 | // for metric type only 53 | repeated string streams = 8; 54 | 55 | // for plot type only 56 | string independent_variable = 9; 57 | repeated string dependent_variables = 10; 58 | 59 | // for table and treetable only 60 | string stream = 11; 61 | bool display_object_id = 12; 62 | } -------------------------------------------------------------------------------- /include/xviz/utils/base64.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Project: libxviz 3 | * Description: C++ Implementation of XVIZ Protocol 4 | * Author: Minjun Xu (mjxu96@outlook.com) 5 | * ----- 6 | * MIT License 7 | * Copyright (c) 2023 Minjun Xu 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to 11 | * deal in the Software without restriction, including without limitation the 12 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 13 | * sell copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 25 | * IN THE SOFTWARE. 26 | */ 27 | 28 | #pragma once 29 | 30 | #include 31 | #include 32 | 33 | namespace xviz::util { 34 | 35 | std::string Base64Encode(const unsigned char*, unsigned int); 36 | std::vector Base64Decode(const std::string&); 37 | 38 | } // namespace xviz::util -------------------------------------------------------------------------------- /misc/cicd/consumer/conanfile.py: -------------------------------------------------------------------------------- 1 | from conans import ConanFile 2 | from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake, cmake_layout 3 | import os 4 | 5 | 6 | class XVIZConsumerExample(ConanFile): 7 | name = "xviz_consumer_example" 8 | 9 | # Binary configuration 10 | settings = "os", "compiler", "build_type", "arch" 11 | options = { 12 | "shared": [True, False], 13 | "fPIC": [True, False], 14 | } 15 | default_options = { 16 | "shared": False, 17 | "fPIC": True, 18 | } 19 | 20 | def _configure_cmake(self) -> CMake: 21 | cmake = CMake(self) 22 | cmake.configure() 23 | return cmake 24 | 25 | def requirements(self): 26 | # read version from CI env 27 | xviz_version = os.environ["XVIZ_CI_VERSION_OVERRIDE"] 28 | self.requires(f"xviz/{xviz_version}@local/test") 29 | self.requires("websocketpp/0.8.2") 30 | self.requires("lodepng/cci.20200615") 31 | self.options["websocketpp"].asio = "standalone" 32 | # we don't need openssl for example 33 | self.options["websocketpp"].with_openssl = False 34 | 35 | def config_options(self): 36 | if self.settings.os == "Windows": 37 | del self.options.fPIC 38 | 39 | def layout(self): 40 | cmake_layout(self) 41 | 42 | def generate(self): 43 | dp = CMakeDeps(self) 44 | dp.generate() 45 | tc = CMakeToolchain(self) 46 | tc.generate() 47 | 48 | def build(self): 49 | cmake = self._configure_cmake() 50 | if self.should_build or self.should_test: 51 | cmake.build() 52 | -------------------------------------------------------------------------------- /tests/utils/cleanup.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Project: libxviz 3 | * Description: C++ Implementation of XVIZ Protocol 4 | * Author: Minjun Xu (mjxu96@outlook.com) 5 | * ----- 6 | * MIT License 7 | * Copyright (c) 2023 Minjun Xu 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to 11 | * deal in the Software without restriction, including without limitation the 12 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 13 | * sell copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 25 | * IN THE SOFTWARE. 26 | */ 27 | 28 | #pragma once 29 | 30 | #include 31 | 32 | namespace xviz::tests { 33 | struct GlobalDesctructor { 34 | GlobalDesctructor() {} 35 | ~GlobalDesctructor() { google::protobuf::ShutdownProtobufLibrary(); } 36 | } global_destructor; 37 | } // namespace xviz::tests 38 | -------------------------------------------------------------------------------- /tests/utils/macros.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Project: libxviz 3 | * Description: C++ Implementation of XVIZ Protocol 4 | * Author: Minjun Xu (mjxu96@outlook.com) 5 | * ----- 6 | * MIT License 7 | * Copyright (c) 2023 Minjun Xu 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to 11 | * deal in the Software without restriction, including without limitation the 12 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 13 | * sell copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 25 | * IN THE SOFTWARE. 26 | */ 27 | 28 | #pragma once 29 | 30 | #define CONVERT_PROTOBUF_FIELD_TO_OPTIONAL(msg, field_name) \ 31 | (msg.has_##field_name() ? (std::make_optional(msg.field_name())) \ 32 | : (std::nullopt)) 33 | 34 | #define CONVERT_PROTOBUF_ENUM_TO_OPTIONAL(msg, field_name) \ 35 | (static_cast(msg.field_name()) != 0 \ 36 | ? (std::make_optional(msg.field_name())) \ 37 | : (std::nullopt)) 38 | -------------------------------------------------------------------------------- /tests/utils/converters.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Project: libxviz 3 | * Description: C++ Implementation of XVIZ Protocol 4 | * Author: Minjun Xu (mjxu96@outlook.com) 5 | * ----- 6 | * MIT License 7 | * Copyright (c) 2023 Minjun Xu 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to 11 | * deal in the Software without restriction, including without limitation the 12 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 13 | * sell copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 25 | * IN THE SOFTWARE. 26 | */ 27 | 28 | #pragma once 29 | 30 | #include 31 | #include 32 | 33 | #include 34 | 35 | namespace xviz::tests { 36 | 37 | std::unordered_map 38 | ConvertStyleClassToMap( 39 | const google::protobuf::RepeatedPtrField&); 40 | 41 | std::unordered_map 42 | ConvertMapToStyleClass(const std::unordered_map&); 43 | } // namespace xviz::tests 44 | -------------------------------------------------------------------------------- /tests/utils/comparators.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Project: libxviz 3 | * Description: C++ Implementation of XVIZ Protocol 4 | * Author: Minjun Xu (mjxu96@outlook.com) 5 | * ----- 6 | * MIT License 7 | * Copyright (c) 2023 Minjun Xu 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to 11 | * deal in the Software without restriction, including without limitation the 12 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 13 | * sell copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 25 | * IN THE SOFTWARE. 26 | */ 27 | 28 | #pragma once 29 | 30 | #include 31 | 32 | #include 33 | 34 | namespace xviz::v2 { 35 | 36 | bool operator==(const StyleStreamValue& message1, 37 | const StyleStreamValue& message2) { 38 | return google::protobuf::util::MessageDifferencer::Equals(message1, message2); 39 | } 40 | 41 | bool operator==(const StyleObjectValue& message1, 42 | const StyleObjectValue& message2) { 43 | return google::protobuf::util::MessageDifferencer::Equals(message1, message2); 44 | } 45 | 46 | }; // namespace xviz::v2 47 | -------------------------------------------------------------------------------- /include/xviz/def.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Project: libxviz 3 | * Description: C++ Implementation of XVIZ Protocol 4 | * Author: Minjun Xu (mjxu96@outlook.com) 5 | * ----- 6 | * MIT License 7 | * Copyright (c) 2023 Minjun Xu 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to 11 | * deal in the Software without restriction, including without limitation the 12 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 13 | * sell copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 25 | * IN THE SOFTWARE. 26 | */ 27 | 28 | #pragma once 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #include 38 | 39 | #include 40 | #include 41 | #include 42 | 43 | #ifdef __cpp_lib_format 44 | #include 45 | #else 46 | #include 47 | #include 48 | namespace std { 49 | using fmt::format; 50 | } 51 | 52 | #endif 53 | 54 | namespace xviz { 55 | 56 | using namespace v2; 57 | 58 | } // namespace xviz 59 | -------------------------------------------------------------------------------- /include/xviz/builder/primitive/circle.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Project: libxviz 3 | * Description: C++ Implementation of XVIZ Protocol 4 | * Author: Minjun Xu (mjxu96@outlook.com) 5 | * ----- 6 | * MIT License 7 | * Copyright (c) 2023 Minjun Xu 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to 11 | * deal in the Software without restriction, including without limitation the 12 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 13 | * sell copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 25 | * IN THE SOFTWARE. 26 | */ 27 | 28 | #pragma once 29 | 30 | #include "primitive_base.h" 31 | 32 | namespace xviz { 33 | 34 | template 35 | class PrimitiveCircleBuilder 36 | : public PrimitiveBaseBuilder< 37 | PrimitiveCircleBuilder, Circle, 38 | PrimitiveBuilderType, BuilderType> { 39 | using BaseType = PrimitiveBaseBuilder< 40 | PrimitiveCircleBuilder, Circle, 41 | PrimitiveBuilderType, BuilderType>; 42 | 43 | public: 44 | using BaseType::BaseType; 45 | using BaseType::End; 46 | using BaseType::Start; 47 | }; 48 | 49 | } // namespace xviz 50 | -------------------------------------------------------------------------------- /include/xviz/builder/primitive/polygon.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Project: libxviz 3 | * Description: C++ Implementation of XVIZ Protocol 4 | * Author: Minjun Xu (mjxu96@outlook.com) 5 | * ----- 6 | * MIT License 7 | * Copyright (c) 2023 Minjun Xu 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to 11 | * deal in the Software without restriction, including without limitation the 12 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 13 | * sell copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 25 | * IN THE SOFTWARE. 26 | */ 27 | 28 | #pragma once 29 | #include "primitive_base.h" 30 | 31 | namespace xviz { 32 | 33 | template 34 | class PrimitivePolygonBuilder 35 | : public PrimitiveBaseBuilder< 36 | PrimitivePolygonBuilder, Polygon, 37 | PrimitiveBuilderType, BuilderType> { 38 | using BaseType = PrimitiveBaseBuilder< 39 | PrimitivePolygonBuilder, Polygon, 40 | PrimitiveBuilderType, BuilderType>; 41 | 42 | public: 43 | using BaseType::BaseType; 44 | using BaseType::End; 45 | using BaseType::Start; 46 | }; 47 | 48 | } // namespace xviz 49 | -------------------------------------------------------------------------------- /include/xviz/builder/primitive/polyline.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Project: libxviz 3 | * Description: C++ Implementation of XVIZ Protocol 4 | * Author: Minjun Xu (mjxu96@outlook.com) 5 | * ----- 6 | * MIT License 7 | * Copyright (c) 2023 Minjun Xu 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to 11 | * deal in the Software without restriction, including without limitation the 12 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 13 | * sell copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 25 | * IN THE SOFTWARE. 26 | */ 27 | 28 | #pragma once 29 | #include "primitive_base.h" 30 | 31 | namespace xviz { 32 | 33 | template 34 | class PrimitivePolylineBuilder 35 | : public PrimitiveBaseBuilder< 36 | PrimitivePolylineBuilder, Polyline, 37 | PrimitiveBuilderType, BuilderType> { 38 | using BaseType = PrimitiveBaseBuilder< 39 | PrimitivePolylineBuilder, Polyline, 40 | PrimitiveBuilderType, BuilderType>; 41 | 42 | public: 43 | using BaseType::BaseType; 44 | using BaseType::End; 45 | using BaseType::Start; 46 | }; 47 | 48 | } // namespace xviz 49 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # XVIZ Protocol In C++ 2 | [![libxviz CI](https://github.com/mjxu96/xviz/actions/workflows/ci.yml/badge.svg)](https://github.com/mjxu96/xviz/actions/workflows/ci.yml) [![codecov](https://codecov.io/gh/mjxu96/xviz/branch/master/graph/badge.svg?token=JDDAW7YU7B)](https://codecov.io/gh/mjxu96/xviz) 3 | 4 | ## Overview 5 | This is an _incomplete_ implementation of [XVIZ protocol](https://github.com/aurora-opensource/xviz) in C++. 6 | 7 | This project has been migrated to [Conan](https://conan.io/). Please checkout to [old](https://github.com/mjxu96/xviz/tree/old) branch for legacy build mechanism. 8 | 9 | ## Requirements 10 | 1. Conan 1.55.0+ 11 | 2. C++20 compiler 12 | 13 | ## Example 14 | Please see [example.cc](examples/example.cc), [example_server.cc](examples/example_server.cc) for more information. 15 | 16 | ## Use Case 17 | 1. [CarlaViz](https://github.com/mjxu96/carlaviz) 18 | 19 | ## Build and Test 20 | 21 | ### Download from Conan remote 22 | ```bash 23 | conan remote add gitlab https://gitlab.com/api/v4/projects/44861904/packages/conan 24 | conan install xviz 25 | ``` 26 | ### Build xviz builder example 27 | ```bash 28 | mkdir build && cd build 29 | conan install -pr gcc11 --build=missing -o build_examples=True .. 30 | conan build .. --build 31 | ./examples/example 32 | ``` 33 | 34 | ### Build xviz server example 35 | Frontend is needed. You can refer to these two repos for frontend: 36 | 1. [CarlaViz Frontend](https://github.com/mjxu96/carlaviz/tree/master/frontend) 37 | 2. [Aurora streetscape.gl](https://github.com/aurora-opensource/streetscape.gl) 38 | ```bash 39 | mkdir build && cd build 40 | conan install -pr gcc11 --build=missing -o build_examples=True .. 41 | conan build .. --build 42 | ./examples/example_server [PNG FILE PATH (this is optional)] 43 | ``` 44 | 45 | ### Build tests 46 | ```bash 47 | mkdir build && cd build 48 | conan install -pr gcc11 --build=missing -o build_tests=True .. 49 | conan build .. --test 50 | ``` 51 | 52 | ## Format script 53 | ```bash 54 | find . -iname *.h -not -path "./build/*" -o -iname *.cc -not -path "./build/*" | xargs clang-format -i -style=file 55 | ``` 56 | -------------------------------------------------------------------------------- /include/xviz/builder/metadata/metadata_mixin.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Project: libxviz 3 | * Description: C++ Implementation of XVIZ Protocol 4 | * Author: Minjun Xu (mjxu96@outlook.com) 5 | * ----- 6 | * MIT License 7 | * Copyright (c) 2023 Minjun Xu 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to 11 | * deal in the Software without restriction, including without limitation the 12 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 13 | * sell copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 25 | * IN THE SOFTWARE. 26 | */ 27 | 28 | #pragma once 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | namespace xviz { 35 | 36 | template 37 | class MetadataBuilderMixin { 38 | public: 39 | MetadataBuilderMixin(MetadataBuilderT& builder) : builder_(builder) {} 40 | 41 | template 42 | auto&& Stream(Args&&... args) { 43 | return builder_.Stream(std::forward(args)...); 44 | } 45 | 46 | template 47 | auto&& UI(Args&&... args) { 48 | return builder_.UI(std::forward(args)...); 49 | } 50 | 51 | auto&& GetData() { return builder_.GetData(); } 52 | 53 | private: 54 | MetadataBuilderT& builder_; 55 | }; 56 | 57 | } // namespace xviz 58 | -------------------------------------------------------------------------------- /include/xviz/utils/concepts.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Project: libxviz 3 | * Description: C++ Implementation of XVIZ Protocol 4 | * Author: Minjun Xu (mjxu96@outlook.com) 5 | * ----- 6 | * MIT License 7 | * Copyright (c) 2022 Minjun Xu 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to 11 | * deal in the Software without restriction, including without limitation the 12 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 13 | * sell copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 25 | * IN THE SOFTWARE. 26 | */ 27 | 28 | #pragma once 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | namespace xviz::concepts { 36 | 37 | template 38 | using FirstArgType = std::decay_t>>; 39 | 40 | template 41 | concept CanConstructString = std::constructible_from; 42 | 43 | template 44 | concept TimeSeriesAcceptableType = CanConstructString || 45 | ((sizeof...(ValueArgsT) == 1) && 46 | (std::same_as, bool> || 47 | std::same_as, double> || 48 | std::same_as, int32_t>)); 49 | 50 | } // namespace xviz::concepts -------------------------------------------------------------------------------- /tests/utils/types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Project: libxviz 3 | * Description: C++ Implementation of XVIZ Protocol 4 | * Author: Minjun Xu (mjxu96@outlook.com) 5 | * ----- 6 | * MIT License 7 | * Copyright (c) 2023 Minjun Xu 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to 11 | * deal in the Software without restriction, including without limitation the 12 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 13 | * sell copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 25 | * IN THE SOFTWARE. 26 | */ 27 | 28 | #pragma once 29 | 30 | #include 31 | 32 | #include 33 | #include 34 | 35 | namespace xviz::tests { 36 | 37 | template typename Tpl> 38 | struct IsTemplateClass : std::false_type {}; 39 | 40 | template