Astra Linux Directory Client Core API  1.7.0
ald-rpc.h
См. документацию.
1 
6 #ifndef ALD_RPC
7 #define ALD_RPC
8 
12 #define ARPCM_ERROR 0x0
13 #define ARPCM_CALL 0x10
14 #define ARPCM_ECALL 0x11
15 #define ARPCM_RESULT 0x20
16 #define ARPCM_ERESULT 0x21
17 #define ARPCM_LOCAL_REQ 0x30
18 #define ARPCM_LOCAL_RES 0x31
19 #define ARPCM_BROAD_MSG 0x40
20 #define ARPCM_BROAD_RES 0x41
21 
25 #define ALDRPCSERVICE "aldd"
26 
29 #define ALDRPCMAGIC "ALDRPC01"
30 
33 #define ALDRPCVERSION 100
34 
39  char magic[8];
41  unsigned short version;
43  unsigned short message;
45  unsigned long size;
46 };
47 
48 #ifdef __cplusplus
49 
50 #include "common.h"
51 #include "ALDCore.h"
52 #include "gettext.h"
53 
54 using namespace std;
55 
56 namespace ALD
57 {
58 
65 #define ALD_RPC_ITF_NAME "ald-rpc"
66 
68 const size_t ALDRPCHDRSIZE = sizeof(ald_rpc_header);
69 
71 enum alRPCStatus {alrsINI, alrsOK, alrsWAIT, alrsERR};
72 
82  string name;
90  string error;
91 
93  inline bool good() const {return alrsOK == status;}
94 
99  inline void addArg(const string &arg, const string &val){args.insert(make_pair(arg, val));}
100 
105  inline void addRes(const string &res, const string &val){result.insert(make_pair(res, val));}
106 
108  inline void setError(const string &err){error = err;status = alrsERR;}
109 
111  inline string argByName(const string& key){
112  ald_string_multimap::const_iterator it = args.find(key);
113  if(it != args.end())
114  return it->second;
115  else
116  return "";
117  }
118 
120  inline string resByName(const string& key){
121  ald_string_multimap::const_iterator it = result.find(key);
122  if(it != result.end())
123  return it->second;
124  else
125  return "";
126  }
127 
129  inline bool argExists(const string& key){
130  ald_string_multimap::const_iterator it = args.find(key);
131  return (it != args.end());
132  }
133 
135  inline bool resExists(const string& key){
136  ald_string_multimap::const_iterator it = result.find(key);
137  return (it != result.end());
138  }
139 
141  inline void clear(){args.clear(); result.clear();}
142 };
143 
149 {
150 public:
152  virtual ALDAuthType AuthType() = 0;
154  virtual int getTimeout() const = 0;
156  virtual void setTimeout(int timeout) = 0;
157 
163  virtual bool Connect(const string &server, ALDAuthType at) = 0;
165  virtual bool IsConnected() = 0;
167  virtual void Disconnect() = 0;
168 
170  virtual void Call(ald_rpc_request& req) = 0;
172  virtual alRPCStatus CallEx(ald_rpc_request& req) = 0;
173 
175  virtual ~IALDRpcConnection(){}
176 };
177 
179 typedef shared_ptr<IALDRpcConnection> CALDRpcConnPtr;
180 
186 {
187 public:
191  virtual size_t SendBroadcastMessage(const string& msg, ald_string_list *responses, int timeout = 3) = 0;
193  virtual CALDRpcConnPtr getConnection() = 0;
194 };
195 
197 typedef shared_ptr<IALDRpcWrapper> CALDRpcWrapperPtr;
198 
199 } /* ALD */
200 
201 #endif /* ALD_RPC */
202 
203 #endif /* __cplusplus */
204 
string resByName(const string &key)
Definition: ald-rpc.h:120
list< string > ald_string_list
Список строк
Definition: ALDUtils.h:152
Объявление основного интерфейса клиента Astra Linux Directory и необходимых для него типов и интерфей...
IALDRpcWrapper(IALDCore &Core)
Definition: ald-rpc.h:189
shared_ptr< IALDRpcWrapper > CALDRpcWrapperPtr
Definition: ald-rpc.h:197
alRPCStatus status
Definition: ald-rpc.h:88
ald_rpc_header header
Definition: ald-rpc.h:80
#define ALD_RPC_ITF_NAME
Definition: ald-rpc.h:65
string argByName(const string &key)
Definition: ald-rpc.h:111
bool good() const
Definition: ald-rpc.h:93
shared_ptr< IALDRpcConnection > CALDRpcConnPtr
Definition: ald-rpc.h:179
Пространство имен основного интерфейса Astra Linux Directory.
Definition: action-definitions.h:9
void addRes(const string &res, const string &val)
Установка результата
Definition: ald-rpc.h:105
Абстрактный класс-интерфейс RPC соединения с сервером ALD.
Definition: ald-rpc.h:148
STL namespace.
ald_string_multimap result
Definition: ald-rpc.h:86
Базовый класс интерфейса
Definition: ALDCore.h:83
void setError(const string &err)
Definition: ald-rpc.h:108
void clear()
Definition: ald-rpc.h:141
Definition: ald-rpc.h:37
bool resExists(const string &key)
Definition: ald-rpc.h:135
const size_t ALDRPCHDRSIZE
Definition: ald-rpc.h:68
bool SendBroadcastMessage(IALDCore &Core, const string &msg, ald_string_list *responses=NULL, int timeout=3)
Отправка широковещательного сообщения
Структура RPC запроса
Definition: ald-rpc.h:78
unsigned short version
Definition: ald-rpc.h:41
multimap< string, string > ald_string_multimap
MultiMAP строка => строка
Definition: ALDUtils.h:166
char magic[8]
Definition: ald-rpc.h:39
string name
Definition: ald-rpc.h:82
Абстрактный класс-интерфейс RPC взаимодействия с сервером
Definition: ald-rpc.h:185
Основной заголовочный файл, содержащий необходимый минимум предварительных объявлений и включений дру...
alRPCStatus
Definition: ald-rpc.h:71
Конфигурационные определения для подсистемы локализации Gettext.
ald_string_multimap args
Definition: ald-rpc.h:84
void addArg(const string &arg, const string &val)
Установка аргумента
Definition: ald-rpc.h:99
unsigned short message
Definition: ald-rpc.h:43
virtual ~IALDRpcConnection()
Definition: ald-rpc.h:175
unsigned long size
Definition: ald-rpc.h:45
ALDAuthType
Набор способов аутентификации
Definition: ALDCore.h:28
Абстрактный класс IALDCore - основной интерфейс клиента Astra Linux Directory, с помощью которого вып...
Definition: ALDCore.h:241
bool argExists(const string &key)
Definition: ald-rpc.h:129
string error
Definition: ald-rpc.h:90