Instrument Neutral Distributed Interface INDI  1.9.2
baseclient_p.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <vector>
4 #include <map>
5 #include <list>
6 #include <mutex>
7 #include <condition_variable>
8 #include <atomic>
9 #include <string>
10 #include <set>
11 #include <thread>
12 #include <cstdint>
13 
14 #include <lilxml.h>
15 
16 #ifdef _WINDOWS
17 #if defined(_MSC_VER)
18 #include <BaseTsd.h>
19 typedef SSIZE_T ssize_t;
20 #endif
21 #endif
22 
23 namespace INDI
24 {
25 
26 class BaseDevice;
27 
28 struct BLOBMode
29 {
30  std::string device;
31  std::string property;
33 };
34 
36 {
37  public:
39  virtual ~BaseClientPrivate();
40 
41  public:
42  bool connect();
43  bool disconnect(int exit_code);
44 
50  void setDriverConnection(bool status, const char *deviceName);
51 
52  size_t sendData(const void *data, size_t size);
53  void sendString(const char *fmt, ...);
54 
55  public:
56  void listenINDI();
58  void clear();
59 
60  public:
61  BLOBMode *findBLOBMode(const std::string &device, const std::string &property);
62 
63  public:
65  int dispatchCommand(XMLEle *root, char *errmsg);
66 
68  int deleteDevice(const char *devName, char *errmsg);
69 
71  int delPropertyCmd(XMLEle *root, char *errmsg);
72 
74  INDI::BaseDevice *findDev(const char *devName, char *errmsg);
76  INDI::BaseDevice *addDevice(XMLEle *dep, char *errmsg);
78  INDI::BaseDevice *findDev(XMLEle *root, int create, char *errmsg);
79 
81  int messageCmd(XMLEle *root, char *errmsg);
82 
83  public:
85 
86 #ifdef _WINDOWS
87  SOCKET sockfd;
88 #else
89  int sockfd {-1};
90  int receiveFd {-1};
91  int sendFd {-1};
92 #endif
93 
94  std::vector<INDI::BaseDevice *> cDevices;
95  std::set<std::string> cDeviceNames;
96  std::list<BLOBMode> blobModes;
97  std::map<std::string, std::set<std::string>> cWatchProperties;
98 
99  std::string cServer;
100  uint32_t cPort;
101  std::atomic_bool sConnected;
102  std::atomic_bool sAboutToClose;
103  std::mutex sSocketBusy;
104  std::condition_variable sSocketChanged;
106  bool verbose;
107 
108  // Parse & FILE buffers for IO
109 
111 };
112 
113 }
INDI::BaseClientPrivate::sendFd
int sendFd
Definition: baseclient_p.h:91
INDI::BaseClientPrivate::dispatchCommand
int dispatchCommand(XMLEle *root, char *errmsg)
Dispatch command received from INDI server to respective devices handled by the client.
Definition: baseclient.cpp:520
INDI::BaseClientPrivate::receiveFd
int receiveFd
Definition: baseclient_p.h:90
INDI::BaseClientPrivate::sSocketBusy
std::mutex sSocketBusy
Definition: baseclient_p.h:103
INDI::BaseClientPrivate::sockfd
int sockfd
Definition: baseclient_p.h:89
INDI::BaseClientPrivate::sendData
size_t sendData(const void *data, size_t size)
Definition: baseclient.cpp:488
INDI::BaseClientPrivate::verbose
bool verbose
Definition: baseclient_p.h:106
INDI::BaseClientPrivate::cPort
uint32_t cPort
Definition: baseclient_p.h:100
INDI::BaseClientPrivate::timeout_sec
uint32_t timeout_sec
Definition: baseclient_p.h:110
INDI::BaseClientPrivate::cDeviceNames
std::set< std::string > cDeviceNames
Definition: baseclient_p.h:95
INDI::BaseClientPrivate::connect
bool connect()
Definition: baseclient.cpp:135
INDI::BaseClientPrivate::findDev
INDI::BaseDevice * findDev(const char *devName, char *errmsg)
Find and return a particular device.
Definition: baseclient.cpp:647
INDI::BaseClientPrivate::listenINDI
void listenINDI()
Definition: baseclient.cpp:324
INDI::BaseClientPrivate::sConnected
std::atomic_bool sConnected
Definition: baseclient_p.h:101
INDI::BaseClientPrivate
Definition: baseclient_p.h:35
INDI::BaseClientPrivate::timeout_us
uint32_t timeout_us
Definition: baseclient_p.h:110
device
hid_device * device
Definition: activefocuser_utils.cpp:92
INDI::BaseClientPrivate::BaseClientPrivate
BaseClientPrivate(BaseClient *parent)
Definition: baseclient.cpp:75
INDI::BaseClientPrivate::cWatchProperties
std::map< std::string, std::set< std::string > > cWatchProperties
Definition: baseclient_p.h:97
INDI::BaseClientPrivate::parent
BaseClient * parent
Definition: baseclient_p.h:84
INDI::BaseClientPrivate::delPropertyCmd
int delPropertyCmd(XMLEle *root, char *errmsg)
Delete property command.
Definition: baseclient.cpp:608
INDI::BaseClientPrivate::findBLOBMode
BLOBMode * findBLOBMode(const std::string &device, const std::string &property)
Definition: baseclient.cpp:771
INDI::BaseClientPrivate::cDevices
std::vector< INDI::BaseDevice * > cDevices
Definition: baseclient_p.h:94
INDI::BaseClientPrivate::messageCmd
int messageCmd(XMLEle *root, char *errmsg)
Definition: baseclient.cpp:727
INDI::BaseClientPrivate::cServer
std::string cServer
Definition: baseclient_p.h:99
xml_ele_
Definition: lilxml.c:105
BLOBHandling
BLOBHandling
How drivers handle BLOBs incoming from snooping drivers.
Definition: indidevapi.h:268
INDI::BaseClientPrivate::disconnect
bool disconnect(int exit_code)
Definition: baseclient.cpp:295
lilxml.h
A little DOM-style library to handle parsing and processing an XML file.
INDI::BaseClientPrivate::blobModes
std::list< BLOBMode > blobModes
Definition: baseclient_p.h:96
INDI::BLOBMode::property
std::string property
Definition: baseclient_p.h:31
INDI::BaseClient
Class to provide basic client functionality.
Definition: baseclient.h:54
INDI::BaseClientPrivate::~BaseClientPrivate
virtual ~BaseClientPrivate()
Definition: baseclient.cpp:99
INDI::BLOBMode::device
std::string device
Definition: baseclient_p.h:30
INDI::BaseClientPrivate::sendString
void sendString(const char *fmt,...)
Definition: baseclient.cpp:509
INDI::BaseClientPrivate::sExitCode
int sExitCode
Definition: baseclient_p.h:105
INDI::BaseClientPrivate::clear
void clear()
clear Clear devices and blob modes
Definition: baseclient.cpp:123
INDI
Namespace to encapsulate INDI client, drivers, and mediator classes.
Definition: AlignmentSubsystemForClients.cpp:11
INDI::BaseClientPrivate::sSocketChanged
std::condition_variable sSocketChanged
Definition: baseclient_p.h:104
INDI::BaseClientPrivate::addDevice
INDI::BaseDevice * addDevice(XMLEle *dep, char *errmsg)
Add a new device.
Definition: baseclient.cpp:662
INDI::BLOBMode
Definition: baseclient_p.h:28
INDI::BaseClientPrivate::sAboutToClose
std::atomic_bool sAboutToClose
Definition: baseclient_p.h:102
INDI::BaseClientPrivate::deleteDevice
int deleteDevice(const char *devName, char *errmsg)
Remove device.
Definition: baseclient.cpp:583
INDI::BLOBMode::blobMode
BLOBHandling blobMode
Definition: baseclient_p.h:32
INDI::BaseClientPrivate::setDriverConnection
void setDriverConnection(bool status, const char *deviceName)
Connect/Disconnect to INDI driver.
Definition: baseclient.cpp:782
INDI::BaseDevice
Class to provide basic INDI device functionality.
Definition: basedevice.h:45