🛰️航天仿真算法库 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
44class AST_CORE_API SpiceAPI
45{
46public:
47 // 函数索引
48 enum{
49 ifurnsh = 0,
50 ispkgeo,
51 ispklef,
52 ispkuef,
53 iktotal,
54 ibodc2n,
55 ierract,
56 ifailed,
57 ireset,
58 ikclear,
59 numfunctions,
60 };
61 using funcarray = std::array<void*, numfunctions>;
62
65 static SpiceAPI* Instance();
66
68 SpiceAPI() = default;
69
71 explicit SpiceAPI(bool shouldLoadDynamicLib);
72
73 ~SpiceAPI();
74
78 errc_t load(StringView libpath);
79
84 errc_t tryload(const std::vector<std::string>& libpaths);
85
88 errc_t unload();
89
92 bool isLoaded() const { return library_ != nullptr; }
93public: // 包装函数
94
98 errc_t furnsh(const char* file);
99
108 errc_t spkgeo(
109 int targ,
110 double et,
111 const char * ref,
112 int obs,
113 double state[6],
114 double * lt
115 );
116
122 errc_t spklef(const char* filename, int* handle);
123
128 errc_t spkuef(int handle);
129
134 errc_t ktotal(const char * kind, int* count);
135 int ktotal(const char * kind){
136 int count = 0;
137 ktotal(kind, &count);
138 return count;
139 }
140
142 void bodc2n(int code,
143 int namlen,
144 char * name,
145 bool * found);
146 errc_t bodc2n(int code, std::string& name);
147
150 bool failed();
151
153 void reset();
154
157 void erract(const char* operation, int lenout, char* action);
158
160 void kclear();
161protected:
162 errc_t checkerror();
163 A_DISABLE_COPY(SpiceAPI);
164protected:
165 void* library_{nullptr};
166 std::vector<uint32_t> spk_handles_;
167 funcarray functions_{};
168 std::mutex mutex_;
169};
170
171
172
175AST_NAMESPACE_END
Spice API
定义 SpiceAPI.hpp:45
SpiceAPI()=default
默认构造函数
std::vector< uint32_t > spk_handles_
已加载的SPK内核句柄列表
定义 SpiceAPI.hpp:166
std::mutex mutex_
互斥锁(CSPICE库的函数不是线程安全的,这里用于保护函数调用的线程安全问题)
定义 SpiceAPI.hpp:168
bool isLoaded() const
检查是否加载了库
定义 SpiceAPI.hpp:92