-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathclass_r_t_injector.html
More file actions
265 lines (249 loc) · 15.3 KB
/
class_r_t_injector.html
File metadata and controls
265 lines (249 loc) · 15.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.6"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>C++ TargetRTS: RTInjector Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="projectrow">
<td id="projectalign">
<div id="projectname">C++ TargetRTS
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.6 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>
</div><!-- top -->
<div class="header">
<div class="summary">
<a href="#pub-methods">Public Member Functions</a> |
<a href="#pub-static-methods">Static Public Member Functions</a> |
<a href="class_r_t_injector-members.html">List of all members</a> </div>
<div class="headertitle"><div class="title">RTInjector Class Reference</div></div>
</div><!--header-->
<div class="contents">
<p>Dependency injector for RT applications.
<a href="class_r_t_injector.html#details">More...</a></p>
<p><code>#include <<a class="el" href="_r_t_injector_8h_source.html">RTInjector.h</a>></code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="pub-methods" name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:abb5d5a47f08b8e6b34e07d13abcfe38b"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="class_r_t_injector.html#abb5d5a47f08b8e6b34e07d13abcfe38b">registerCreateFunction</a> (const std::string &id, std::function< <a class="el" href="class_r_t_actor.html">RTActor</a> *(<a class="el" href="class_r_t_controller.html">RTController</a> *, <a class="el" href="class_r_t_actor_ref.html">RTActorRef</a> *, int)> createFunc)</td></tr>
<tr class="memdesc:abb5d5a47f08b8e6b34e07d13abcfe38b"><td class="mdescLeft"> </td><td class="mdescRight">Register a create function to be used for incarnating capsule instances in a capsule part. <br /></td></tr>
<tr class="separator:abb5d5a47f08b8e6b34e07d13abcfe38b"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:aaa9b5ed1aada6e6fa00574b839cde6fe"><td class="memItemLeft" align="right" valign="top">std::function< <a class="el" href="class_r_t_actor.html">RTActor</a> *(<a class="el" href="class_r_t_controller.html">RTController</a> *, <a class="el" href="class_r_t_actor_ref.html">RTActorRef</a> *, int)> </td><td class="memItemRight" valign="bottom"><a class="el" href="class_r_t_injector.html#aaa9b5ed1aada6e6fa00574b839cde6fe">getCreateFunction</a> (const std::string &id)</td></tr>
<tr class="memdesc:aaa9b5ed1aada6e6fa00574b839cde6fe"><td class="mdescLeft"> </td><td class="mdescRight">Get a create function registered for incarnating capsule instances in a capsule part. <br /></td></tr>
<tr class="separator:aaa9b5ed1aada6e6fa00574b839cde6fe"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a23f2c45bc802443918532174bc4708b0"><td class="memItemLeft" align="right" valign="top"><a class="el" href="class_r_t_actor.html">RTActor</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="class_r_t_injector.html#a23f2c45bc802443918532174bc4708b0">create</a> (<a class="el" href="class_r_t_controller.html">RTController</a> *rts, <a class="el" href="class_r_t_actor_ref.html">RTActorRef</a> *ref, int index)</td></tr>
<tr class="memdesc:a23f2c45bc802443918532174bc4708b0"><td class="mdescLeft"> </td><td class="mdescRight">Create a capsule instance. <br /></td></tr>
<tr class="separator:a23f2c45bc802443918532174bc4708b0"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a5be5839bc3868f80e2c3f22b99a3ed17"><td class="memItemLeft" align="right" valign="top"><a id="a5be5839bc3868f80e2c3f22b99a3ed17" name="a5be5839bc3868f80e2c3f22b99a3ed17"></a>
 </td><td class="memItemRight" valign="bottom"><b>RTInjector</b> (<a class="el" href="class_r_t_injector.html">RTInjector</a> const &)=delete</td></tr>
<tr class="separator:a5be5839bc3868f80e2c3f22b99a3ed17"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ae3606156f9eafde403f181eb1e7c7964"><td class="memItemLeft" align="right" valign="top"><a id="ae3606156f9eafde403f181eb1e7c7964" name="ae3606156f9eafde403f181eb1e7c7964"></a>
void </td><td class="memItemRight" valign="bottom"><b>operator=</b> (<a class="el" href="class_r_t_injector.html">RTInjector</a> const &)=delete</td></tr>
<tr class="separator:ae3606156f9eafde403f181eb1e7c7964"><td class="memSeparator" colspan="2"> </td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="pub-static-methods" name="pub-static-methods"></a>
Static Public Member Functions</h2></td></tr>
<tr class="memitem:a9fa3e0df657b37bd727abfc4943ba3fc"><td class="memItemLeft" align="right" valign="top">static <a class="el" href="class_r_t_injector.html">RTInjector</a> & </td><td class="memItemRight" valign="bottom"><a class="el" href="class_r_t_injector.html#a9fa3e0df657b37bd727abfc4943ba3fc">getInstance</a> ()</td></tr>
<tr class="memdesc:a9fa3e0df657b37bd727abfc4943ba3fc"><td class="mdescLeft"> </td><td class="mdescRight">Access the singleton injector instance (created on first access) <br /></td></tr>
<tr class="separator:a9fa3e0df657b37bd727abfc4943ba3fc"><td class="memSeparator" colspan="2"> </td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Dependency injector for RT applications. </p>
<p>At runtime a capsule instance depends on other capsule instances. Instead of hard coding such dependencies inside the capsule itself, the dependency injector approach allows to register such dependencies in a centralized location. Thereby you can configure the application by changing in that single place only.</p>
<p>A typical usage of this class is to access the singleton instance at application start-up (for example in the constructor of the top capsule). There you then configure the dependencies to be injected by registering create functions for capsule parts that you want to incarnate in a non-default way. Some example of customization possibilities (implemented by the create function):</p><ul>
<li>which capsule to create an instance of (if not the same as specified as type for the capsule part)</li>
<li>which constructor arguments to pass (custom initialization data for the create capsule instance)</li>
<li>which thread to run the created capsule instance (if not the same as the one running the owner capsule instance) A capsule factory (local or global in the TC) can be used and delegate to the injector object whenever a capsule instance should be created. The injector will check if a specific create function has been registered as a dependency, and if so it will use it for creating the capsule instance. If no such create function is found it will fallback to creating the capsule instance as usual (based on the type of the capsule part).</li>
</ul>
<p>Dependencies are usually not changed once registered, but if needed it's possible to do so (the implementation is thread safe). </p>
</div><h2 class="groupheader">Member Function Documentation</h2>
<a id="a23f2c45bc802443918532174bc4708b0" name="a23f2c45bc802443918532174bc4708b0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a23f2c45bc802443918532174bc4708b0">◆ </a></span>create()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="class_r_t_actor.html">RTActor</a> * RTInjector::create </td>
<td>(</td>
<td class="paramtype"><a class="el" href="class_r_t_controller.html">RTController</a> * </td>
<td class="paramname"><em>rts</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="class_r_t_actor_ref.html">RTActorRef</a> * </td>
<td class="paramname"><em>ref</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"><em>index</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Create a capsule instance. </p>
<p>If a create function has been registered for the specified capsule part it will be used for creating the capsule instance. Otherwise nullptr will be returned, to allow the capsule instance to be created as default (if possible). </p><dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">rts</td><td>Default controller thread to run the created capsule instance (a registered create function may override this) </td></tr>
<tr><td class="paramname">ref</td><td>Capsule part to host the created capsule instance </td></tr>
<tr><td class="paramname">index</td><td>Index where to insert the created capsule instance in the capsule part </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Created capsule instance, or nullptr in case no capsule instance was created </dd></dl>
</div>
</div>
<a id="aaa9b5ed1aada6e6fa00574b839cde6fe" name="aaa9b5ed1aada6e6fa00574b839cde6fe"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aaa9b5ed1aada6e6fa00574b839cde6fe">◆ </a></span>getCreateFunction()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">std::function< <a class="el" href="class_r_t_actor.html">RTActor</a> *(<a class="el" href="class_r_t_controller.html">RTController</a> *, <a class="el" href="class_r_t_actor_ref.html">RTActorRef</a> *, int)> RTInjector::getCreateFunction </td>
<td>(</td>
<td class="paramtype">const std::string & </td>
<td class="paramname"><em>id</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Get a create function registered for incarnating capsule instances in a capsule part. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">id</td><td>Qualified id string for the capsule part (e.g. "/part1:0/part2") </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Registered create function, or an empty function if no create function was registered for the capsule part </dd></dl>
</div>
</div>
<a id="a9fa3e0df657b37bd727abfc4943ba3fc" name="a9fa3e0df657b37bd727abfc4943ba3fc"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a9fa3e0df657b37bd727abfc4943ba3fc">◆ </a></span>getInstance()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">static <a class="el" href="class_r_t_injector.html">RTInjector</a> & RTInjector::getInstance </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Access the singleton injector instance (created on first access) </p>
<dl class="section return"><dt>Returns</dt><dd>injector instance </dd></dl>
</div>
</div>
<a id="abb5d5a47f08b8e6b34e07d13abcfe38b" name="abb5d5a47f08b8e6b34e07d13abcfe38b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#abb5d5a47f08b8e6b34e07d13abcfe38b">◆ </a></span>registerCreateFunction()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void RTInjector::registerCreateFunction </td>
<td>(</td>
<td class="paramtype">const std::string & </td>
<td class="paramname"><em>id</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">std::function< <a class="el" href="class_r_t_actor.html">RTActor</a> *(<a class="el" href="class_r_t_controller.html">RTController</a> *, <a class="el" href="class_r_t_actor_ref.html">RTActorRef</a> *, int)> </td>
<td class="paramname"><em>createFunc</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Register a create function to be used for incarnating capsule instances in a capsule part. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">id</td><td>Qualified id string for the capsule part (e.g. "/part1:0/part2") </td></tr>
<tr><td class="paramname">createFunc</td><td>Create function to register </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="_r_t_injector_8h_source.html">RTInjector.h</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.6
</small></address>
</body>
</html>