XVector
xvec_context.hpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2026 XCENA Inc.
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 
42 #pragma once
43 
44 #ifdef __cplusplus
45 
46 #include <cstdint>
47 #include <optional>
48 #include <string>
49 
51 
52 #include "xvector/xvec_types.h"
53 
54 namespace xvec
55 {
56 
67 class Context
68 {
69 public:
75  static uint32_t getNumDevices();
76 
82  explicit Context(uint32_t deviceId);
83 
84  virtual ~Context();
85 
86  Context(Context&& other) noexcept;
87  Context& operator=(Context&& other) noexcept;
88 
89  Context(const Context&) = delete;
90  Context& operator=(const Context&) = delete;
91 
97  xvecExecutionContextTag* handle() const noexcept;
98 
105  void setProperty(const std::string& key, const std::string& value);
106 
113  std::string getProperty(const std::string& key) const;
114 
121  std::optional<std::string> tryGetProperty(const std::string& key) const;
122 
132  void resetVpe();
133 
134 private:
135  xvecExecutionContextTag* handle_ = nullptr;
136 };
137 
138 } // namespace xvec
139 
140 #endif // __cplusplus
RAII wrapper for xvecExecutionContextTag.
Context & operator=(Context &&other) noexcept
static uint32_t getNumDevices()
Get the number of available devices.
Context(uint32_t deviceId)
Create an execution context using the embedded production kernel.
Context(Context &&other) noexcept
void setProperty(const std::string &key, const std::string &value)
Set a context property.
Context(const Context &)=delete
void resetVpe()
Reset the VPE SRAM allocator state.
xvecExecutionContextTag * handle() const noexcept
Get the underlying C API handle.
std::string getProperty(const std::string &key) const
Get a context property.
virtual ~Context()
Context & operator=(const Context &)=delete
std::optional< std::string > tryGetProperty(const std::string &key) const
Try to get a context property.
Exception types for C++ XVECTOR wrappers.
Core types, enums, and structures for the XVector library.