123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295 |
- /***********************************************************
- * File generated by the HALCON-Compiler hcomp version 20.11
- * Usage: Interface to C++
- *
- * Software by: MVTec Software GmbH, www.mvtec.com
- ***********************************************************/
- #ifndef HCPP_HSOCKET
- #define HCPP_HSOCKET
- namespace HalconCpp
- {
- // Represents an instance of a socket connection.
- class LIntExport HSocket : public HHandle
- {
- public:
- // Create an uninitialized instance
- HSocket():HHandle() {}
- // Copy constructor
- HSocket(const HSocket& source) : HHandle(source) {}
- // Copy constructor
- HSocket(const HHandle& handle);
- // Create HSocket from handle, taking ownership
- explicit HSocket(Hlong handle);
- bool operator==(const HHandle& obj) const
- {
- return HHandleBase::operator==(obj);
- }
- bool operator!=(const HHandle& obj) const
- {
- return HHandleBase::operator!=(obj);
- }
- protected:
- // Verify matching semantic type ('socket')!
- virtual void AssertType(Hphandle handle) const;
- public:
- /*****************************************************************************
- * Operator-based class constructors
- *****************************************************************************/
- // open_socket_connect: Open a socket and connect it to an accepting socket.
- explicit HSocket(const HString& HostName, Hlong Port, const HTuple& GenParamName, const HTuple& GenParamValue);
- // open_socket_connect: Open a socket and connect it to an accepting socket.
- explicit HSocket(const HString& HostName, Hlong Port, const HString& GenParamName, const HString& GenParamValue);
- // open_socket_connect: Open a socket and connect it to an accepting socket.
- explicit HSocket(const char* HostName, Hlong Port, const char* GenParamName, const char* GenParamValue);
- #ifdef _WIN32
- // open_socket_connect: Open a socket and connect it to an accepting socket.
- explicit HSocket(const wchar_t* HostName, Hlong Port, const wchar_t* GenParamName, const wchar_t* GenParamValue);
- #endif
- // open_socket_accept: Open a socket that accepts connection requests.
- explicit HSocket(Hlong Port, const HTuple& GenParamName, const HTuple& GenParamValue);
- // open_socket_accept: Open a socket that accepts connection requests.
- explicit HSocket(Hlong Port, const HString& GenParamName, const HString& GenParamValue);
- // open_socket_accept: Open a socket that accepts connection requests.
- explicit HSocket(Hlong Port, const char* GenParamName, const char* GenParamValue);
- #ifdef _WIN32
- // open_socket_accept: Open a socket that accepts connection requests.
- explicit HSocket(Hlong Port, const wchar_t* GenParamName, const wchar_t* GenParamValue);
- #endif
- /***************************************************************************
- * Operators *
- ***************************************************************************/
- // Receive an image over a socket connection.
- HImage ReceiveImage() const;
- // Send an image over a socket connection.
- void SendImage(const HImage& Image) const;
- // Receive regions over a socket connection.
- HRegion ReceiveRegion() const;
- // Send regions over a socket connection.
- void SendRegion(const HRegion& Region) const;
- // Receive an XLD object over a socket connection.
- HXLD ReceiveXld() const;
- // Send an XLD object over a socket connection.
- void SendXld(const HXLD& XLD) const;
- // Receive a tuple over a socket connection.
- HTuple ReceiveTuple() const;
- // Send a tuple over a socket connection.
- void SendTuple(const HTuple& Tuple) const;
- // Send a tuple over a socket connection.
- void SendTuple(const HString& Tuple) const;
- // Send a tuple over a socket connection.
- void SendTuple(const char* Tuple) const;
- #ifdef _WIN32
- // Send a tuple over a socket connection.
- void SendTuple(const wchar_t* Tuple) const;
- #endif
- // Receive arbitrary data from external devices or applications using a generic socket connection.
- HTuple ReceiveData(const HTuple& Format, HTuple* From) const;
- // Receive arbitrary data from external devices or applications using a generic socket connection.
- HTuple ReceiveData(const HString& Format, HString* From) const;
- // Receive arbitrary data from external devices or applications using a generic socket connection.
- HTuple ReceiveData(const char* Format, HString* From) const;
- #ifdef _WIN32
- // Receive arbitrary data from external devices or applications using a generic socket connection.
- HTuple ReceiveData(const wchar_t* Format, HString* From) const;
- #endif
- // Send arbitrary data to external devices or applications using a generic socket communication.
- void SendData(const HString& Format, const HTuple& Data, const HTuple& To) const;
- // Send arbitrary data to external devices or applications using a generic socket communication.
- void SendData(const HString& Format, const HString& Data, const HString& To) const;
- // Send arbitrary data to external devices or applications using a generic socket communication.
- void SendData(const char* Format, const char* Data, const char* To) const;
- #ifdef _WIN32
- // Send arbitrary data to external devices or applications using a generic socket communication.
- void SendData(const wchar_t* Format, const wchar_t* Data, const wchar_t* To) const;
- #endif
- // Get the value of a socket parameter.
- HTuple GetSocketParam(const HTuple& GenParamName) const;
- // Get the value of a socket parameter.
- HTuple GetSocketParam(const HString& GenParamName) const;
- // Get the value of a socket parameter.
- HTuple GetSocketParam(const char* GenParamName) const;
- #ifdef _WIN32
- // Get the value of a socket parameter.
- HTuple GetSocketParam(const wchar_t* GenParamName) const;
- #endif
- // Set a socket parameter.
- void SetSocketParam(const HTuple& GenParamName, const HTuple& GenParamValue) const;
- // Set a socket parameter.
- void SetSocketParam(const HString& GenParamName, const HString& GenParamValue) const;
- // Set a socket parameter.
- void SetSocketParam(const char* GenParamName, const char* GenParamValue) const;
- #ifdef _WIN32
- // Set a socket parameter.
- void SetSocketParam(const wchar_t* GenParamName, const wchar_t* GenParamValue) const;
- #endif
- // Determine the HALCON data type of the next socket data.
- HString GetNextSocketDataType() const;
- // Get the socket descriptor of a socket used by the operating system.
- Hlong GetSocketDescriptor() const;
- // This operator is inoperable. It had the following function: Close all opened sockets.
- static void CloseAllSockets();
- // Close a socket.
- void CloseSocket() const;
- // Accept a connection request on a listening socket of the protocol type 'HALCON' or 'TCP'/'TCP4'/'TCP6'.
- HSocket SocketAcceptConnect(const HString& Wait) const;
- // Accept a connection request on a listening socket of the protocol type 'HALCON' or 'TCP'/'TCP4'/'TCP6'.
- HSocket SocketAcceptConnect(const char* Wait) const;
- #ifdef _WIN32
- // Accept a connection request on a listening socket of the protocol type 'HALCON' or 'TCP'/'TCP4'/'TCP6'.
- HSocket SocketAcceptConnect(const wchar_t* Wait) const;
- #endif
- // Open a socket and connect it to an accepting socket.
- void OpenSocketConnect(const HString& HostName, Hlong Port, const HTuple& GenParamName, const HTuple& GenParamValue);
- // Open a socket and connect it to an accepting socket.
- void OpenSocketConnect(const HString& HostName, Hlong Port, const HString& GenParamName, const HString& GenParamValue);
- // Open a socket and connect it to an accepting socket.
- void OpenSocketConnect(const char* HostName, Hlong Port, const char* GenParamName, const char* GenParamValue);
- #ifdef _WIN32
- // Open a socket and connect it to an accepting socket.
- void OpenSocketConnect(const wchar_t* HostName, Hlong Port, const wchar_t* GenParamName, const wchar_t* GenParamValue);
- #endif
- // Open a socket that accepts connection requests.
- void OpenSocketAccept(Hlong Port, const HTuple& GenParamName, const HTuple& GenParamValue);
- // Open a socket that accepts connection requests.
- void OpenSocketAccept(Hlong Port, const HString& GenParamName, const HString& GenParamValue);
- // Open a socket that accepts connection requests.
- void OpenSocketAccept(Hlong Port, const char* GenParamName, const char* GenParamValue);
- #ifdef _WIN32
- // Open a socket that accepts connection requests.
- void OpenSocketAccept(Hlong Port, const wchar_t* GenParamName, const wchar_t* GenParamValue);
- #endif
- // Receive a serialized item over a socket connection.
- HSerializedItem ReceiveSerializedItem() const;
- // Send a serialized item over a socket connection.
- void SendSerializedItem(const HSerializedItem& SerializedItemHandle) const;
- };
- // forward declarations and types for internal array implementation
- template<class T> class HSmartPtr;
- template<class T> class HHandleBaseArrayRef;
- typedef HHandleBaseArrayRef<HSocket> HSocketArrayRef;
- typedef HSmartPtr< HSocketArrayRef > HSocketArrayPtr;
- // Represents multiple tool instances
- class LIntExport HSocketArray : public HHandleBaseArray
- {
- public:
- // Create empty array
- HSocketArray();
- // Create array from native array of tool instances
- HSocketArray(HSocket* classes, Hlong length);
- // Copy constructor
- HSocketArray(const HSocketArray &tool_array);
- // Destructor
- virtual ~HSocketArray();
- // Assignment operator
- HSocketArray &operator=(const HSocketArray &tool_array);
- // Clears array and all tool instances
- virtual void Clear();
- // Get array of native tool instances
- const HSocket* Tools() const;
- // Get number of tools
- virtual Hlong Length() const;
- // Create tool array from tuple of handles
- virtual void SetFromTuple(const HTuple& handles);
- // Get tuple of handles for tool array
- virtual HTuple ConvertToTuple() const;
- protected:
- // Smart pointer to internal data container
- HSocketArrayPtr *mArrayPtr;
- };
- }
- #endif
|