C++ Client  0.0.0.0
C++ wrapper for Corelink DLL
CorelinkInit.h
Go to the documentation of this file.
1 
5 #ifndef CORELINKINIT_H
6 #define CORELINKINIT_H
7 #pragma once
8 
9 #include "CorelinkConst.h"
10 #include "CorelinkClasses.h"
11 #include "CorelinkException.h"
12 
13 namespace Corelink {
14  inline void DLLInit::Init() {
15  CorelinkDLL::DLLInit();
16  CorelinkDLL::setDroppedCallbackHandler(nullptr);
17  CorelinkDLL::setStaleCallbackHandler(nullptr);
18  CorelinkDLL::setSubscribeCallbackHandler(nullptr);
19  CorelinkDLL::setUpdateCallbackHandler(nullptr);
20  }
21 
22  inline int DLLInit::getInitState() {
23  return CorelinkDLL::getInitState();
24  }
25 
26  inline void DLLInit::setInitState(int state) {
27  int errorID;
28  CorelinkDLL::setInitState(state, errorID);
29  CorelinkException::GetDLLException(errorID);
30  }
31 
32  inline std::string DLLInit::getLocalCertPath() {
33  char* data;
34  std::string path;
35  int len;
36  #ifdef WRAPPER_ALLOC
37  len = CorelinkDLL::getInitLocalCertPathLen();
38  if (len == 0) { return ""; }
39  data = new char[len];
40  CorelinkDLL::getInitLocalCertPathStr(data);
41  path = std::string(data, len);
42  delete[] data;
43  return path;
44  #else
45  data = CorelinkDLL::getInitLocalCertPath(len);
46  path = std::string(data, len);
47  CorelinkDLL::freeData(data);
48  return path;
49  #endif
50  }
51 
52  inline void DLLInit::setLocalCertPath(const char* path, int len) {
53  CorelinkDLL::setInitLocalCertPath(path, len);
54  }
55 
56  inline void DLLInit::setLocalCertPath(const std::string& path) {
57  setLocalCertPath(path.c_str(), (int) path.size());
58  }
59 
60  inline std::string DLLInit::getServerCertPath() {
61  char* data;
62  std::string path;
63  int len;
64  #ifdef WRAPPER_ALLOC
65  len = CorelinkDLL::getInitServerCertPathLen();
66  if (len == 0) { return ""; }
67  data = new char[len];
68  CorelinkDLL::getInitServerCertPathStr(data);
69  path = std::string(data, len);
70  delete[] data;
71  return path;
72  #else
73  data = CorelinkDLL::getInitServerCertPath(len);
74  path = std::string(data, len);
75  CorelinkDLL::freeData(data);
76  return path;
77  #endif
78  }
79 
80  inline void DLLInit::setServerCertPath(const char* path, int len) {
81  CorelinkDLL::setInitServerCertPath(path, len);
82  }
83 
84  inline void DLLInit::setServerCertPath(const std::string& path) {
85  setServerCertPath(path.c_str(), (int)path.size());
86  }
87 
88  inline void DLLInit::setServerCredentials(const std::string& username, const std::string& password) {
89  CorelinkDLL::setServerCredentials(username.c_str(), password.c_str());
90  }
91 
92  inline void DLLInit::setOnDrop(void(*func)(const STREAM_ID&)) {
93  CorelinkDLL::setDroppedCallbackHandler(func);
94  }
95 
96  inline void DLLInit::setOnStale(void(*func)(const STREAM_ID&)) {
97  CorelinkDLL::setStaleCallbackHandler(func);
98  }
99 
100  inline void DLLInit::setOnSubscribe(void(*func)(const STREAM_ID&, const STREAM_ID&)) {
101  CorelinkDLL::setSubscribeCallbackHandler(func);
102  }
103 
104  inline void DLLInit::setOnUpdate(void(*func)(const STREAM_ID&, const STREAM_ID&)) {
105  CorelinkDLL::setUpdateCallbackHandler(func);
106  }
107 }
108 #endif