Skip to content

Commit 6eec6a8

Browse files
Home page formatting fixes
1 parent 138e371 commit 6eec6a8

File tree

2 files changed

+55
-57
lines changed

2 files changed

+55
-57
lines changed

docs/html/index.html

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,15 @@ <h2><a class="anchor" id="create_component"></a>
133133
<p>In order to create a new component, we must derive our component class from the <a class="el" href="class_d_s_patch_1_1_component.html" title="Abstract base class for DSPatch components.">DSPatch::Component</a> base class, configure component IO, and implement the inherited virtual "Process_()" method.</p>
134134
<p>Lets take a look at how we would go about creating a very simple boolean logic "AND" component. This component will accept 2 boolean input values and output the result of: input 1 &amp;&amp; input 2.</p>
135135
<p>We begin by deriving our new "AndBool" component from Component:</p>
136-
<div class="fragment"><div class="line"><span class="comment">// 1. Derive AndBool class from Component</span></div>
137-
<div class="line"><span class="comment">// ======================================</span></div>
136+
<div class="fragment"><div class="line"><span class="comment">// 1. Derive AndBool class from Component</span></div>
137+
<div class="line"><span class="comment">// ======================================</span></div>
138138
<div class="line"><span class="keyword">class </span>AndBool final : <span class="keyword">public</span> <a class="code hl_class" href="class_d_s_patch_1_1_component.html">DSPatch::Component</a></div>
139139
<div class="line">{</div>
140140
<div class="ttc" id="aclass_d_s_patch_1_1_component_html"><div class="ttname"><a href="class_d_s_patch_1_1_component.html">DSPatch::Component</a></div><div class="ttdoc">Abstract base class for DSPatch components.</div><div class="ttdef"><b>Definition</b> <a href="_component_8h_source.html#l00064">Component.h:65</a></div></div>
141141
</div><!-- fragment --><p>The next step is to configure our component's input and output buses. This is achieved by calling the base protected methods: SetInputCount_() and SetOutputCount_() respectively from our component's constructor. In our component's case, we require 2 inputs and 1 output, therefore our constructor code will look like this:</p>
142142
<div class="fragment"><div class="line"><span class="keyword">public</span>:</div>
143-
<div class="line"> <span class="comment">// 2. Configure component IO buses</span></div>
144-
<div class="line"> <span class="comment">// ===============================</span></div>
143+
<div class="line"><span class="comment">// 2. Configure component IO buses</span></div>
144+
<div class="line"><span class="comment">// ===============================</span></div>
145145
<div class="line"> AndBool()</div>
146146
<div class="line"> {</div>
147147
<div class="line"> <span class="comment">// add 2 inputs</span></div>
@@ -153,8 +153,8 @@ <h2><a class="anchor" id="create_component"></a>
153153
</div><!-- fragment --><p>Lastly, our component must implement the virtual Process_() method. This is where our component does its work. The Process_() method provides us with 2 arguments: the input bus and the output bus. It is our duty as the component designer to pull the inputs we require out of the input bus, process them accordingly, then populate the output bus with the results.</p>
154154
<p>Our component's process method will look something like this:</p>
155155
<div class="fragment"><div class="line"><span class="keyword">protected</span>:</div>
156-
<div class="line"> <span class="comment">// 3. Implement virtual Process_() method</span></div>
157-
<div class="line"> <span class="comment">// ======================================</span></div>
156+
<div class="line"><span class="comment">// 3. Implement virtual Process_() method</span></div>
157+
<div class="line"><span class="comment">// ======================================</span></div>
158158
<div class="line"> <span class="keywordtype">void</span> Process_( <a class="code hl_class" href="class_d_s_patch_1_1_signal_bus.html">DSPatch::SignalBus</a>&amp; inputs, <a class="code hl_class" href="class_d_s_patch_1_1_signal_bus.html">DSPatch::SignalBus</a>&amp; outputs )<span class="keyword"> override</span></div>
159159
<div class="line"><span class="keyword"> </span>{</div>
160160
<div class="line"> <span class="comment">// create some local pointers to hold our input values</span></div>
@@ -183,43 +183,41 @@ <h2><a class="anchor" id="use_component"></a>
183183
</div><!-- fragment --><p>Next, we must instantiate our circuit object and all component objects needed for our circuit. Lets say we had 2 other components included with "AndBool" (from the first tutorial): "GenBool" (generates a random boolean value then outputs the result) and "PrintBool" (receives a boolean value and outputs it to the console):</p>
184184
<div class="fragment"><div class="line"><span class="keywordtype">int</span> main()</div>
185185
<div class="line">{</div>
186-
<div class="line"> <span class="comment">// 1. Create a circuit where we can route our components</span></div>
187-
<div class="line"> <span class="comment">// =====================================================</span></div>
186+
<div class="line"><span class="comment">// 1. Create a circuit where we can route our components</span></div>
187+
<div class="line"><span class="comment">// =====================================================</span></div>
188188
<div class="line"> <span class="keyword">auto</span> circuit = std::make_shared&lt;DSPatch::Circuit&gt;();</div>
189189
<div class="line"> </div>
190-
<div class="line"> <span class="comment">// 2. Create instances of the components needed for our circuit</span></div>
191-
<div class="line"> <span class="comment">// ============================================================</span></div>
190+
<div class="line"><span class="comment">// 2. Create instances of the components needed for our circuit</span></div>
191+
<div class="line"><span class="comment">// ============================================================</span></div>
192192
<div class="line"> <span class="keyword">auto</span> genBool1 = std::make_shared&lt;GenBool&gt;();</div>
193193
<div class="line"> <span class="keyword">auto</span> genBool2 = std::make_shared&lt;GenBool&gt;();</div>
194194
<div class="line"> <span class="keyword">auto</span> andBool = std::make_shared&lt;AndBool&gt;();</div>
195195
<div class="line"> <span class="keyword">auto</span> printBool = std::make_shared&lt;PrintBool&gt;();</div>
196196
</div><!-- fragment --><p>Now that we have a circuit and some components, lets add all of our components to the circuit:</p>
197-
<div class="fragment"><div class="line"> <span class="comment">// 3. Add component instances to circuit</span></div>
198-
<div class="line"> <span class="comment">// =====================================</span></div>
197+
<div class="fragment"><div class="line"><span class="comment">// 3. Add component instances to circuit</span></div>
198+
<div class="line"><span class="comment">// =====================================</span></div>
199199
<div class="line"> circuit-&gt;AddComponent( genBool1 );</div>
200200
<div class="line"> circuit-&gt;AddComponent( genBool2 );</div>
201201
<div class="line"> circuit-&gt;AddComponent( andBool );</div>
202-
<div class="line">_ circuit-&gt;AddComponent( printBool );</div>
202+
<div class="line"> circuit-&gt;AddComponent( printBool );</div>
203203
</div><!-- fragment --><p>We are now ready to begin wiring the circuit:</p>
204-
<div class="fragment"><div class="line"> <span class="comment">// 4. Wire up the components inside the circuit</span></div>
205-
<div class="line"> <span class="comment">// ============================================</span></div>
204+
<div class="fragment"><div class="line"><span class="comment">// 4. Wire up the components inside the circuit</span></div>
205+
<div class="line"><span class="comment">// ============================================</span></div>
206206
<div class="line"> circuit-&gt;ConnectOutToIn( genBool1, 0, andBool, 0 );</div>
207207
<div class="line"> circuit-&gt;ConnectOutToIn( genBool2, 0, andBool, 1 );</div>
208-
<div class="line">_ circuit-&gt;ConnectOutToIn( andBool, 0, printBool, 0 );</div>
209-
</div><!-- fragment --><p>The code above results in the following wiring configuration: </p><div class="fragment"><div class="line"> __________ _________</div>
210-
<div class="line"> | | | |</div>
211-
<div class="line"> | genBool1 |-0 ===&gt; 0-| | ___________</div>
212-
<div class="line"> |__________| | | | |</div>
213-
<div class="line"> __________ | andBool |-0 ===&gt; 0-| printBool |</div>
214-
<div class="line"> | | | | |___________|</div>
215-
<div class="line"> | genBool2 |-0 ===&gt; 1-| |</div>
216-
<div class="line"> |__________| |_________|</div>
217-
<div class="line">_</div>
218-
</div><!-- fragment --><p>Lastly, in order for our circuit to do any work it must be ticked. This is performed by repeatedly calling the circuit's Tick() method. This method can be called manually in a loop, or alternatively, by calling StartAutoTick(), a seperate thread will spawn, automatically calling Tick() continuously.</p>
208+
<div class="line"> circuit-&gt;ConnectOutToIn( andBool, 0, printBool, 0 );</div>
209+
</div><!-- fragment --><p>The code above results in the following wiring configuration: </p><pre class="fragment"> __________ _________
210+
| | | |
211+
| genBool1 |-0 ===&gt; 0-| | ___________
212+
|__________| | | | |
213+
__________ | andBool |-0 ===&gt; 0-| printBool |
214+
| | | | |___________|
215+
| genBool2 |-0 ===&gt; 1-| |
216+
|__________| |_________|</pre><p>Lastly, in order for our circuit to do any work it must be ticked. This is performed by repeatedly calling the circuit's Tick() method. This method can be called manually in a loop, or alternatively, by calling StartAutoTick(), a seperate thread will spawn, automatically calling Tick() continuously.</p>
219217
<p>Furthermore, to boost performance in stream processing circuits like this one, multi-buffering can be enabled via the SetBufferCount() method:</p>
220218
<p><b>NOTE:</b> If none of the parallel branches in your circuit are time-consuming (⪆10μs), multi-buffering (or even zero buffering) will almost always outperform multi-threading (via SetThreadCount()). The contention overhead caused by multiple threads processing a single tick must be made negligible by time-consuming parallel components for any performance improvement to be seen.</p>
221-
<div class="fragment"><div class="line"> <span class="comment">// 5. Tick the circuit</span></div>
222-
<div class="line"> <span class="comment">// ===================</span></div>
219+
<div class="fragment"><div class="line"><span class="comment">// 5. Tick the circuit</span></div>
220+
<div class="line"><span class="comment">// ===================</span></div>
223221
<div class="line"> </div>
224222
<div class="line"> <span class="comment">// Circuit tick method 1: Manual</span></div>
225223
<div class="line"> <span class="keywordflow">for</span>( <span class="keywordtype">int</span> i = 0; i &lt; 10; ++i )</div>

include/DSPatch.h

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
103103
We begin by deriving our new "AndBool" component from Component:
104104
105105
\code
106-
// 1. Derive AndBool class from Component
107-
// ======================================
106+
// 1. Derive AndBool class from Component
107+
// ======================================
108108
class AndBool final : public DSPatch::Component
109109
{
110110
\endcode
@@ -116,8 +116,8 @@ class AndBool final : public DSPatch::Component
116116
117117
\code
118118
public:
119-
// 2. Configure component IO buses
120-
// ===============================
119+
// 2. Configure component IO buses
120+
// ===============================
121121
AndBool()
122122
{
123123
// add 2 inputs
@@ -137,8 +137,8 @@ class AndBool final : public DSPatch::Component
137137
138138
\code
139139
protected:
140-
// 3. Implement virtual Process_() method
141-
// ======================================
140+
// 3. Implement virtual Process_() method
141+
// ======================================
142142
void Process_( DSPatch::SignalBus& inputs, DSPatch::SignalBus& outputs ) override
143143
{
144144
// create some local pointers to hold our input values
@@ -184,12 +184,12 @@ class AndBool final : public DSPatch::Component
184184
\code
185185
int main()
186186
{
187-
// 1. Create a circuit where we can route our components
188-
// =====================================================
187+
// 1. Create a circuit where we can route our components
188+
// =====================================================
189189
auto circuit = std::make_shared<DSPatch::Circuit>();
190190
191-
// 2. Create instances of the components needed for our circuit
192-
// ============================================================
191+
// 2. Create instances of the components needed for our circuit
192+
// ============================================================
193193
auto genBool1 = std::make_shared<GenBool>();
194194
auto genBool2 = std::make_shared<GenBool>();
195195
auto andBool = std::make_shared<AndBool>();
@@ -199,36 +199,36 @@ int main()
199199
Now that we have a circuit and some components, lets add all of our components to the circuit:
200200
201201
\code
202-
// 3. Add component instances to circuit
203-
// =====================================
202+
// 3. Add component instances to circuit
203+
// =====================================
204204
circuit->AddComponent( genBool1 );
205205
circuit->AddComponent( genBool2 );
206206
circuit->AddComponent( andBool );
207-
_ circuit->AddComponent( printBool );
207+
circuit->AddComponent( printBool );
208208
\endcode
209209
210210
We are now ready to begin wiring the circuit:
211211
212212
\code
213-
// 4. Wire up the components inside the circuit
214-
// ============================================
213+
// 4. Wire up the components inside the circuit
214+
// ============================================
215215
circuit->ConnectOutToIn( genBool1, 0, andBool, 0 );
216216
circuit->ConnectOutToIn( genBool2, 0, andBool, 1 );
217-
_ circuit->ConnectOutToIn( andBool, 0, printBool, 0 );
217+
circuit->ConnectOutToIn( andBool, 0, printBool, 0 );
218218
\endcode
219219
220220
The code above results in the following wiring configuration:
221-
\code
222-
__________ _________
223-
| | | |
224-
| genBool1 |-0 ===> 0-| | ___________
225-
|__________| | | | |
226-
__________ | andBool |-0 ===> 0-| printBool |
227-
| | | | |___________|
228-
| genBool2 |-0 ===> 1-| |
229-
|__________| |_________|
230-
_
231-
\endcode
221+
\verbatim
222+
__________ _________
223+
| | | |
224+
| genBool1 |-0 ===> 0-| | ___________
225+
|__________| | | | |
226+
__________ | andBool |-0 ===> 0-| printBool |
227+
| | | | |___________|
228+
| genBool2 |-0 ===> 1-| |
229+
|__________| |_________|
230+
231+
\endverbatim
232232
233233
Lastly, in order for our circuit to do any work it must be ticked. This is performed by
234234
repeatedly calling the circuit's Tick() method. This method can be called manually in a loop,
@@ -245,8 +245,8 @@ _ circuit->ConnectOutToIn( andBool, 0, printBool, 0 );
245245
improvement to be seen.
246246
247247
\code
248-
// 5. Tick the circuit
249-
// ===================
248+
// 5. Tick the circuit
249+
// ===================
250250
251251
// Circuit tick method 1: Manual
252252
for( int i = 0; i < 10; ++i )

0 commit comments

Comments
 (0)