🛰️航天仿真算法库 SpaceAST 0.0.1
载入中...
搜索中...
未找到
SpiceApi.hpp
浏览该文件的文档.
1
20
21#pragma once
22
23#include "AstGlobal.h"
24#include <mutex>
25#include <vector>
26#include <string>
27#include <array>
28#include <cstdint>
29
30AST_NAMESPACE_BEGIN
31
41class AST_CORE_API SpiceApi
42{
43public:
44 // 函数索引
45 enum{
46 ifurnsh = 0,
47 ispkgeo,
48 ispklef,
49 ispkuef,
50 iktotal,
51 ibodc2n,
52 ierract,
53 ifailed,
54 ireset,
55 numfunctions,
56 };
57 using funcarray = std::array<void*, numfunctions>;
58
61 static SpiceApi* Instance();
62
64 SpiceApi() = default;
65
67 SpiceApi(bool shouldLoadDynamicLib);
68
69 ~SpiceApi();
70
74 errc_t load(StringView libpath);
75
80 errc_t tryload(const std::vector<std::string>& libpaths);
81
84 errc_t unload();
85
88 bool isLoaded() const { return library_ != nullptr; }
89public: // 包装函数
90
94 errc_t furnsh(const char* libpath);
95
104 errc_t spkgeo(
105 int targ,
106 double et,
107 const char * ref,
108 int obs,
109 double state[6],
110 double * lt
111 );
112
118 errc_t spklef(const char* libpath, int* handle);
119
124 errc_t spkuef(int handle);
125
130 errc_t ktotal(const char * kind, int* count);
131 int ktotal(const char * kind){
132 int count = 0;
133 ktotal(kind, &count);
134 return count;
135 }
136
138 void bodc2n(int code,
139 int namlen,
140 char * name,
141 bool * found);
142 errc_t bodc2n(int code, std::string& name);
143
146 bool failed();
147
149 void reset();
150
153 void erract(const char* operation, int lenout, char* action);
154
155
156
157protected:
158 errc_t checkerror();
159 A_DISABLE_COPY(SpiceApi);
160protected:
161 void* library_{nullptr};
162 std::vector<uint32_t> spk_handles_;
163 funcarray functions_{};
164 std::mutex mutex_;
165};
166
167
168
171AST_NAMESPACE_END
Spice API
定义 SpiceApi.hpp:42
std::mutex mutex_
互斥锁(CSPICE库的函数不是线程安全的,这里用于保护函数调用的线程安全问题)
定义 SpiceApi.hpp:164
std::vector< uint32_t > spk_handles_
已加载的SPK内核句柄列表
定义 SpiceApi.hpp:162
SpiceApi()=default
默认构造函数
bool isLoaded() const
检查是否加载了库
定义 SpiceApi.hpp:88