UNPKG

15.1 kBHTMLView Raw
1<!DOCTYPE html> <html> <head> <title>LoggableFactory.coffee</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="ByteIterable.html"> ByteIterable.coffee </a> <a class="source" href="ByteIterator.html"> ByteIterator.coffee </a> <a class="source" href="ArrayByteIterable.html"> ArrayByteIterable.coffee </a> <a class="source" href="ByteIterableBase.html"> ByteIterableBase.coffee </a> <a class="source" href="ByteIterableUtil.html"> ByteIterableUtil.coffee </a> <a class="source" href="LightOutputStream.html"> LightOutputStream.coffee </a> <a class="source" href="StoreConfiguration.html"> StoreConfiguration.coffee </a> <a class="source" href="Reader.html"> Reader.coffee </a> <a class="source" href="Writer.html"> Writer.coffee </a> <a class="source" href="List.html"> List.coffee </a> <a class="source" href="ListNode.html"> ListNode.coffee </a> <a class="source" href="Cursor.html"> Cursor.coffee </a> <a class="source" href="DatabaseRoot.html"> DatabaseRoot.coffee </a> <a class="source" href="Environment.html"> Environment.coffee </a> <a class="source" href="EnvironmentConfig.html"> EnvironmentConfig.coffee </a> <a class="source" href="Store.html"> Store.coffee </a> <a class="source" href="Transaction.html"> Transaction.coffee </a> <a class="source" href="Addr64.html"> Addr64.coffee </a> <a class="source" href="DataIterator.html"> DataIterator.coffee </a> <a class="source" href="Log.html"> Log.coffee </a> <a class="source" href="LogCache.html"> LogCache.coffee </a> <a class="source" href="LogConfig.html"> LogConfig.coffee </a> <a class="source" href="LogUtil.html"> LogUtil.coffee </a> <a class="source" href="Loggable.html"> Loggable.coffee </a> <a class="source" href="LoggableFactory.html"> LoggableFactory.coffee </a> <a class="source" href="LoggableIterator.html"> LoggableIterator.coffee </a> <a class="source" href="LoggableToWrite.html"> LoggableToWrite.coffee </a> <a class="source" href="NullLoggable.html"> NullLoggable.coffee </a> <a class="source" href="RandomAccessByteIterable.html"> RandomAccessByteIterable.coffee </a> <a class="source" href="RandomAccessLoggable.html"> RandomAccessLoggable.coffee </a> <a class="source" href="RandomAccessLoggableIterator.html"> RandomAccessLoggableIterator.coffee </a> <a class="source" href="StackList.html"> StackList.coffee </a> <a class="source" href="CompoundByteIterable.html"> CompoundByteIterable.coffee </a> <a class="source" href="CompoundByteIteratorBase.html"> CompoundByteIteratorBase.coffee </a> <a class="source" href="CompressedUnsignedLongByteIterable.html"> CompressedUnsignedLongByteIterable.coffee </a> <a class="source" href="FixedLengthByteIterable.html"> FixedLengthByteIterable.coffee </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> LoggableFactory.coffee </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> </td> <td class="code"> <div class="highlight"><pre><span class="nv">RandomAccessLoggable =</span>
2 <span class="p">(</span><span class="nx">require</span> <span class="s1">&#39;./RandomAccessLoggable.coffee&#39;</span><span class="p">).</span><span class="nx">RandomAccessLoggable</span>
3<span class="nv">ExodusError = </span><span class="p">(</span><span class="nx">require</span> <span class="s1">&#39;../util/ExodusVersion.coffee&#39;</span><span class="p">).</span><span class="nx">ExodusError</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>This class provides an ability to create various loggables of the same type.</p> </td> <td class="code"> <div class="highlight"><pre><span class="k">class</span> <span class="nx">LoggableFactory</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>@private</p> </td> <td class="code"> <div class="highlight"><pre> <span class="vi">@MAXIMUM_LOGGABLE_TYPE = </span><span class="mi">128</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>@private</p> </td> <td class="code"> <div class="highlight"><pre> <span class="vi">@FACTORY: </span><span class="k">new</span> <span class="nb">Array</span> <span class="nx">LoggableFactory</span><span class="p">.</span><span class="nx">MAXIMUM_LOGGABLE_TYPE</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <p>@protected
4Constructor.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="vi">@create: </span><span class="nf">(o) -&gt;</span>
5 <span class="k">if</span> <span class="o">!</span><span class="nx">o</span><span class="o">?</span> <span class="k">then</span> <span class="nv">o = </span><span class="k">new</span> <span class="nx">LoggableFactory</span>
6 <span class="k">return</span> <span class="nx">o</span></pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-6">&#182;</a> </div> <p>Register new factory.</p>
7
8<p>@param type loggable type.
9@param loggableFactory new factory.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">@registerLoggable$int</span><span class="nv">$LoggableFactory: </span><span class="nf">(type, loggableFactory) -&gt;</span>
10 <span class="nv">prevLoggableFactory = </span><span class="nx">LoggableFactory</span><span class="p">.</span><span class="nx">FACTORY</span><span class="p">[</span><span class="nx">type</span><span class="p">]</span>
11 <span class="k">if</span> <span class="nx">prevLoggableFactory</span><span class="o">?</span> <span class="o">&amp;&amp;</span> <span class="nx">prevLoggableFactory</span> <span class="o">!=</span> <span class="nx">loggableFactory</span>
12 <span class="k">throw</span> <span class="k">new</span> <span class="nx">ExodusError</span><span class="p">(</span><span class="s2">&quot;Loggable type is already registered: &quot;</span> <span class="o">+</span>
13 <span class="nx">type</span><span class="p">.</span><span class="nx">toString</span><span class="p">())</span>
14 <span class="nx">LoggableFactory</span><span class="p">.</span><span class="nx">FACTORY</span><span class="p">[</span><span class="nx">type</span><span class="p">]</span> <span class="o">=</span> <span class="nx">loggableFactory</span></pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-7">&#182;</a> </div> <p>Clears all prototypes.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="vi">@clear: </span><span class="nf">() -&gt;</span>
15 <span class="k">for</span> <span class="nx">i</span> <span class="k">in</span> <span class="p">[</span><span class="mi">0</span><span class="p">..</span><span class="nx">LoggableFactory</span><span class="p">.</span><span class="nx">FACTORY</span><span class="p">.</span><span class="nx">length</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span>
16 <span class="nx">LoggableFactory</span><span class="p">.</span><span class="nx">FACTORY</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">=</span> <span class="kc">null</span></pre></div> </td> </tr> <tr id="section-8"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-8">&#182;</a> </div> <p>Creates new instance of loggable.</p>
17
18<p>@param address address of result in the log.
19@param type type of loggable.
20@param length length of the loggable.
21@param data loggable data.
22@param dataLength length of the loggable data.
23@param structureId structure id of loggable.
24@return new loggable instance.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">@create$Addr64$int$int$RandomAccessByteIterable$int</span><span class="nv">$int: </span><span class="nf">(address, type, length, data, dataLength, structureId) -&gt;</span>
25 <span class="nv">prototype = </span><span class="nx">LoggableFactory</span><span class="p">.</span><span class="nx">FACTORY</span><span class="p">[</span><span class="nx">type</span><span class="p">]</span>
26 <span class="k">if</span> <span class="nx">prototype</span><span class="o">?</span>
27 <span class="k">return</span> <span class="nx">prototype</span><span class="p">.</span><span class="nx">create</span> <span class="nx">address</span><span class="p">,</span> <span class="nx">length</span><span class="p">,</span> <span class="nx">data</span><span class="p">,</span> <span class="nx">dataLength</span><span class="p">,</span> <span class="nx">structureId</span>
28 <span class="k">return</span> <span class="nx">RandomAccessLoggable</span><span class="p">.</span>
29 <span class="nx">create$Addr64$int$int$RandomAccessByteIterable$int$int</span> <span class="nx">address</span><span class="p">,</span> <span class="nx">type</span><span class="p">,</span>
30 <span class="nx">length</span><span class="p">,</span> <span class="nx">data</span><span class="p">,</span> <span class="nx">dataLength</span><span class="p">,</span> <span class="nx">structureId</span></pre></div> </td> </tr> <tr id="section-9"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-9">&#182;</a> </div> <p>@protected
31Creates new instance of loggable.</p>
32
33<p>@param address address of result in the log.
34@param length length of the loggable.
35@param data loggable data.
36@param dataLength length of the loggable data.
37@param structureId structure id of loggable.
38@return new loggable instance.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">create$Addr64$int$RandomAccessByteIterable$int</span><span class="nv">$int: </span><span class="nf">(address, length, data, dataLength, structureId) -&gt;</span></pre></div> </td> </tr> <tr id="section-10"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-10">&#182;</a> </div> <p>Overload in child classes.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">exports.LoggableFactory = </span><span class="nx">LoggableFactory</span>
39
40</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
\No newline at end of file