Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0c25fd4

Browse filesBrowse files
committed
doc: small improvements
1 parent e71b8d7 commit 0c25fd4
Copy full SHA for 0c25fd4

File tree

Expand file treeCollapse file tree

7 files changed

+564
-83
lines changed
Filter options
Expand file treeCollapse file tree

7 files changed

+564
-83
lines changed

‎doc/Doxyfile

Copy file name to clipboardExpand all lines: doc/Doxyfile
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,7 @@ RECURSIVE = YES
772772
# run.
773773

774774
EXCLUDE = "../include/rpc/msgpack"
775+
EXCLUDE += "../include/rpc/nonstd"
775776

776777
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
777778
# directories that are symbolic links (a Unix file system feature) are excluded

‎doc/pages/reference.md

Copy file name to clipboardExpand all lines: doc/pages/reference.md
+60-11Lines changed: 60 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ Use this class to connect to msgpack-rpc servers and call their exposed function
3333
| RPCLIB_MSGPACK::object_handle | [call](#classrpc_1_1client_1aedc166b5a80820be198ef134f522b049)(std::string const &func_name, Args... args)
3434
| std::future< RPCLIB_MSGPACK::object_handle > | [async_call](#classrpc_1_1client_1a2e3702a314c8c0a00bfac652b82d16cc)(std::string const &func_name, Args... args)
3535
| void | [send](#classrpc_1_1client_1a5f5ad1d1d0630178a51ae219cd831b44)(std::string const &func_name, Args... args)
36-
| uint64_t | [get_timeout](#classrpc_1_1client_1a7976c427e3e0a87a15931737df624712)() const
37-
| void | [set_timeout](#classrpc_1_1client_1adc950350ae3c955c38fe18d16a6fd6af)(uint64_t value)
36+
| nonstd::optional< int64_t > | [get_timeout](#classrpc_1_1client_1a2c264af4d7169574452b9f968ffde87d)() const
37+
| void | [set_timeout](#classrpc_1_1client_1af890e3067745861642e2ba1a65bebce6)(int64_t value)
38+
| void | [clear_timeout](#classrpc_1_1client_1a89eeffaf87bf0470a65c9c8ca40562bb)()
3839
| connection_state | [get_connection_state](#classrpc_1_1client_1a710037bce0d9b80127a98eb6cd54caf1)() const
3940
| void | [wait_all_responses](#classrpc_1_1client_1ac37437bc05b70588c079079b957eb15f)()
4041

@@ -128,9 +129,9 @@ Notifications are a special kind of calls. They can be used to notify the server
128129
!!! warn
129130
This function returns immediately (possibly before the notification is written to the socket).
130131

131-
<h4 id="classrpc_1_1client_1a7976c427e3e0a87a15931737df624712" class="doxy">rpc::client::get_timeout</h4>
132+
<h4 id="classrpc_1_1client_1a2c264af4d7169574452b9f968ffde87d" class="doxy">rpc::client::get_timeout</h4>
132133
```cpp
133-
uint64_t rpc::client::get_timeout() const;
134+
nonstd::optional< int64_t > rpc::client::get_timeout() const;
134135
```
135136

136137
Returns the timeout setting of this client in milliseconds.
@@ -141,14 +142,22 @@ The timeout is applied to synchronous calls. If the timeout expires without rece
141142
!!! warn
142143
The timeout has no effect on async calls. For those, the preferred timeout mechanism remains using std::future.
143144

144-
<h4 id="classrpc_1_1client_1adc950350ae3c955c38fe18d16a6fd6af" class="doxy">rpc::client::set_timeout</h4>
145+
<h4 id="classrpc_1_1client_1af890e3067745861642e2ba1a65bebce6" class="doxy">rpc::client::set_timeout</h4>
145146
```cpp
146-
void rpc::client::set_timeout(uint64_t value);
147+
void rpc::client::set_timeout(int64_t value);
147148
```
148149

149150
Sets the timeout for synchronous calls. For more information, see
150151

151152

153+
<h4 id="classrpc_1_1client_1a89eeffaf87bf0470a65c9c8ca40562bb" class="doxy">rpc::client::clear_timeout</h4>
154+
```cpp
155+
void rpc::client::clear_timeout();
156+
```
157+
158+
Clears the timeout for synchronous calls. For more information, see
159+
160+
152161
<h4 id="classrpc_1_1client_1a710037bce0d9b80127a98eb6cd54caf1" class="doxy">rpc::client::get_connection_state</h4>
153162
```cpp
154163
connection_state rpc::client::get_connection_state() const;
@@ -211,15 +220,17 @@ Returns the error object that the server provided.
211220

212221
Implements a msgpack-rpc server. This is the main interfacing point with the library for creating servers.
213222

214-
The server maintains a registry of function bindings that it uses to dispatch calls. It also takes care of managing worker threads and TCP connections. The server does not start listening right after construction in order to allow binding functions before that. Use the `run` or `async_run` functions to start listening on the port.
223+
The server maintains a registry of function bindings that it uses to dispatch calls. It also takes care of managing worker threads and TCP connections. The server does not start listening right after construction in order to allow binding functions before that. Use the `run` or `async_run` functions to start listening on the port. This class is not copyable, but moveable.
215224

216225
### Public functions
217226

218227
| | |
219228
|---------|-------------|
220229
| | [server](#classrpc_1_1server_1ac406b44f73cf2ff17240c0cd926a9c1e)(uint16_t port)
230+
| | [server](#classrpc_1_1server_1a744b961d3b151b3449a4e0da37bd471a)(server &&other) noexcept
221231
| | [server](#classrpc_1_1server_1ad71ffce076d752e116cefa3672e5d188)(std::string const &address, uint16_t port)
222232
| | [~server](#classrpc_1_1server_1a20b9197e5ef1a22371e6fbdb7f58b330)()
233+
| server | [operator=](#classrpc_1_1server_1ac3cf4848fc3969cd26ba5e3bd2dc411b)(server &&other)
223234
| void | [run](#classrpc_1_1server_1a981d7e4a08d04d05cbac6770fab0dff8)()
224235
| void | [async_run](#classrpc_1_1server_1a462e032fa21cad78eeacc27da103a2b7)(std::size_t worker_threads=1)
225236
| void | [bind](#classrpc_1_1server_1a072135629430df6d5576416806f7b02c)(std::string const &name, F func)
@@ -239,6 +250,17 @@ Constructs a server that listens on the localhost on the specified port.
239250
`port` The port number to listen on.
240251

241252

253+
<h4 id="classrpc_1_1server_1a744b961d3b151b3449a4e0da37bd471a" class="doxy">rpc::server::server</h4>
254+
```cpp
255+
rpc::server::server(server &&other) noexcept;
256+
```
257+
258+
Move constructor. This is implemented by calling the move assignment operator.
259+
260+
##### Parameters
261+
`other` The other instance to move from.
262+
263+
242264
<h4 id="classrpc_1_1server_1ad71ffce076d752e116cefa3672e5d188" class="doxy">rpc::server::server</h4>
243265
```cpp
244266
rpc::server::server(std::string const &address, uint16_t port);
@@ -247,6 +269,8 @@ Constructs a server that listens on the localhost on the specified port.
247269
Constructs a server that listens on the specified address on the specified port.
248270

249271
##### Parameters
272+
`address` The address to bind to. This only works if oee of your network adapaters control the given address.
273+
250274
`port` The port number to listen on.
251275

252276

@@ -261,6 +285,20 @@ Destructor.
261285
When the server is destroyed, all ongoin sessions are closed gracefully.
262286

263287

288+
<h4 id="classrpc_1_1server_1ac3cf4848fc3969cd26ba5e3bd2dc411b" class="doxy">rpc::server::operator=</h4>
289+
```cpp
290+
server rpc::server::operator=(server &&other);
291+
```
292+
293+
Move assignment operator.
294+
295+
##### Parameters
296+
`other` The other instance to move from.
297+
298+
##### Return value
299+
The result of the assignment.
300+
301+
264302
<h4 id="classrpc_1_1server_1a981d7e4a08d04d05cbac6770fab0dff8" class="doxy">rpc::server::run</h4>
265303
```cpp
266304
void rpc::server::run();
@@ -269,7 +307,7 @@ void rpc::server::run();
269307
Starts the server loop. This is a blocking call.
270308

271309
##### Details
272-
First and foremost, running the event loop causes the server to start listening on the specified port. Also, as connections are established and calls are made by clients, the server executes the calls as part of this call. This means that the handlers are executed on the thread that calls `run`. Reads and writes are initiated by this function
310+
First and foremost, running the event loop causes the server to start listening on the specified port. Also, as connections are established and calls are made by clients, the server executes the calls as part of this call. This means that the handlers are executed on the thread that calls `run`. Reads and writes are initiated by this function internally as well.
273311

274312

275313
<h4 id="classrpc_1_1server_1a462e032fa21cad78eeacc27da103a2b7" class="doxy">rpc::server::async_run</h4>
@@ -465,6 +503,7 @@ Encapsulates information about the server session/connection this handler is run
465503
| | |
466504
|---------|-------------|
467505
| void | [post_exit](#classrpc_1_1this__session__t_1ae0551bc44674bdd43e33a4d4a36781b0)()
506+
| session_id_t | [id](#classrpc_1_1this__session__t_1aada2250ec9dd3d88781ca16eb4352047)() const
468507

469508

470509
<h4 id="classrpc_1_1this__session__t_1ae0551bc44674bdd43e33a4d4a36781b0" class="doxy">rpc::this_session_t::post_exit</h4>
@@ -477,15 +516,25 @@ Gracefully exits the session (i.e. ongoing writes and reads are completed; queue
477516
!!! warn
478517
Use this function if you need to close the connection from a handler.
479518

519+
<h4 id="classrpc_1_1this__session__t_1aada2250ec9dd3d88781ca16eb4352047" class="doxy">rpc::this_session_t::id</h4>
520+
```cpp
521+
session_id_t rpc::this_session_t::id() const;
522+
```
523+
524+
Returns an ID that uniquely identifies a session.
525+
526+
!!! warn
527+
This is not an ID for the client. If the client disconnects and reconnects, this ID may change. That being said, you can use this ID to store client-specific information *for the duration of the session.
528+
480529

481530
## rpc::timeout
482531

483532
```cpp
484-
#include ""
533+
#include "rpc/rpc_error.h"
485534
```
486535
### Description
487536

488-
537+
This exception is thrown by the client when either the connection or a call takes more time than it is set in set_timeout.
489538

490539

491540

@@ -501,7 +550,7 @@ Gracefully exits the session (i.e. ongoing writes and reads are completed; queue
501550
const char * rpc::timeout::what() const noexcept override;
502551
```
503552

504-
553+
Describes the exception.
505554

506555

507556

‎include/rpc/rpc_error.h

Copy file name to clipboardExpand all lines: include/rpc/rpc_error.h
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,12 @@ class rpc_error : public std::runtime_error {
3535
RPCLIB_MSGPACK::object_handle ob_h_;
3636
};
3737

38+
//! \brief This exception is thrown by the client when either the connection
39+
//! or a call takes more time than it is set in set_timeout.
40+
//! \note There isn't necessarily a timeout set, it is an optional value.
3841
class timeout : public std::runtime_error {
3942
public:
43+
//! \brief Describes the exception.
4044
const char *what() const noexcept override;
4145

4246
private:

‎include/rpc/server.h

Copy file name to clipboardExpand all lines: include/rpc/server.h
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ class server {
4242
//! \brief Constructs a server that listens on the specified address on
4343
//! the specified port.
4444
//!
45+
//! \param address The address to bind to. This only works if oee of your
46+
//! network adapaters control the given address.
4547
//! \param port The port number to listen on.
4648
server(std::string const &address, uint16_t port);
4749

‎utils/.style.yapf

Copy file name to clipboard
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[style]
2+
based_on_style=pep8
3+
indent_width=2

‎utils/markygen.py

Copy file name to clipboardExpand all lines: utils/markygen.py
+87-72Lines changed: 87 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -9,88 +9,103 @@
99

1010

1111
class DoxyObject(object):
12-
def __init__(self, xml):
13-
self._xml = xml
14-
self.brief = self._get('briefdescription/para')
15-
self.desc = self._get('detaileddescription/para')
16-
self.refid = xml.get('refid')
17-
self.id = xml.get('id')
12+
def __init__(self, xml):
13+
self._xml = xml
14+
self.brief = self._get('briefdescription/para')
15+
self.desc = self._get('detaileddescription/para')
16+
self.refid = xml.get('refid')
17+
self.id = xml.get('id')
1818

19-
def _get(self, xpath):
20-
try:
21-
return self._xml.xpath(xpath)[0].text
22-
except:
23-
return ''
19+
def _get(self, xpath):
20+
try:
21+
return self._xml.xpath(xpath)[0].text
22+
except IndexError:
23+
return ''
2424

2525

2626
class Parameter(DoxyObject):
27-
def __init__(self, xml):
28-
super().__init__(xml)
29-
self.name = self._get('parameternamelist/parametername')
30-
self.desc = self._get('parameterdescription/para')
27+
def __init__(self, xml):
28+
super().__init__(xml)
29+
self.name = self._get('parameternamelist/parametername')
30+
self.desc = self._get('parameterdescription/para')
3131

3232

3333
class Function(DoxyObject):
34-
def __init__(self, xml):
35-
super().__init__(xml)
36-
self.visibility = xml.get('prot')
37-
self.is_static = xml.get('static') == 'yes'
38-
self.is_const = xml.get('const') == 'yes'
39-
self.is_explicit = xml.get('explicit') == 'yes'
40-
self.is_inline = xml.get('inline') == 'yes'
41-
self.is_virtual = xml.get('virtual') == 'virtual'
42-
self.name = self._get('name')
43-
self.type = self._get('type')
44-
self.type = self._get_type()
45-
self.argsstr = self._get('argsstring')
46-
try:
47-
self.params = [Parameter(p)
48-
for p in xml.xpath('detaileddescription/para/parameterlist[@kind="param"]')[0]]
49-
except IndexError:
50-
self.params = []
51-
try:
52-
self.tparams = [Parameter(p)
53-
for p in xml.xpath('detaileddescription/para/parameterlist[@kind="templateparam"]')[0]]
54-
except IndexError:
55-
self.tparams = []
56-
try:
57-
self.exceptions = [Parameter(p)
58-
for p in xml.xpath('detaileddescription/para/parameterlist[@kind="exception"]')[0]]
59-
except IndexError:
60-
self.exceptions = []
61-
62-
self.note = self._get(
63-
'detaileddescription/para/simplesect[@kind="note"]/para')
64-
self.returns = self._get(
65-
'detaileddescription/para/simplesect[@kind="return"]/para')
66-
67-
def _get_type(self):
68-
try:
69-
t = self._xml.xpath('type/ref')[0].text
70-
except:
71-
t = self._xml.xpath('type')[0].text
72-
return t
34+
def __init__(self, xml):
35+
super().__init__(xml)
36+
self.visibility = xml.get('prot')
37+
self.is_static = xml.get('static') == 'yes'
38+
self.is_const = xml.get('const') == 'yes'
39+
self.is_explicit = xml.get('explicit') == 'yes'
40+
self.is_inline = xml.get('inline') == 'yes'
41+
self.is_virtual = xml.get('virtual') == 'virtual'
42+
self.name = self._get('name')
43+
self.type = self._get('type')
44+
self.type = self._get_type()
45+
self.argsstr = self._get('argsstring')
46+
try:
47+
self.params = [
48+
Parameter(p)
49+
for p in xml.xpath(
50+
'detaileddescription/para/parameterlist[@kind="param"]')[0]
51+
]
52+
except IndexError:
53+
self.params = []
54+
try:
55+
self.tparams = [
56+
Parameter(p)
57+
for p in xml.xpath(
58+
'detaileddescription/para/parameterlist[@kind="templateparam"]')[
59+
0]
60+
]
61+
except IndexError:
62+
self.tparams = []
63+
try:
64+
self.exceptions = [
65+
Parameter(p)
66+
for p in xml.xpath(
67+
'detaileddescription/para/parameterlist[@kind="exception"]')[0]
68+
]
69+
except IndexError:
70+
self.exceptions = []
71+
72+
self.note = self._get(
73+
'detaileddescription/para/simplesect[@kind="note"]/para')
74+
self.returns = self._get(
75+
'detaileddescription/para/simplesect[@kind="return"]/para')
76+
77+
def _get_type(self):
78+
try:
79+
type_name = self._xml.xpath('type/ref')[0].text
80+
except IndexError:
81+
type_name = self._xml.xpath('type')[0].text
82+
return type_name
7383

7484

7585
class Class(DoxyObject):
76-
def __init__(self, xml):
77-
super().__init__(xml)
78-
self.name = self._get('compoundname')
79-
self.includes = self._get('includes')
80-
self.functions = [Function(f)
81-
for f in xml.xpath('sectiondef[@kind="public-func"]/memberdef[@kind="function"]')]
82-
83-
parser = argparse.ArgumentParser()
84-
parser.add_argument('input')
85-
parser.add_argument('template')
86-
parser.add_argument('output')
87-
args = parser.parse_args()
88-
89-
tree = et.parse(args.input)
90-
classes = [Class(i) for i in tree.xpath('//compounddef[@kind="class"]')]
91-
92-
with open(args.template) as t:
86+
def __init__(self, xml):
87+
super().__init__(xml)
88+
self.name = self._get('compoundname')
89+
self.includes = self._get('includes')
90+
self.functions = [
91+
Function(f)
92+
for f in xml.xpath(
93+
'sectiondef[@kind="public-func"]/memberdef[@kind="function"]')
94+
]
95+
96+
97+
if __name__ == "__main__":
98+
parser = argparse.ArgumentParser()
99+
parser.add_argument('input')
100+
parser.add_argument('template')
101+
parser.add_argument('output')
102+
args = parser.parse_args()
103+
104+
tree = et.parse(args.input)
105+
classes = [Class(i) for i in tree.xpath('//compounddef[@kind="class"]')]
106+
107+
with open(args.template) as t:
93108
tdata = t.read()
94109
mytemplate = Template(tdata)
95110
with open(args.output, 'w') as f:
96-
f.write(mytemplate.render(classes=classes))
111+
f.write(mytemplate.render(classes=classes))

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.