cisst-saw
Loading...
Searching...
No Matches
mtsSocketProxyClient.h
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
3
4/*
5 Author(s): Peter Kazanzides
6 Created on: 2013-08-06
7
8 (C) Copyright 2013-2026 Johns Hopkins University (JHU), All Rights Reserved.
9
10--- begin cisst license - do not edit ---
11
12This software is provided "as is" under an open source license, with
13no warranty. The complete license can be found in license.txt and
14http://www.cisst.org/cisst/license.txt.
15
16--- end cisst license ---
17*/
18
19
25
26#ifndef _mtsSocketProxyClient_h
27#define _mtsSocketProxyClient_h
28
31
34
35class CommandWrapperBase;
36
38
40{
41 CMN_DECLARE_SERVICES(CMN_DYNAMIC_CREATION, CMN_LOG_ALLOW_DEFAULT);
42public:
43 std::string Name;
44 std::string IP;
45 short Port;
46
48 mtsSocketProxyClientConstructorArg(const std::string &name, const std::string &ip, short port) :
49 mtsGenericObject(), Name(name), IP(ip), Port(port) {}
53
54 void SerializeRaw(std::ostream & outputStream) const override;
55 void DeSerializeRaw(std::istream & inputStream) override;
56
57 void ToStream(std::ostream & outputStream) const override;
58
60 void ToStreamRaw(std::ostream & outputStream, const char delimiter = ' ',
61 bool headerOnly = false, const std::string & headerPrefix = "") const override;
62
65 bool FromStreamRaw(std::istream & inputStream, const char delimiter = ' ') override;
66};
67
69
71{
73
74 protected:
75
77 mtsProxySerializer *Serializer;
78
80
81 // For memory cleanup
82 std::vector<mtsCommandBase *> EventGenerators;
83
87 // Returns false if timed out
88 bool WaitForResponse(double timeoutInSec);
89
94 bool CreateClientProxy(const std::string & providedInterfaceName);
95
96 // For use by MulticastCommandVoidProxy and MulticastCommandWriteProxy
99 void EventEnable(const std::string &eventName, const char *handle);
100 void EventDisable(const std::string &eventName, const char *handle);
101
102 void CheckForEvents(double timeoutInSec);
103
104 friend class CommandWrapperBase;
107
108 public:
114 mtsSocketProxyClient(const std::string &name, const std::string &ip, short port);
115
117
118
121
122 void Configure(const std::string &) override {}
123
124 void Startup(void) override;
125
126 void Run(void) override;
127
128 void Cleanup(void) override;
129
130 // Following used by command wrappers
131 bool CheckForEventsImmediate(double timeoutInSec);
132 bool Serialize(const mtsGenericObject & originalObject, std::string & serializedObject);
133 bool DeSerialize(const std::string & serializedObject, mtsGenericObject & originalObject);
134 mtsGenericObject * DeSerialize(const std::string & serializedObject);
135};
136
138
139#endif // _mtsSocketProxyClient_h
Definition mtsCommandWriteBase.h:40
Base class for data object in cisstMultiTask.
Definition mtsGenericObject.h:52
mtsGenericObject(void)
Definition mtsGenericObject.h:77
Definition mtsSocketProxyClient.h:40
bool FromStreamRaw(std::istream &inputStream, const char delimiter=' ') override
void ToStream(std::ostream &outputStream) const override
void SerializeRaw(std::ostream &outputStream) const override
void ToStreamRaw(std::ostream &outputStream, const char delimiter=' ', bool headerOnly=false, const std::string &headerPrefix="") const override
std::string Name
Definition mtsSocketProxyClient.h:43
mtsSocketProxyClientConstructorArg(const mtsSocketProxyClientConstructorArg &other)
Definition mtsSocketProxyClient.h:50
~mtsSocketProxyClientConstructorArg()
Definition mtsSocketProxyClient.h:52
std::string IP
Definition mtsSocketProxyClient.h:44
mtsSocketProxyClientConstructorArg(const std::string &name, const std::string &ip, short port)
Definition mtsSocketProxyClient.h:48
short Port
Definition mtsSocketProxyClient.h:45
void DeSerializeRaw(std::istream &inputStream) override
mtsSocketProxyClientConstructorArg()
Definition mtsSocketProxyClient.h:47
Definition mtsSocketProxyClient.h:71
void Startup(void) override
std::vector< mtsCommandBase * > EventGenerators
Definition mtsSocketProxyClient.h:82
friend class CommandWrapperBase
Definition mtsSocketProxyClient.h:104
void Configure(const std::string &) override
Definition mtsSocketProxyClient.h:122
bool CheckForEventsImmediate(double timeoutInSec)
void CheckForEvents(double timeoutInSec)
void EventDisable(const std::string &eventName, const char *handle)
friend class MulticastCommandVoidProxy
Definition mtsSocketProxyClient.h:105
osaSocket Socket
Definition mtsSocketProxyClient.h:76
mtsProxySerializer * Serializer
Definition mtsSocketProxyClient.h:77
friend class MulticastCommandWriteProxy
Definition mtsSocketProxyClient.h:106
mtsCommandWriteBase * localUnblockingCommand
Definition mtsSocketProxyClient.h:85
bool Serialize(const mtsGenericObject &originalObject, std::string &serializedObject)
void EventEnable(const std::string &eventName, const char *handle)
void LocalUnblockingHandler(const mtsGenericObject &arg)
void Cleanup(void) override
mtsSocketProxyClient(const std::string &name, const std::string &ip, short port)
mtsCommandWriteBase * EventEnableCommand
Definition mtsSocketProxyClient.h:97
mtsSocketProxyInitData ServerData
Definition mtsSocketProxyClient.h:79
bool DeSerialize(const std::string &serializedObject, mtsGenericObject &originalObject)
mtsCommandWriteBase * EventDisableCommand
Definition mtsSocketProxyClient.h:98
void Run(void) override
mtsSocketProxyClient(const mtsSocketProxyClientConstructorArg &arg)
bool CreateClientProxy(const std::string &providedInterfaceName)
Create client proxy.
bool LocalWaiting
Definition mtsSocketProxyClient.h:84
virtual ~mtsSocketProxyClient()
bool WaitForResponse(double timeoutInSec)
mtsGenericObject * DeSerialize(const std::string &serializedObject)
Definition mtsSocketProxyCommon.h:79
mtsTaskContinuous(const std::string &name, unsigned int sizeStateTable=256, bool newThread=true)
Definition osaSocket.h:175
const int CMN_DYNAMIC_CREATION_ONEARG
Definition cmnClassRegisterMacros.h:330
#define CMN_DECLARE_SERVICES_INSTANTIATION(className)
Definition cmnClassRegisterMacros.h:199
const int CMN_DYNAMIC_CREATION
Definition cmnClassRegisterMacros.h:328
#define CISST_EXPORT
Definition cmnExportMacros.h:50
#define CMN_LOG_ALLOW_DEFAULT
Definition cmnLogLoD.h:76
Rules of exporting.
Forward declarations and #define for cisstMultiTask.
Common definitions for mtsSocketProxyClient and mtsSocketProxyServer.
Defines a continuously executing task.
Declaration of osaSocket.