~ubuntu-branches/ubuntu/wily/flrig/wily

« back to all changes in this revision

Viewing changes to src/xmlrpcpp/XmlRpcSource.h

  • Committer: Package Import Robot
  • Author(s): Kamal Mostafa
  • Date: 2014-06-07 11:28:52 UTC
  • Revision ID: package-import@ubuntu.com-20140607112852-v4d5tb1m3h3vi0dl
Tags: upstream-1.3.15
ImportĀ upstreamĀ versionĀ 1.3.15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
#ifndef _XMLRPCSOURCE_H_
 
3
#define _XMLRPCSOURCE_H_
 
4
//
 
5
// XmlRpc++ Copyright (c) 2002-2008 by Chris Morley
 
6
//
 
7
#if defined(_MSC_VER)
 
8
# pragma warning(disable:4786)    // identifier was truncated in debug info
 
9
#endif
 
10
 
 
11
#include "XmlRpcSocket.h"
 
12
 
 
13
 
 
14
namespace XmlRpc {
 
15
 
 
16
  //! Proxy for Ssl data to avoid including headers here.
 
17
  struct SslProxy;
 
18
 
 
19
  //! An RPC source represents a file descriptor to monitor
 
20
  class XmlRpcSource {
 
21
  public:
 
22
    //! Constructor
 
23
    //!  @param fd The socket file descriptor to monitor.
 
24
    //!  @param deleteOnClose If true, the object deletes itself when close is called.
 
25
    XmlRpcSource(XmlRpcSocket::Socket fd = XmlRpcSocket::Invalid, bool deleteOnClose = false);
 
26
 
 
27
    //! Destructor
 
28
    virtual ~XmlRpcSource();
 
29
 
 
30
    //! Return the file descriptor being monitored.
 
31
    XmlRpcSocket::Socket getfd() const { return _fd; }
 
32
    //! Specify the file descriptor to monitor.
 
33
    void setfd(XmlRpcSocket::Socket fd) { _fd = fd; }
 
34
 
 
35
    //! Return whether the file descriptor should be kept open if it is no longer monitored.
 
36
    bool getKeepOpen() const { return _keepOpen; }
 
37
    //! Specify whether the file descriptor should be kept open if it is no longer monitored.
 
38
    void setKeepOpen(bool b=true) { _keepOpen = b; }
 
39
 
 
40
    //! Return whether ssl is enabled.
 
41
    bool getSslEnabled() const { return _sslEnabled; }
 
42
    //! Specify whether to enable ssl. Use getSslEnabled() to verify that Ssl is available.
 
43
    void setSslEnabled(bool b=true);
 
44
 
 
45
    //! Close the owned fd. If deleteOnClose was specified at construction, the object is deleted.
 
46
    virtual void close();
 
47
 
 
48
    //! Return true to continue monitoring this source
 
49
    virtual unsigned handleEvent(unsigned eventType) = 0;
 
50
 
 
51
  protected:
 
52
 
 
53
    // Execution processing helpers
 
54
    virtual bool doConnect();
 
55
 
 
56
    //! Read text from the source. Returns false on error.
 
57
    bool nbRead(std::string& s, bool *eof);
 
58
 
 
59
    //! Write text to the source. Returns false on error.
 
60
    bool nbWrite(std::string const& s, int *bytesSoFar);
 
61
 
 
62
  private:
 
63
 
 
64
    // Socket. This is an int for linux/unix, and unsigned on win32, and unsigned __int64 on win64.
 
65
    // Casting to int/long/unsigned on win64 is a bad idea.
 
66
    XmlRpcSocket::Socket _fd;
 
67
 
 
68
    // In the server, a new source (XmlRpcServerConnection) is created
 
69
    // for each connected client. When each connection is closed, the
 
70
    // corresponding source object is deleted.
 
71
    bool _deleteOnClose;
 
72
 
 
73
    // In the client, keep connections open if you intend to make multiple calls.
 
74
    bool _keepOpen;
 
75
 
 
76
    // Enable use of SSL
 
77
    bool _sslEnabled;
 
78
 
 
79
    // SSL data
 
80
    SslProxy *_ssl;
 
81
  };
 
82
} // namespace XmlRpc
 
83
 
 
84
#endif //_XMLRPCSOURCE_H_