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 4b9ea2f

Browse filesBrowse files
committed
add unbind to enable runtime binding/unbinding
adding unbind function to remove a binding in runtime (if wanted) and names function to list all binded functors (usable for debugging etc.)
1 parent d1bb5b4 commit 4b9ea2f
Copy full SHA for 4b9ea2f

File tree

Expand file treeCollapse file tree

2 files changed

+31
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+31
-0
lines changed

‎include/rpc/dispatcher.h

Copy file name to clipboardExpand all lines: include/rpc/dispatcher.h
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,19 @@ class dispatcher {
6060
detail::tags::nonvoid_result const &,
6161
detail::tags::nonzero_arg const &);
6262

63+
//! \brief removes a functor with given name from callable functors.
64+
void remove(std::string const &name) {
65+
funcs_.erase(name);
66+
}
67+
68+
//! \brief returns a list name of all functors binded
69+
std::vector<std::string> names() {
70+
std::vector<std::string> names;
71+
for(auto it = funcs_.begin(); it != funcs_.end(); ++it)
72+
names.push_back(it->first);
73+
return names;
74+
}
75+
6376
//! @}
6477

6578
//! \brief Processes a message that contains a call according to

‎include/rpc/server.h

Copy file name to clipboardExpand all lines: include/rpc/server.h
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,24 @@ class server {
9393
disp_->bind(name, func);
9494
}
9595

96+
//! \brief Unbinds a functor binded to a name.
97+
//!
98+
//! This function removes already binded function from RPC Ccallable functions
99+
//!
100+
//! \param name The name of the functor.
101+
void unbind(std::string const &name) {
102+
disp_->remove(name);
103+
}
104+
105+
//! \brief Returns all binded names
106+
//!
107+
//! This function returns a list of all names which functors are binded to
108+
//!
109+
//! \param name The name of the functor.
110+
std::vector<std::string> names() {
111+
return disp_->names();
112+
}
113+
96114
//! \brief Sets the exception behavior in handlers. By default,
97115
//! handlers throwing will crash the server. If suppressing is on,
98116
//! the server will try to gather textual data and return it to

0 commit comments

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