File: counter.xml

package info (click to toggle)
php-doc 20140201-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 74,084 kB
  • ctags: 4,040
  • sloc: xml: 998,137; php: 20,812; cpp: 500; sh: 177; makefile: 63; awk: 28
file content (1124 lines) | stat: -rw-r--r-- 35,108 bytes parent folder | download
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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 323642 $ -->
 <part xml:id="internals2.counter" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
  <title>The "counter" Extension - A Continuing Example</title>
  
  <partintro xml:id="internals2.counter.preface">
   <title>Preface</title>
   <simpara> 
    Throughout this Zend documentation, references are made to an example module
    in order to illustrate various concepts. The "counter" extension is this
    example, a fictional yet functional Zend module which strives to use as much
    of the Zend API as is reasonably possible. This short chapter describes the
    userland interface to the completed extension.
   </simpara>
  
   <note>
    <simpara>
     "counter" serves no practical purpose whatsoever, as the functionality it
     provides is far more effectively implemented by appropriate userland code.
    </simpara>
   </note>
  </partintro>
  
  <chapter xml:id="internals2.counter.setup">
   &reftitle.setup;

   <section xml:id="internals2.counter.intro">
    &reftitle.intro;
  
    <simpara>
     The "counter" extension provides any number of counters to PHP code using it
     which reset at times determined by the caller.
    </simpara>
   
    <simpara>
     There are three interfaces to "counter": basic, extended, and objective. The
     basic interface provides a single counter controlled by INI settings and
     function calls. The extended interface provides an arbitrary number of named
     counter resources which may optionally persist beyond the lifetime of a
     single PHP request. The objective interface combines both the basic and
     extended interfaces into a <classname>Counter</classname> class.
    </simpara>
   </section>
  
   <section xml:id="internals2.counter.ini">
    &reftitle.runtime;

    &extension.runtime;
    <table>
     <title>Counter configuration options</title>
     <tgroup cols="4">
      <thead>
       <row>
        <entry>Name</entry>
        <entry>Default</entry>
        <entry>Changeable</entry>
        <entry>Changelog</entry>
       </row>
      </thead>
      <tbody>
       <row>
        <entry>counter.reset_time</entry>
        <entry>COUNTER_RESET_PER_REQUEST</entry>
        <entry>PHP_INI_ALL</entry>
        <entry></entry>
       </row>
       <row>
        <entry>counter.save_path</entry>
        <entry>""</entry>
        <entry>PHP_INI_ALL</entry>
        <entry></entry>
       </row>
       <row>
        <entry>counter.initial_value</entry>
        <entry>"0"</entry>
        <entry>PHP_INI_ALL</entry>
        <entry></entry>
       </row>
      </tbody>
     </tgroup>
    </table>
    <simpara>&ini.php.constants;</simpara>

    <variablelist>
     <varlistentry xml:id="internals2.counter.ini.reset-time">
      <term>
       <parameter>counter.reset_time</parameter>
       <type>integer</type>
      </term>
      <listitem>
       <simpara>
        <varname>counter.reset_time</varname> tells "counter" to reset the
        counter used by the basic interface. It may be any of the
        <constant>COUNTER_RESET_*</constant> constants (see below).
       </simpara>
      </listitem>
     </varlistentry>
     <varlistentry xml:id="internals2.counter.ini.save-path">
      <term>
       <parameter>counter.save_path</parameter>
       <type>string</type>
      </term>
      <listitem>
       <simpara>
        Tells "counter" where to save data that has to persist between
        invocations of PHP (i.e. any counter that has COUNTER_RESET_NEVER or
        COUNTER_FLAG_SAVE). A file will be created at this path, which must be
        readable and writable to whatever user PHP is running as.
       </simpara>
      </listitem>
     </varlistentry>
     <varlistentry xml:id="internals2.counter.ini.initial-value">
      <term>
       <parameter>counter.initial_value</parameter>
       <type>integer</type>
      </term>
      <listitem>
       <simpara>
        Sets the initial value of the counter used by the basic interface
        whenever it is reset.
       </simpara>
      </listitem>
     </varlistentry>
    </variablelist>

   </section>

   <section xml:id="internals2.counter.resources">
    &reftitle.resources;
   
    <simpara>
     The "counter" extension defines one resource type: a counter.
    </simpara>
   </section>

  </chapter>
  
  <appendix xml:id="internals2.counter.constants">
   &reftitle.constants;
   &extension.constants;

   <variablelist>
    <varlistentry>
     <term>
      <constant>COUNTER_FLAG_PERSIST</constant>
      (<type>integer</type>)
     </term>
     <listitem>
      <simpara>
       A counter with this flag will be created as a persistent resource.
      </simpara>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term>
      <constant>COUNTER_FLAG_SAVE</constant>
      (<type>integer</type>)
     </term>
     <listitem>
      <simpara>
       A counter with this flag will be saved between invocations of PHP.
      </simpara>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term>
      <constant>COUNTER_FLAG_NO_OVERWRITE</constant>
      (<type>integer</type>)
     </term>
     <listitem>
      <simpara>
       This flag causes <function>counter_create</function> to avoid overwriting
       an existing named counter with a new one.
      </simpara>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term>
      <constant>COUNTER_META_NAME</constant>
      (<type>string</type>)
     </term>
     <listitem>
      <simpara>
       Pass this constant to get the name of a counter resource or object.
      </simpara>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term>
      <constant>COUNTER_META_IS_PERISTENT</constant>
      (<type>string</type>)
     </term>
     <listitem>
      <simpara>
       Pass this constant to determine whether a counter resource or object is
       persistent (has the <constant>COUNTER_FLAG_PERSIST</constant> flag).
      </simpara>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term>
      <constant>COUNTER_RESET_NEVER</constant>
      (<type>integer</type>)
     </term>
     <listitem>
      <simpara>
       The counter will never be reset.
      </simpara>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term>
      <constant>COUNTER_RESET_PER_LOAD</constant>
      (<type>integer</type>)
     </term>
     <listitem>
      <simpara>
       The counter will be reset on each invocation of PHP.
      </simpara>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term>
      <constant>COUNTER_RESET_PER_REQUEST</constant>
      (<type>integer</type>)
     </term>
     <listitem>
      <simpara>
       The counter will be reset on each request.
      </simpara>
     </listitem>
    </varlistentry>
   </variablelist>
  </appendix>

  <chapter xml:id="internals2.counter.examples">
   &reftitle.examples;
   
   <section xml:id="internals2.counter.examples.basic">
    <title>Basic interface</title>
    
    <simpara>
     The basic interface provides three simple functions, illustrated here:
    </simpara>
   
    <example xml:id="internals2.counter.examples.basic.ex">
     <title>"counter"'s basic interface</title>
     <programlisting role="php">
<![CDATA[
<?php
$starting_counter_value = counter_get();
counter_bump(1);
$second_counter_value = counter_get();
counter_reset();
$final_counter_value = counter_get();
printf("%3d %3d %3d", $starting_counter_value, $second_counter_value, $final_counter_value);
?>
]]>
     </programlisting>
    </example>
    &example.outputs;
    <screen>
<![CDATA[
  0   1   0]]></screen>
   
    <simpara>
     The basic interface also provides a number of
     <link linkend="internals2.counter.constants">INI settings</link>.
    </simpara>
   </section>
   
   <section xml:id="internals2.counter.examples.extended">
    <title>Extended interface</title>
    
    <simpara>
     The extended interface provides a small suite of functions that allow the
     user to define an arbitrary number of named counters with unique settings.
     The basic interface can be used in parallel with the extended interface.
    </simpara>
    
    <example xml:id="internals2.counter.examples.extended.ex">
     <title>"counter"'s extended interface</title>
     <programlisting role="php">
<![CDATA[
<?php
function print_counter_info($counter)
{
    if (is_resource($counter)) {
        printf("Counter's name is '%s' and is%s persistent. Its current value is %d.\n",
            counter_get_meta($counter, COUNTER_META_NAME),
            counter_get_meta($counter, COUNTER_META_IS_PERSISTENT) ? '' : ' not',
            counter_get_value($counter));
    } else {
      print "Not a valid counter!\n";
    }
}

if (($counter_one = counter_get_named("one")) === NULL) {
    $counter_one = counter_create("one", 0, COUNTER_FLAG_PERSIST);
}
counter_bump_value($counter_one, 2);
$counter_two = counter_create("two", 5);
$counter_three = counter_get_named("three");
$counter_four = counter_create("four", 2, COUNTER_FLAG_PERSIST | COUNTER_FLAG_SAVE | COUNTER_FLAG_NO_OVERWRITE);
counter_bump_value($counter_four, 1);

print_counter_info($counter_one);
print_counter_info($counter_two);
print_counter_info($counter_three);
print_counter_info($counter_four);
?>
]]>
     </programlisting>
     <simpara>
      When run once, the above example outputs:
     </simpara>
     <screen>
<![CDATA[
Counter's name is 'one' and is persistent. Its current value is 2.
Counter's name is 'two' and is not persistent. Its current value is 5.
Not a valid counter!
Counter's name is 'four' and is persistent. Its current value is 3.]]></screen>
     <simpara>
      If run a second time within the same instance of PHP, it outputs:
     </simpara>
     <screen>
<![CDATA[
Counter's name is 'one' and is persistent. Its current value is 4.
Counter's name is 'two' and is not persistent. Its current value is 5.
Not a valid counter!
Counter's name is 'four' and is persistent. Its current value is 4.]]></screen>
     <simpara>
      If then run a third time <emphasis>in a different instance of
      PHP</emphasis>, it outputs:
     </simpara>
     <screen>
<![CDATA[
Counter's name is 'one' and is persistent. Its current value is 2.
Counter's name is 'two' and is not persistent. Its current value is 5.
Not a valid counter!
Counter's name is 'four' and is persistent. Its current value is 5.]]></screen>
    </example>
   </section>
   
   <section xml:id="internals2.counter.examples.objective">
    <title>Objective interface</title>
    
    <simpara>
     The objective interface provides an object-oriented way to access the
     extended interfaces. The following example shows how the above one would be
     implemented using the objective interface. The output of this example is
     exactly the same, except that instead of printing "Not a valid counter!",
     this will instead issue a PHP warning that the variable
     <literal>$counter_three</literal> is not an object. This example shows that
     it is possible to subclass the <classname>Counter</classname> class defined
     by the extension, as well as that the counter's value is maintained using
     an instance variable rather than method access.
    </simpara>
    
    <example xml:id="internals2.counter.examples.objective.ex">
     <title>"counter"'s objective interface</title>
     
     <programlisting role="php">
<![CDATA[
<?php
class MyCounter extends Counter
{
    public function printCounterInfo() {
        printf("Counter's name is '%s' and is%s persistent. Its current value is %d.\n",
            $this->getMeta(COUNTER_META_NAME),
            $this->getMeta(COUNTER_META_IS_PERSISTENT) ? '' : ' not',
            $this->value);
    }
}

Counter::setCounterClass("MyCounter");
if (($counter_one = Counter::getNamed("one")) === NULL) {
    $counter_one = new Counter("one", 0, COUNTER_FLAG_PERSIST);
}
$counter_one->bumpValue(2); // we aren't allowed to "set" the value directly
$counter_two = new Counter("two", 5);
$counter_three = Counter::getNamed("three");
$counter_four = new Counter("four", 2, COUNTER_FLAG_PERSIST | COUNTER_FLAG_SAVE | COUNTER_FLAG_NO_OVERWRITE);
$counter_four->bumpValue(1);

$counter_one->printCounterInfo();
$counter_two->printCounterInfo();
$counter_three->printCounterInfo();
$counter_four->printCounterInfo();
?>
]]>
     </programlisting>
    </example>
   </section>

  </chapter>
  
  <reference xml:id="internals2.counter.counter-class">
   <title>The Counter class</title>
   <titleabbrev>Counter</titleabbrev>
   
   <partintro>
    <section xml:id="internals2.counter.counter-class.intro">
     &reftitle.intro;
     <simpara>
      Represents a single counter object.
     </simpara>
    </section>
   
    <section xml:id="internals2.counter.counter-class.synopsis">
     &reftitle.classsynopsis;
     
     <classsynopsis>
      <ooclass><classname>Counter</classname></ooclass>
     
      <classsynopsisinfo>
       <ooclass><classname>Counter</classname></ooclass>
      </classsynopsisinfo>
 
      <xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('internals2.counter.counter-class')/db:refentry/db:refsect1[@role='description']/descendant::db:constructorsynopsis[1])" />
      <xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('internals2.counter.counter-class')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[1])" />
     </classsynopsis>
    </section>
   </partintro>
   
   <refentry xml:id="internals2.counter.counter-class.construct" role="noversion">
    <refnamediv>
     <refname>Counter::__construct</refname>
     <refpurpose>
      Creates an instance of a Counter which maintains a single numeric value.
     </refpurpose>
    </refnamediv>
    <refsect1 role="description">
     &reftitle.description;
     <constructorsynopsis>
      <methodname>Counter::__construct</methodname>
      <methodparam><type>string</type><parameter>name</parameter></methodparam>
      <methodparam choice="opt"><type>integer</type><parameter>initial_value</parameter></methodparam>
      <methodparam choice="opt"><type>integer</type><parameter>flags</parameter></methodparam>
     </constructorsynopsis>
     <simpara>
      Creates an instance of a Counter which maintains a single numeric value.
     </simpara>
    </refsect1>
    <refsect1 role="parameters">
     &reftitle.parameters;
     <variablelist>
      <varlistentry>
       <term>name</term>
       <listitem>
        <simpara>
         The new counter's name.
        </simpara>
       </listitem>
      </varlistentry>
      <varlistentry>
       <term>initial_value</term>
       <listitem>
        <simpara>
         The initial value of the counter. Defaults to zero (0).
        </simpara>
       </listitem>
      </varlistentry>
      <varlistentry>
       <term>flags</term>
       <listitem>
        <simpara>
         Flags for the new counter, chosen from the
         <literal>COUNTER_FLAG_*</literal> constants.
        </simpara>
       </listitem>
      </varlistentry>
     </variablelist>
    </refsect1>
    <refsect1 role="returnvalues">
     &reftitle.returnvalues;
     <simpara>
      Returns a Counter object on success.
     </simpara>
    </refsect1>
    <refsect1 role="errors">
     &reftitle.errors;
     <simpara>
      <function>Counter::__construct</function> throws an Exception if something
      goes wrong.
     </simpara>
    </refsect1>
   </refentry>

   <refentry xml:id="internals2.counter.counter-class.getvalue" role="noversion">
    <refnamediv>
     <refname>Counter::getValue</refname>
     <refpurpose>
      Get the current value of a counter.
     </refpurpose>
    </refnamediv>
    <refsect1 role="description">
     &reftitle.description;
     <methodsynopsis>
      <type>integer</type><methodname>Counter::getValue</methodname>
      <void/>
     </methodsynopsis>
     <simpara>
      <function>Counter::getValue</function> returns the current value of a
      counter.
     </simpara>
    </refsect1>
    <refsect1 role="returnvalues">
     &reftitle.returnvalues;
     <simpara>
      <function>Counter::getValue</function> returns an integer.
     </simpara>
    </refsect1>
    <refsect1 role="seealso">
     &reftitle.seealso;
     <simplelist>
      <member><function>Counter::bumpValue</function></member>
      <member><function>Counter::resetValue</function></member>
     </simplelist>
    </refsect1>
   </refentry>

   <refentry xml:id="internals2.counter.counter-class.bumpvalue" role="noversion">
    <refnamediv>
     <refname>Counter::bumpValue</refname>
     <refpurpose>
      Change the current value of a counter.
     </refpurpose>
    </refnamediv>
    <refsect1 role="description">
     &reftitle.description;
     <methodsynopsis>
      <methodname>Counter::bumpValue</methodname>
      <methodparam><type>integer</type><parameter>offset</parameter></methodparam>
     </methodsynopsis>
     <simpara>
      <function>Counter::bumpValue</function> updates the current value of a
      counter.
     </simpara>
    </refsect1>
    <refsect1 role="parameters">
     &reftitle.parameters;
     <variablelist>
      <varlistentry>
       <term><parameter>offset</parameter></term>
       <listitem>
        <simpara>
         The amount by which to change the counter's value. Can be negative.
        </simpara>
       </listitem>
      </varlistentry>
     </variablelist>
    </refsect1>
    <refsect1 role="seealso">
     &reftitle.seealso;
     <simplelist>
      <member><function>Counter::getValue</function></member>
      <member><function>Counter::resetValue</function></member>
     </simplelist>
    </refsect1>
   </refentry>

   <refentry xml:id="internals2.counter.counter-class.resetvalue" role="noversion">
    <refnamediv>
     <refname>Counter::resetValue</refname>
     <refpurpose>
      Reset the current value of a counter.
     </refpurpose>
    </refnamediv>
    <refsect1 role="description">
     &reftitle.description;
     <methodsynopsis>
      <void /><methodname>Counter::resetValue</methodname>
      <void/>
     </methodsynopsis>
     <simpara>
      <function>Counter::resetValue</function> resets the current value of a
      counter to its original initial value.
     </simpara>
    </refsect1>
    <refsect1 role="seealso">
     &reftitle.seealso;
     <simplelist>
      <member><function>Counter::getValue</function></member>
      <member><function>Counter::bumpValue</function></member>
     </simplelist>
    </refsect1>
   </refentry>
   
   <refentry xml:id="internals2.counter.counter-class.getmeta" role="noversion">
    <refnamediv>
     <refname>Counter::getMeta</refname>
     <refpurpose>
      Return a piece of metainformation about a counter.
     </refpurpose>
    </refnamediv>
    <refsect1 role="description">
     &reftitle.description;
     <methodsynopsis>
      <type>mixed</type><methodname>Counter::getMeta</methodname>
      <methodparam><type>integer</type><parameter>attribute</parameter></methodparam>
     </methodsynopsis>
     <simpara>
      <function>Counter::getMeta</function> returns metainformation about a
      counter.
     </simpara>
    </refsect1>
    <refsect1 role="parameters">
     &reftitle.parameters;
     <variablelist>
      <varlistentry>
       <term><parameter>attribute</parameter></term>
       <listitem>
        <simpara>
         The metainformation to retrieve.
        </simpara>
       </listitem>
      </varlistentry>
     </variablelist>
    </refsect1>
    <refsect1 role="returnvalues">
     &reftitle.returnvalues;
     <simpara>
      <function>Counter::getMeta</function> returns values of varying types
      based on which metainformation was requested.
     </simpara>
    </refsect1>
   </refentry>
   
   <refentry xml:id="internals2.counter.counter-class.getnamed" role="noversion">
    <refnamediv>
     <refname>Counter::getNamed</refname>
     <refpurpose>
      Retrieve an existing named counter.
     </refpurpose>
    </refnamediv>
    <refsect1 role="description">
     &reftitle.description;
     <methodsynopsis>
      <modifier>static</modifier>
      <type>Counter</type><methodname>Counter::getNamed</methodname>
      <methodparam><type>string</type><parameter>name</parameter></methodparam>
     </methodsynopsis>
     <simpara>
      <function>Counter::getNamed</function> returns an existing counter by name
      if that name exists, or &null; otherwise. This is a static function.
     </simpara>
    </refsect1>
    <refsect1 role="parameters">
     &reftitle.parameters;
     <variablelist>
      <varlistentry>
       <term><parameter>name</parameter></term>
       <listitem>
        <simpara>
         The counter name to search for.
        </simpara>
       </listitem>
      </varlistentry>
     </variablelist>
    </refsect1>
    <refsect1 role="returnvalues">
     &reftitle.returnvalues;
     <simpara>
      <function>Counter::getNamed</function> returns an existing counter by name
      if that name exists, or &null; otherwise.
     </simpara>
    </refsect1>
   </refentry>

   <refentry xml:id="internals2.counter.counter-class.setcounterclass" role="noversion">
    <refnamediv>
     <refname>Counter::setCounterClass</refname>
     <refpurpose>
      Set the class returned by <methodname>Counter::getNamed</methodname>.
     </refpurpose>
    </refnamediv>
    <refsect1 role="description">
     &reftitle.description;
     <methodsynopsis>
      <modifier>static</modifier>
      <void /><methodname>Counter::setCounterClass</methodname>
      <methodparam><type>string</type><parameter>name</parameter></methodparam>
     </methodsynopsis>
     <simpara>
      <function>Counter::setCounterClass</function> changes the class of objects
      returned by <function>Counter::getNamed</function>. The class being set
      must not have a public constructor and must be a subclass of
      <classname>Counter</classname>. If these conditions are not met, a fatal
      error is raised. This is a static function.
     </simpara>
    </refsect1>
    <refsect1 role="parameters">
     &reftitle.parameters;
     <variablelist>
      <varlistentry>
       <term><parameter>name</parameter></term>
       <listitem>
        <simpara>
         The name of the class to use.
        </simpara>
       </listitem>
      </varlistentry>
     </variablelist>
    </refsect1>
   </refentry>

  </reference>
  
  <reference xml:id="internals2.counter.basic-interface">
   <title>The basic interface</title>
   <titleabbrev>Basic</titleabbrev>

   <refentry xml:id="internals2.counter.function.counter-get" role="noversion">
    <refnamediv>
     <refname>counter_get</refname>
     <refpurpose>
      Get the current value of the basic counter.
     </refpurpose>
    </refnamediv>
    <refsect1 role="description">
     &reftitle.description;
     <methodsynopsis>
      <type>integer</type><methodname>counter_get</methodname>
      <void/>
     </methodsynopsis>
     <simpara>
      <function>counter_get</function> returns the current value of the basic
      interface's counter.
     </simpara>
    </refsect1>
    <refsect1 role="returnvalues">
     &reftitle.returnvalues;
     <simpara>
      <function>counter_get</function> returns an integer.
     </simpara>
    </refsect1>
    <refsect1 role="seealso">
     &reftitle.seealso;
     <simplelist>
      <member><function>counter_bump</function></member>
      <member><function>counter_reset</function></member>
     </simplelist>
    </refsect1>
   </refentry>

   <refentry xml:id="internals2.counter.function.counter-bump" role="noversion">
    <refnamediv>
     <refname>counter_bump</refname>
     <refpurpose>
      Update the current value of the basic counter.
     </refpurpose>
    </refnamediv>
    <refsect1 role="description">
     &reftitle.description;
     <methodsynopsis>
      <void /><methodname>counter_bump</methodname>
      <methodparam><type>integer</type><parameter>offset</parameter></methodparam>
     </methodsynopsis>
     <simpara>
      <function>counter_bump</function> updates the current value of the basic
      interface's counter.
     </simpara>
    </refsect1>
    <refsect1 role="parameters">
     &reftitle.parameters;
     <variablelist>
      <varlistentry>
       <term><parameter>offset</parameter></term>
       <listitem>
        <simpara>
         The amount by which to change the counter's value. Can be negative.
        </simpara>
       </listitem>
      </varlistentry>
     </variablelist>
    </refsect1>
    <refsect1 role="seealso">
     &reftitle.seealso;
     <simplelist>
      <member><function>counter_get</function></member>
      <member><function>counter_reset</function></member>
     </simplelist>
    </refsect1>
   </refentry>
  
   <refentry xml:id="internals2.counter.function.counter-reset" role="noversion">
    <refnamediv>
     <refname>counter_reset</refname>
     <refpurpose>
      Reset the current value of the basic counter.
     </refpurpose>
    </refnamediv>
    <refsect1 role="description">
     &reftitle.description;
     <methodsynopsis>
      <void /><methodname>counter_reset</methodname>
      <void/>
     </methodsynopsis>
     <simpara>
      <function>counter_reset</function> resets the current value of the basic
      interface's counter to its original initial value.
     </simpara>
    </refsect1>
    <refsect1 role="seealso">
     &reftitle.seealso;
     <simplelist>
      <member><function>counter_get</function></member>
      <member><function>counter_bump</function></member>
     </simplelist>
    </refsect1>
   </refentry>

  </reference>

  <reference xml:id="internals2.counter.extended-interface">
   <title>The extended interface</title>
   <titleabbrev>Extended</titleabbrev>

   <refentry xml:id="internals2.counter.function.counter-create" role="noversion">
    <refnamediv>
     <refname>counter_create</refname>
     <refpurpose>
      Creates a counter which maintains a single numeric value.
     </refpurpose>
    </refnamediv>
    <refsect1 role="description">
     &reftitle.description;
     <methodsynopsis>
      <type>resource</type><methodname>counter_create</methodname>
      <methodparam><type>string</type><parameter>name</parameter></methodparam>
      <methodparam choice="opt"><type>integer</type><parameter>initial_value</parameter></methodparam>
      <methodparam choice="opt"><type>integer</type><parameter>flags</parameter></methodparam>
     </methodsynopsis>
     <simpara>
      Creates a counter which maintains a single numeric value.
     </simpara>
    </refsect1>
    <refsect1 role="parameters">
     &reftitle.parameters;
     <variablelist>
      <varlistentry>
       <term>name</term>
       <listitem>
        <simpara>
         The new counter's name.
        </simpara>
       </listitem>
      </varlistentry>
      <varlistentry>
       <term>initial_value</term>
       <listitem>
        <simpara>
         The initial value of the counter. Defaults to zero (0).
        </simpara>
       </listitem>
      </varlistentry>
      <varlistentry>
       <term>flags</term>
       <listitem>
        <simpara>
         Flags for the new counter, chosen from the
         <literal>COUNTER_FLAG_*</literal> constants.
        </simpara>
       </listitem>
      </varlistentry>
     </variablelist>
    </refsect1>
    <refsect1 role="returnvalues">
     &reftitle.returnvalues;
     <simpara>
      Returns a counter resource.
     </simpara>
    </refsect1>
   </refentry>

   <refentry xml:id="internals2.counter.function.counter-get-value" role="noversion">
    <refnamediv>
     <refname>counter_get_value</refname>
     <refpurpose>
      Get the current value of a counter resource.
     </refpurpose>
    </refnamediv>
    <refsect1 role="description">
     &reftitle.description;
     <methodsynopsis>
      <type>integer</type><methodname>counter_get_value</methodname>
      <methodparam><type>resource</type><parameter>counter</parameter></methodparam>
     </methodsynopsis>
     <simpara>
      <function>counter_get_value</function> returns the current value of a
      counter resource.
     </simpara>
    </refsect1>
    <refsect1 role="parameters">
     &reftitle.parameters;
     <variablelist>
      <varlistentry>
       <term><parameter>counter</parameter></term>
       <listitem> 
        <simpara>
         The counter resource to operate on.
        </simpara>
       </listitem>
      </varlistentry>
     </variablelist>
    </refsect1>
    <refsect1 role="returnvalues">
     &reftitle.returnvalues;
     <simpara>
      <function>counter_get_value</function> returns an integer.
     </simpara>
    </refsect1>
    <refsect1 role="seealso">
     &reftitle.seealso;
     <simplelist>
      <member><function>counter_bump_value</function></member>
      <member><function>counter_reset_value</function></member>
     </simplelist>
    </refsect1>
   </refentry>

   <refentry xml:id="internals2.counter.function.counter-bump-value" role="noversion">
    <refnamediv>
     <refname>counter_bump_value</refname>
     <refpurpose>
      Change the current value of a counter resource.
     </refpurpose>
    </refnamediv>
    <refsect1 role="description">
     &reftitle.description;
     <methodsynopsis>
      <void /><methodname>counter_bump_value</methodname>
      <methodparam><type>resource</type><parameter>counter</parameter></methodparam>
      <methodparam><type>integer</type><parameter>offset</parameter></methodparam>
     </methodsynopsis>
     <simpara>
      <function>counter_bump_value</function> updates the current value of a
      counter resource.
     </simpara>
    </refsect1>
    <refsect1 role="parameters">
     &reftitle.parameters;
     <variablelist>
      <varlistentry>
       <term><parameter>counter</parameter></term>
       <listitem> 
        <simpara>
         The counter resource to operate on.
        </simpara>
       </listitem>
      </varlistentry>
      <varlistentry>
       <term><parameter>offset</parameter></term>
       <listitem>
        <simpara>
         The amount by which to change the counter's value. Can be negative.
        </simpara>
       </listitem>
      </varlistentry>
     </variablelist>
    </refsect1>
    <refsect1 role="seealso">
     &reftitle.seealso;
     <simplelist>
      <member><function>counter_get_value</function></member>
      <member><function>counter_reset_value</function></member>
     </simplelist>
    </refsect1>
   </refentry>

   <refentry xml:id="internals2.counter.function.counter-reset-value" role="noversion">
    <refnamediv>
     <refname>counter_reset_value</refname>
     <refpurpose>
      Reset the current value of a counter resource.
     </refpurpose>
    </refnamediv>
    <refsect1 role="description">
     &reftitle.description;
     <methodsynopsis>
      <void /><methodname>counter_reset_value</methodname>
      <methodparam><type>resource</type><parameter>counter</parameter></methodparam>
     </methodsynopsis>
     <simpara>
      <function>counter_reset_value</function> resets the current value of a
      counter resource to its original initial value.
     </simpara>
    </refsect1>
    <refsect1 role="parameters">
     &reftitle.parameters;
     <variablelist>
      <varlistentry>
       <term><parameter>counter</parameter></term>
       <listitem> 
        <simpara>
         The counter resource to operate on.
        </simpara>
       </listitem>
      </varlistentry>
     </variablelist>
    </refsect1>
    <refsect1 role="seealso">
     &reftitle.seealso;
     <simplelist>
      <member><function>counter_get_value</function></member>
      <member><function>counter_bump_value</function></member>
     </simplelist>
    </refsect1>
   </refentry>
   
   <refentry xml:id="internals2.counter.function.counter-get-meta" role="noversion">
    <refnamediv>
     <refname>counter_get_meta</refname>
     <refpurpose>
      Return a piece of metainformation about a counter resource.
     </refpurpose>
    </refnamediv>
    <refsect1 role="description">
     &reftitle.description;
     <methodsynopsis>
      <type>mixed</type><methodname>counter_get_meta</methodname>
      <methodparam><type>resource</type><parameter>counter</parameter></methodparam>
      <methodparam><type>integer</type><parameter>attribute</parameter></methodparam>
     </methodsynopsis>
     <simpara>
      <function>counter_get_meta</function> returns metainformation about a
      counter resource.
     </simpara>
    </refsect1>
    <refsect1 role="parameters">
     &reftitle.parameters;
     <variablelist>
      <varlistentry>
       <term><parameter>counter</parameter></term>
       <listitem> 
        <simpara>
         The counter resource to operate on.
        </simpara>
       </listitem>
      </varlistentry>
      <varlistentry>
       <term><parameter>attribute</parameter></term>
       <listitem>
        <simpara>
         The metainformation to retrieve.
        </simpara>
       </listitem>
      </varlistentry>
     </variablelist>
    </refsect1>
    <refsect1 role="returnvalues">
     &reftitle.returnvalues;
     <simpara>
      <function>counter_get_meta</function> returns values of varying types
      based on which metainformation was requested.
     </simpara>
    </refsect1>
   </refentry>
   
   <refentry xml:id="internals2.counter.function.counter-get-named" role="noversion">
    <refnamediv>
     <refname>counter_get_named</refname>
     <refpurpose>
      Retrieve an existing named counter as a resource.
     </refpurpose>
    </refnamediv>
    <refsect1 role="description">
     &reftitle.description;
     <methodsynopsis>
      <type>resource</type><methodname>Counter::getNamed</methodname>
      <methodparam><type>string</type><parameter>name</parameter></methodparam>
     </methodsynopsis>
     <simpara>
      <function>counter_get_named</function> returns an existing counter by name
      if that name exists, or &null; otherwise.
     </simpara>
    </refsect1>
    <refsect1 role="parameters">
     &reftitle.parameters;
     <variablelist>
      <varlistentry>
       <term><parameter>name</parameter></term>
       <listitem>
        <simpara>
         The counter name to search for.
        </simpara>
       </listitem>
      </varlistentry>
     </variablelist>
    </refsect1>
    <refsect1 role="returnvalues">
     &reftitle.returnvalues;
     <simpara>
      <function>counter_get_name</function> returns an existing counter by name
      if that name exists, or &null; otherwise.
     </simpara>
    </refsect1>
   </refentry>

  </reference>

 </part>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->