1+ /*
2+ * Copyright 2025 Intel Corporation
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+ #pragma once
18+
19+ // /
20+ // / @file version.hpp
21+ // / @brief SVS API versioning support for integration with external libraries like Faiss
22+ // /
23+ // / This header defines the SVS API versioning scheme that allows:
24+ // / 1. Stable API versions (e.g., v0, v1) with inline namespace support
25+ // / 2. Clean integration points for external libraries
26+ // / 3. Gradual migration between API versions
27+ // /
28+ // / Usage:
29+ // / - Public APIs are wrapped in SVS_VERSIONED_NAMESPACE_BEGIN/END
30+ // / - Users can access APIs via svs::ClassName (maps to current version)
31+ // / - External integrators can use namespace aliases (e.g., namespace svs_api = svs::v0)
32+ // /
33+
34+ // /// Version Numbers
35+
36+ // / Major version number - incremented for breaking API changes
37+ // / When this changes, a new version namespace (e.g., v0 -> v1) is created
38+ #define SVS_VERSION_MAJOR 0
39+
40+ // / Minor version number - incremented for backward-compatible feature additions
41+ #define SVS_VERSION_MINOR 1
42+
43+ // / Patch version number - incremented for backward-compatible bug fixes
44+ #define SVS_VERSION_PATCH 0
45+
46+ // / Complete version string
47+ #define SVS_VERSION_STRING " 0.1.0"
48+
49+ // /// API Version Namespace
50+
51+ // / The current API version namespace identifier
52+ // / This defines which API generation is currently active
53+ // / Example: v0 for the first stable API, v1 for the next major version, etc.
54+ #define SVS_VERSION_NAMESPACE v0
55+
56+ // /// Namespace Macros
57+
58+ // / Begin a versioned namespace block for public APIs
59+ // / Use this to wrap public classes, functions, and types that should be
60+ // / stable across minor/patch releases within the same major version
61+ #define SVS_VERSIONED_NAMESPACE_BEGIN \
62+ namespace svs { \
63+ inline namespace SVS_VERSION_NAMESPACE {
64+
65+ // / End a versioned namespace block
66+ #define SVS_VERSIONED_NAMESPACE_END \
67+ } /* end inline namespace SVS_VERSION_NAMESPACE */ \
68+ } /* end namespace svs */
69+
70+ // /// Internal Namespace
71+
72+ // / Internal namespace for implementation details that are not part of the stable API
73+ // / Items in this namespace can change freely without version bumps
74+ #define SVS_INTERNAL_NAMESPACE_BEGIN \
75+ namespace svs { \
76+ namespace internal {
77+
78+ #define SVS_INTERNAL_NAMESPACE_END \
79+ } /* end namespace internal */ \
80+ } /* end namespace svs */
81+
82+ // /// Version Namespace Declaration
83+
84+ // / Declare the main SVS namespace with inline version namespace
85+ // / This makes svs::Foo automatically resolve to svs::v0::Foo (or current version)
86+ namespace svs {
87+ // / Current API version namespace
88+ // / All public APIs live here and are accessible as svs::ClassName
89+ inline namespace SVS_VERSION_NAMESPACE {
90+ // Public APIs will be defined here via SVS_VERSIONED_NAMESPACE_BEGIN/END
91+ }
92+
93+ // / Internal implementation details
94+ // / Not part of the stable API - can change freely
95+ namespace internal {
96+ // Internal helpers and implementation details
97+ }
98+ }
99+
100+ // /// Integration Support
101+
102+ // / Helper macro to create namespace aliases for external integrators
103+ // / Example: SVS_CREATE_API_ALIAS(svs_api, v0) creates: namespace svs_api = svs::v0;
104+ #define SVS_CREATE_API_ALIAS (alias_name, version_ns ) \
105+ namespace alias_name = svs::version_ns
106+
107+ // /
108+ // / @brief Version information structure for runtime queries
109+ // /
110+ SVS_VERSIONED_NAMESPACE_BEGIN
111+
112+ struct VersionInfo {
113+ static constexpr int major = SVS_VERSION_MAJOR;
114+ static constexpr int minor = SVS_VERSION_MINOR;
115+ static constexpr int patch = SVS_VERSION_PATCH;
116+ static constexpr const char * version_string = SVS_VERSION_STRING;
117+ static constexpr const char * api_namespace = " v0" ; // Should match SVS_VERSION_NAMESPACE
118+
119+ // / Get the complete version as a string
120+ static const char * get_version () { return version_string; }
121+
122+ // / Get the API namespace identifier
123+ static const char * get_api_namespace () { return api_namespace; }
124+
125+ // / Check if this version is compatible with a requested major version
126+ static bool is_compatible_with_major (int requested_major) {
127+ return major == requested_major;
128+ }
129+ };
130+
131+ SVS_VERSIONED_NAMESPACE_END
0 commit comments