-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathformatguide.xml
More file actions
1875 lines (1763 loc) · 88.6 KB
/
formatguide.xml
File metadata and controls
1875 lines (1763 loc) · 88.6 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
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
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="styleguide.xsl"?>
<GUIDE title="STAR C++ Naming & Formatting Guidelines">
<address>
Authors:<br/>
Mustafa Mustafa <br/>
Thomas Ullrich <br/>
Anselm Vossen <br/>
</address>
<address><p><em>Version 1.0, June 24, 2015</em></p></address>
<CATEGORY title="Introduction">
<p>
This is a document of the naming & formatting guidelines compiled for the STAR
collaboration by the above mentioned authors. This effort was initiated by the STAR
computing coordinator Jerome Lauret on October 31, 2014. The charge can be
viewed <a href="charge.txt">here</a>. The committee produced two documents, one for the
naming & formatting guidelines seen here, and one for C++ coding guidelines that
can be viewed <a href="codingguide.xml">here</a>.
</p>
<p>
The committee based their work on the existing guidelines, expanded them for clarity, and
added new material where it saw fit. We have made heavy use of the Google Style guide
at <a href="http://google-styleguide.googlecode.com"> http://google-styleguide.googlecode.com</a>
using their xml and css style sheets. Some of the guidelines included are from the original
Google document, some were modified versions by the ALICE collaboration. Where they matched
the STAR guidelines we used their text to minimize efforts.
</p>
<p>
The goal of this guide is to provide a number of rules that keep the code base manageable
by enforcing <em>consistency</em>.
It is very important that any programmer
can look at another programmer's code and understand it quickly.
Maintaining a uniform style and following conventions means that "pattern-matching" can be
more easily used to identify different symbols and invariants.
</p>
<p>
Creating common, required
idioms and patterns makes code much easier to understand. In some
cases there might be good arguments for changing certain style rules.
Nonetheless, for reasons of consistency the rules are left unchanged.
</p>
</CATEGORY>
<OVERVIEW>
<CATEGORY title="Important Note">
<STYLEPOINT title="Displaying Hidden Details in this Guide">
<SUMMARY>
This style guide contains many details that are initially
hidden from view. They are marked by the triangle icon, which you
see here on your left. The first level of hidden information is
the subsection <i>Summary</i> in each rule and the second level of hidden information is the
optional subsection <i>Extra details and exceptions to the rule</i>. Click the arrow on the
left now, you should see "Hooray" appear below.
</SUMMARY>
<BODY>
<p>
Hooray! Now you know you can expand points to get more
details. Alternatively, there are an "expand all summaries"
and an "expand all summaries and extra details" at the
top of this document.
</p>
</BODY>
</STYLEPOINT>
</CATEGORY>
</OVERVIEW>
<CATEGORY title="Naming">
<p>
The most important consistency rules are those that govern
naming. The style of a name immediately informs us what sort of
thing the named entity is: a type, a variable, a function, a macro, etc., without requiring us to search for the
declaration of that entity. The pattern-matching engine in our
brains relies a great deal on these naming rules.
</p>
<p>
Naming rules are pretty arbitrary, but we feel that consistency is more important than individual preferences in this area, so regardless of whether you find them sensible or not, the rules are the rules.
</p>
<STYLEPOINT title="General Naming Rules">
<SUMMARY>
Names should be meaningful; abbreviations should be avoided.
They follow camel case convention. Types and variables, as well as
access functions should be nouns,
while functions should be "command" verbs.
</SUMMARY>
<BODY>
<SUBSECTION title="How to Name">
<p>
Within reason, give as descriptive a name as possible. Do
not worry about saving horizontal space as it is far more
important to make your code immediately understandable to a
new reader. Examples of well-chosen names:
</p>
<CODE_SNIPPET>
int numberOfErrors; // Good.
int numberOfCompletedConnections; // Good.
</CODE_SNIPPET>
<p>
Poorly chosen names use ambiguous abbreviations or arbitrary
characters that do not convey meaning.
Do not use directly the variable names from mathematical formulas.
In mathematics, variable names are usually limited to a single letter.
To implement a mathematical formula use variable names that
clearly indicate what value it holds.
</p>
<CODE_SNIPPET>
float distance = velocity * time; // Good - no ambiguity
</CODE_SNIPPET>
<BAD_CODE_SNIPPET>
int n; // Bad - meaningless.
int nerr; // Bad - ambiguous abbreviation.
int nCompConns; // Bad - ambiguous abbreviation.
float s = v * t; // Bad - almost meaningless.
</BAD_CODE_SNIPPET>
<p>
Type and variable names should typically be nouns: e.g.,
<code>FileOpener</code>, <code>numberOfErrors</code>.
</p>
<p>
Function names should typically be imperative (that is they
should be commands): e.g., <code>openFile()</code>,
<code>setNumberOfErrors()</code>.
</p>
</SUBSECTION>
<SUBSECTION title="CamelCase Convention">
<p>
All names in C++ code follow camel case convention. This is
the practice of writing compound words so that each word
begins with a capital letter. No underscores are allowed.
</p>
<p>
For example:
</p>
<CODE_SNIPPET>
string tableName; // Good
</CODE_SNIPPET>
<BAD_CODE_SNIPPET>
string table_name; // Bad - uses underscore.
string tablename; // Bad - all lowercase.
</BAD_CODE_SNIPPET>
<p>Note, that STAR follows the CamelCase convention even for acronyms:
<code>StFmsHit</code>, <code>StTpcHit</code>, etc.</p>
</SUBSECTION>
<SUBSECTION title="Capitalization Rules">
<p>
Variables and functions start with a lowercase letter.<br/>
Everything else in C++ code (namespaces, type names, constant
expressions) starts with an uppercase letter.
</p>
</SUBSECTION>
<SUBSECTION title="Abbreviations">
<p>
Do not use abbreviations except for acronyms. For example:
</p>
<CODE_SNIPPET>
// Good. These show proper names with no abbreviations.
int numberOfDnsConnections; // Most people know what "DNS" stands for.
int priceCount; // Price count, it makes sense.
int daqRate; // In STAR everyone knows what DAQ stands for.
</CODE_SNIPPET>
<BAD_CODE_SNIPPET>
// Bad. Abbreviations can be confusing or ambiguous outside a small group.
int wgcConnections; // Only your group knows what this stands for.
int pcReader; // Lots of things can be abbreviated "pc".
</BAD_CODE_SNIPPET>
<p>
A single letter variable name can be used for well-known idioms like iterators of integer type and pimpl-idioms (d-pointer).
</p>
<CODE_SNIPPET>
for (int i = 0 ; i < 10 ; i++) { // Good.
prices[i] = 0;
}
</CODE_SNIPPET>
<BAD_CODE_SNIPPET>
for (auto i = &prices[0]; i < &prices[10]; ++i) { // Bad
*i = 0; // i is not of integer type
}
</BAD_CODE_SNIPPET>
</SUBSECTION>
</BODY>
</STYLEPOINT>
<STYLEPOINT title="Specific STAR Naming Rules">
<SUMMARY>
Each class name should begin with <code>St</code> and the appropriate three letter acronym (only first letter capitalized) to indicate its origin and prevent name clashes.
</SUMMARY>
<BODY>
<p>
The <code>St</code> will identify a STAR class to separate it from system, or external libraries classes, e.g.: <code>StTpcTrack</code>.
The three letter acronym typically reflects the context within STAR in which the class operates (sub-detector, sub-project)
and reduces the possibility of name clashes for common packages. Classes unrelated to specific packages may retain only the <code>St</code> prefix.</p>
</BODY>
</STYLEPOINT>
<STYLEPOINT title="File Names">
<p> </p>
<SUMMARY>
C++ code file names are derived from the class names. Following STAR's naming convention they hence always start
with <code>St</code>.
Each header file should contain only one or related class declarations for maintainability and for easier retrieval
of class definitions.
Files that contain only function code (e.g. Maker) and are unrelated to a specific class should start also with <code>St</code> followed by a descriptive name of the purpose of the code.
</SUMMARY>
<BODY>
<p>
C++ implementation files should end in <code>.cxx</code> and header files
should end in <code>.h</code>.
</p>
<p>
Inline functions should go directly into your
<code>.h</code> file.
</p>
<p>
Examples of acceptable file names:
</p>
<CODE_SNIPPET>
StTpcHit.h // The class declaration.
StTpcHit.cxx // The class definition.
</CODE_SNIPPET>
<p>
Having upper case letters in a file name might theoretically lead to problems for case-insensitive operating systems.
However, as the file name corresponds to the class name it seems important to keep the same case as well.
Moreover, having two valid class/file names that would collide on a not-case sensitive OS seems extremely unlikely.
</p>
</BODY>
</STYLEPOINT>
<STYLEPOINT title="Type Names">
<SUMMARY>
Type names follow camel case convention and start with an upper case letter:
<code>MyClass</code>, <code>MyEnum</code>.
</SUMMARY>
<BODY>
<p>
The names of all types — classes, structs, typedefs, and enums
— have the same naming convention. For example:
</p>
<CODE_SNIPPET>
// classes and structs
class UrlTable { ... }
class UrlTableTester { ... }
struct UrlTableProperties { ... }
// typedefs
typedef HashMap<UrlTableProperties *, string> PropertiesMap;
// enums
enum UrlTableErrors { ... }
</CODE_SNIPPET>
</BODY>
</STYLEPOINT>
<STYLEPOINT title="Variable Names">
<SUMMARY>
Variable names follow camel case convention and start with
a lower case letter: <code>myLocalVariable</code>.
<ul>
<li>Class member variables are prefixed with <code>m</code>.</li>
<li>No <code>m</code> prefix for struct members.</li>
<li>Global variables are prefixed with <code>g</code>.</li>
<li><code>constexpr</code> variables are capitalized.</li>
<li>No additional prefix for <code>const</code>.</li>
</ul>
</SUMMARY>
<BODY>
<SUBSECTION title="Local Variable names">
<p>
For example:
</p>
<CODE_SNIPPET>
string tableName; // Good.
</CODE_SNIPPET>
</SUBSECTION>
<SUBSECTION title="Class Data Members">
<p>
Data members (also called instance variables or member
variables) are prefixed with <code>m</code>.
If the data member is <code>static</code>, prefix the variable with <code>s</code> instead.
</p>
<CODE_SNIPPET>
class Something {
private:
string mTableName;
static int sGlobalState;
};
</CODE_SNIPPET>
</SUBSECTION>
<SUBSECTION title="Struct Variables">
<p>
Data members in structs are named like regular
variables.
</p>
<CODE_SNIPPET>
struct UrlTableProperties {
string name;
int numberOfEntries;
}
</CODE_SNIPPET>
</SUBSECTION>
<SUBSECTION title="Global Variables">
<p>
Global variables,
which should be rare in any case, are prefixed with <code>g</code>.
</p>
</SUBSECTION>
<SUBSECTION title="constexpr">
<p>
A variable declared as <code>constexpr</code> typically is only used as compile-time constant (but may be stored in read-only memory).
Therefore it uses the same convention as <code>enum</code>s and uses uppercase CamelCase.
</p>
<CODE_SNIPPET>
constexpr double LightSpeed = 2.99792458e+8;
</CODE_SNIPPET>
</SUBSECTION>
<SUBSECTION title="const">
<p>
A variable declared as <code>const</code> does not have any additional naming rules.
The prefixes describe the scope of the variable.
<code>const</code> is just one aspect of the type of the variable.
</p>
<p>
To provide a constant in the public interface consider <code>constexpr</code>,
<code>enum</code>, or a (<code>constexpr</code>) function instead.
</p>
</SUBSECTION>
</BODY>
</STYLEPOINT>
<STYLEPOINT title="Function Names">
<SUMMARY>
Regular functions follow camel case convention and start with a lower case
letter: <code>myFunction()</code>.
<ul><li>Accessors and mutators match the name of the variable. Accessors should follow the name of the variable (DO NOT prefix it with <code>get</code>) and mutators are prefixed with <code>set</code>, for example:
<code>myMemberVariable()</code>, <code>setMyMemberVariable()</code>.</li>
<li> Functions (including accessors) returning a boolean value should be prefixed with
<code>is</code> or <code>has</code>. </li>
</ul>
</SUMMARY>
<BODY>
<SUBSECTION title="Regular Functions">
<p>
Example of functions:
</p>
<CODE_SNIPPET>
addTableEntry();
deleteUrl();
</CODE_SNIPPET>
<p>
The rule applies also to <code>constexpr</code> functions:
</p>
<CODE_SNIPPET>
constexpr int getFive() { return 5; }
</CODE_SNIPPET>
</SUBSECTION>
<SUBSECTION title="Accessors and Mutators">
<p>
Accessors and mutators match
the name of the variable they are getting and setting. For the latter use
the prefixes <code>set</code>. Do not use the <code>get</code> prefix as done in ROOT.
The prefix <code>set</code> is not exclusive for mutators and could
be used for other functions, if applicable.
This shows an excerpt of a class whose instance variable is
<code>mNumberOfEntries</code>:
</p>
<CODE_SNIPPET>
class MyClass {
public:
...
int numberOfEntries() const { return mNumberOfEntries; }
void setNumberOfEntries(int val) { mNumberOfEntries = val; }
private:
int mNumberOfEntries;
};
</CODE_SNIPPET>
</SUBSECTION>
<SUBSECTION title="Functions returning a boolean value">
<p>
Functions returning a boolean value should be prefixed with
<code>is</code> or <code>has</code>:
</p>
<CODE_SNIPPET>
bool isOpen();
bool hasZero();
</CODE_SNIPPET>
<p> This rule applies also to class member functions where <code>is</code> or <code>has</code> replace <code>get</code>:
</p>
<CODE_SNIPPET>
class MyClass {
public:
void setValid(bool isValid) const { mValid = isValid; }
bool isValid() const { return mValid; }
private:
bool mValid;
};
</CODE_SNIPPET>
</SUBSECTION>
</BODY>
</STYLEPOINT>
<STYLEPOINT title="Namespace Names">
<SUMMARY>
Namespace names follow camel case convention and start with an upper case
letter: <code>MyNamespace</code>.
</SUMMARY>
<BODY>
<CODE_SNIPPET>
namespace MyNamespace {
void MyClass::doSomething()
{
...
}
}
</CODE_SNIPPET>
</BODY>
</STYLEPOINT>
<STYLEPOINT title="Enumerator Names">
<SUMMARY>
Enumerations and enumerators (the type and the values) follow camel case
convention and start with <code>St</code> followed by an upper case letter:
<code> StBeamPolarizationAxis</code>, <code>StDetectorId</code>.
<ul>
<li>Enumerators in unscoped enumerations should have a common
prefix/postfix derived from the enumerations name. </li>
<li>Enum classes are already scoped and therefore the enumerators do not
need a prefix/postfix.</li>
</ul>
</SUMMARY>
<BODY>
<DEFINITION>
A <i>scoped</i> enum is one that is declared with the <code>class</code>
keyword, as opposed to a <i>traditional</i> enum, which is unscoped and
doesn't include the <code>class</code> keyword in its declaration.
</DEFINITION>
<p>
Unscoped enumerators are exposed to the enclosing scope.
Therefore they should be prefixed or postfixed (decided by which position makes the code more prose-like)
with the enumeration's name (or a sensible part thereof).
All names use uppercase CamelCase.
</p>
<p>
Example of an unscoped enumeration:
</p>
<CODE_SNIPPET>
enum Something {
SomethingSmall, // the type name as prefix
SomethingBig,
SomethingElse
};
void add(Something);
...
add(SomethingSmall);
add(SomethingElse);
</CODE_SNIPPET>
<p>
Another example of an unscoped enumeration whose enumerators are prefixed with just a (sensible) part
of the type name.
</p>
<CODE_SNIPPET>
enum MallocAlignment {
AlignOnVector, // the "Align" prefix taken from the type name
AlignOnCacheline,
AlignOnPage
}
template<MallocAlignment A> void* malloc(size_t);
...
void* memory = malloc<AlignOnCacheline>(64);
</CODE_SNIPPET>
<p>
Enum classes (new in C++11) create scoped enumerators.
Therefore there is no need for prefixing or postfixing.
</p>
<CODE_SNIPPET>
enum class Something : int {
Small,
Big,
Unknown
};
void add(Something);
...
add(Something::Small);
add(Something::Unknown);
</CODE_SNIPPET>
The following enum is forbidden unless it is enclosed in a private namespace.
The names <code>Ok</code> and <code>OutOfMemory</code> are too generic to be added to the global namespace.
<BAD_CODE_SNIPPET>
enum UrlTableErrors {
Ok, // Bad.
OutOfMemory // Bad.
};
</BAD_CODE_SNIPPET>
</BODY>
</STYLEPOINT>
<STYLEPOINT title="Macro Names">
<SUMMARY>
All uppercase letters and underscores, prefixed with ST (for STAR) and the sub/project name, i.e. <code>ST_PROJECT_PKG1_MY_MACRO</code>.
</SUMMARY>
<BODY>
<p>
Macros must be named with all uppercase letters and underscores, prefixed with the
sub/project name.
</p>
<CODE_SNIPPET>
#define ST_TRIGGER_BIT_SHIFT_TODAY 2
</CODE_SNIPPET>
Be sure to never put an underscore as prefix nor use a double underscore.
First it doesn't follow our naming convention.
Second, and more importantly, it is reserved to compiler developers.
<BAD_CODE_SNIPPET>
#define _WRONG
#define WRONG__AGAIN
</BAD_CODE_SNIPPET>
</BODY>
</STYLEPOINT>
<STYLEPOINT title="STAR StRoot Makers Naming Standards">
<SUMMARY>
This section attempts to explain the code directory structure and layout in STAR
the rules and assumptions triggered in the make system (cons) solely on the basis
of the name choice the existing exceptions to the rules.
</SUMMARY>
<BODY>
<p>The following naming convention keeps consistency between STAR code and
packages written by many users.
Not only it enables users to
have a feel for what-does-what but also, it allows managers to define basic
default set of compilation rules depending
sometimes naming convention. Naming conventions
in general are fundamental to all large projects
and although N
users will surely have N best-solution,
the rules should be enforced as much as possible.</p>
<SUBSECTION title="The Directory Structure Under the StRoot Tree">
<p>The <code>StRoot/</code> tree Is of the following form:</p>
<table>
<tr>
<td><code>StRoot</code></td>
<td><code>XXX/</code></td>
<td>Only base class that should be freely named. Example: <code>StarClassLibrary</code>,
<code>StarRoot</code>, <code>Star2Root</code>.
<p>User discouraged, request should be accompanied with a strong reasoning.</p> </td>
</tr>
<tr>
<td> </td>
<td><code>StXXX/</code></td>
<td>A directory tree which will contain a base class many makers will use and derive from.
In this category, <code>XXX</code> can be anything. For example, <code>StChain</code>,
<code>StEvent</code>, <code>StEventUtilities</code>.
<p>User discouraged, request should be accompanied with a strong reasoning.</p>
</td>
</tr>
<tr>
<td> </td>
<td><code>StXXXMaker/</code></td>
<td>A tree for a Maker, that is, code compiled in this tree will be assembled as
one self-sufficient package. A maker is a particular class deriving from
<code>StMaker</code>. Its purpose is to run from within a chain (<code>StChain</code>)
of makers and perform a specific task.
<p>In this category, sub-name convention are as follows:</p>
<ul>
<li> <code>StXXXDbMaker</code> a maker containing the database
calls for the sub-system <code>XXX</code></li>
<li> <code>StXXXSimulationMaker</code> or <code>StXXXSimulatorMaker</code>
a simulation maker for the subsystem <code>XXX</code></li>
<li> <code>StXXXCalibMaker</code> or <code>StXXXCalibrationMaker</code>
a calibration maker for the sub-system <code>XXX</code></li>
<li> <code>StXXXMixerMaker</code> a data/simulation mixer code
for he sub-system <code>XXX</code></li>
<li> <code>StXXXDisplayMaker</code> a self-explained named
Graphical tool</li>
<li> <code>StXXTagMaker</code> a maker collecting tags for
the sub-system or analysis <code>XXX</code></li>
</ul>
while <code>XXX</code> is in principle a detector sub-system identification
(3 to 4 letters uniquely designating the sub-system), it may also be anything
but a detector sub-system (<code>StAssociationMaker</code>,
<code>StMiniMcMaker</code>, <code>StDbMaker</code>) or of the
form <code>XXX</code>=analysis or physics study.</td>
</tr>
<tr>
<td> </td>
<td><code>StXXXRaw*/</code></td>
<td>Any directory with named with the word Raw will make our make system
include the necessary path for the Run-Time-System DAQ reader files
automatically. This convention is additive to any other description
and convention herein.
<p>Example: <code>StEmcRawMaker</code> is a "maker" as described above)
and a code base using the DAQ reader and so would be the expectation
for <code>Stl3RawReaderMaker</code> or <code>StFgtRawMaker</code>.</p></td>
</tr>
<tr>
<td> </td>
<td><code>StXXXUtil/</code> and <code>StXXXUtilities/</code> </td>
<td>Code compiled in a Util or Utilities tree should be code which do
not perform any action (nor a maker) but constitute by itself a set
of utility classes and functions. Other classes may depend on a
Utility library.
<ul>
<li> <code>XXXUtil</code> : <code>XXX</code> IS a sub-system detector.</li>
<li> <code>XXXUtilities</code> : <code>XXX</code> IS NOT a detector
sub-system (this is reserved)</li>
</ul>
</td>
</tr>
<tr>
<td> </td>
<td><code>StXXXPool/</code></td>
<td>This tree will contain a set of sub-directories chosen by the user,
each sub-directory maybe a self-contained project with no relation
with anything else. Each sub-directory will therefore lead to the
creation of a separate library. The naming convention for the
library creation is as follow :
<ul>
<li> If the subdirectory is named like <code>StYYY</code>, the
library will inherit the same name. Beware of potential name
clash in this case</li>
<li> If the subdirectory has an arbitrary name <code>YYY</code>,
the final library name will be have the name <code>StXXXPoolYYY</code>.</li>
</ul>
The Pool category has some special compilation internal rules: if it
does not compile, it may be removed from compilation entirely. As such,
codes appearing in Pool directory trees cannot be part of a production
maker dependency. A typical usage for this structure is to provide a
Pool (or collection) of lose codes not used in production (utility
tools for sub-systems, analysis codes or utilities).
<code>XXX</code> can be easer a Physics Work Group acronym or a
detector sub-system acronym.</td>
</tr>
<tr>
<td> </td>
<td><code>StXXXClient</code>/</td>
<td>This tree will behave like the Pool trees in terms of library naming creation
(separate libraries will be created, one per compilable sub-directory).
<code>XXX</code> can be anything relevant for a sub-system. Client directories
MUST compile (unlike the pools) and may be part of a dependency of a data
processing chain. Its general goal is to provide a different tree structure
for a set of code providing a "service" widely used across makers.
For example, the Run Time System (RTS) have a Client tree containing DAQ
related reading codes.</td>
</tr>
</table>
</SUBSECTION>
<SUBSECTION title="Trees and Implicit/Hidden Rules">
<p> </p>
<table>
<tr>
<td><code>StRoot/</code> </td>
<td><code>StXXX/</code> and <code>/.</code></td>
<td><code>README</code></td>
<td>A basic documentation in plain text (not
mandatory). If exists, the software guide
will display the information contained in
this file</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><code>doc/</code></td>
<td>A directory containing more elaborate
documentation, either in html or in LaTeX.
Note that if a file named index.html
exists, the software guide will link to it.</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><code>local/</code></td>
<td>A subdirectory containing stand-alone
Makefiles for the package and/or
standalone configuration files.
<p>This directory is persona non grata. It was
introduced due to unfortunate momentary laps of reason,
power surge or extreme special transitional needs.
Do not use.</p>
</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><code>examples/</code></td>
<td>A directory having a collection of code
using the Maker or utility package of
interest (case insensitive)
</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><code>macros/</code></td>
<td>A directory containing root macros
example making use of the maker
</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><code>kumac/</code></td>
<td>This is an obsolete directory name (from
staf time) but still considered by the make
system. It may also appears in the pams/
tree structure.
</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><code>test/</code></td>
<td>This directory may contain test programs
(executables should in principle not
appear in our standard but be assembled)
<p>This directory is persona non grata. It was
introduced due to unfortunate momentary laps of reason,
power surge or extreme special transitional needs.
Do not use.</p>
</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><code>html/</code></td>
<td>A directory possibly containing cross-linked
information for Web purposes.
However, note that the documentation is,
since 2002, auto-generated via the
doxygen documentation system (see the
sofi page for more information).
</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><code>images/</code></td>
<td>A directory containing images such as
bitmap, pixmaps or other images used by
your program but NOT assembled by any
part of the build process. XPM files
necessary for Qt for example should not
be placed in this directory as explicit rules
exists in <code>cons</code> to handle those (but <code>cons</code>
will ignore the xpm placed in <code>images/</code>).
</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><code>wrk/</code> and
<code>run/</code></td>
<td>Discouraged for users.
</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><code>include/</code></td>
<td>A directory containing a set of common
include files.
<p>This directory is persona non grata. It was
introduced due to unfortunate momentary laps of reason,
power surge or extreme special transitional needs.
Do not use.</p>
</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>Any other name</td>
<td>Will be searched for code one level down
only.
All compiled code will be assembled in
one library named after to <code>StXXX...</code>.
Each sub-directory will be compiled
separately that is, each must contain code
using explicit include path as the only
default search paths for includes will be
the one described by <code>CPPPATH</code> and its
own directory.
<p>However, if there is a need for <code>StRoot/StXXX</code>
sub-directories compilation to include every available sub-paths
(other than the exceptions noted above) <a id="footnote_a">(a)</a> as a list
of default path in a compiler option or if you want a default
include/ directory <a id="footnote_b">(b)</a> to be always added in a
default include path compiler option statement, you may request this
feature to be enabled. To do that, send an email to the <code>starsoft-hn</code> mailing list.</p>
<p>Include statement can ALWAYS refer to
the relative path after the
<code>StRoot/portion</code> as the <code>StRoot/</code> path is
a default in <code>CPPPATH</code></p>.
</td>
</tr>
<tr>
<td> </td>
<td><code>StXXXPool/</code> and
<code>StXXXClient/</code> and
<code>./</code></td>
<td><code>doc/</code><br/>
<code>local/</code><br/>
<code>examples/</code><br/>
<code>macros/</code><br/>
<code> kumac/</code><br/>
<code>test/</code><br/>
<code>html/</code><br/>
<code>images/</code><br/>
<code>wrk/</code><br/>
<code>run/</code><br/>
<code>include/</code>
</td>
<td>As noted above (i.e. the content of those
directories will be skipped by the make
system).
<p>
<code>local/</code>, <code>test/</code>, and <code>include/</code>
are legacy names and should not be used.
</p>
<p>
<code>wrk/</code> and <code>run/</code> are are
discouraged for users.
</p>
</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>Any other name</td>
<td>The presence of every sub-directory will
create a different dynamic library. Note
that this is NOT the case with the other
name format (all compiled code would go
in a unique library name)
<p>The convention is as follows:</p>
<ul>
<li> If the name starts with <code>St</code>, for example
<code>StZZZ</code>, a library <code>StZZZ.so</code> will be
created containing every compiled code
available in <code>StZZZ</code> directory. In this form, the sub-directory
MUST be self-sufficient i.e. all code and include
(apart from the default paths) must be
in the sub-directory <code>StZZZ</code></li>
<li> If the name does NOT start with <code>St</code>, for
example <code>WWW</code>, a library
<code>StXXXPoolWWW.so</code> will be created
containing all compile code available in
<code>WWW</code> directory.</li>
</ul>
</td>
</tr>
</table>
</SUBSECTION>
<SUBSECTION title="Current Patterned Exceptions">
<p> </p>
<table>
<tr>
<td><code>StEventDisplay.* </code></td>
<td>Directories within this pattern will be compiled using the extra
include path pointed by the environment variable <code>QTDIR</code>.
The moc program will run on any include containing the <code>Q_OBJECT</code> directive,
<code>-DR__QT</code> define is added to <code>CXXFLAGS</code>. </td>
</tr>
<tr>
<td><code>StDbLib</code><br/>
<code>StDbBroker</code></td>
<td>Those are special. Compilation will consider MySQL includes and the
created dynamic library will be linked against MySQL </td>
</tr>
<tr>
<td><code>St.*Db.*</code></td>
<td>Any directory following this pattern will use the MySQL include as an extra include path for the <code>CPPPATH</code> directive </td>
</tr>
<tr>
<td><code>StTrsMaker</code> <br/>
<code>StRTSClient</code></td>
<td> Are two exceptions of kind (b) [<a href="#footnote_b">see above</a>]
and use their own <code>include/</code> directory as a general extraneous include path. </td>
</tr>
<tr>
<td><code>StHbtMaker</code></td>
<td> For this maker, a pre-defined list of sub-directories is being
added to the (<code>CPPPATH</code>).</td>
</tr>
<tr>
<td>
<code>StAssociationMaker</code><br/>
<code>StMuDSTMaker</code><br/>
<code>.*EmcUtil</code><br/>
<code>StEEmcPool</code><br/>
<code>StTofPool</code><br/>
<code>StRichPool</code><br/>
<code>Sti.* </code>
</td>
<td> This form will include in the <code>CPPPATH</code> every sub-directories
found one level below.
Only <code>macros/</code>, <code>examples/</code>, and <code>doc/</code>
are excluded within
this form noted in (a) [<a href="#footnote_a">see above</a>]. For the
Pool directory, the extraneous rule
mentioned here is additive to the one of Pool directories.</td>
</tr>
</table>
</SUBSECTION>
</BODY>
</STYLEPOINT>
</CATEGORY>
<CATEGORY title="Formatting">
<p>
Coding style and formatting are pretty arbitrary. However, a good project
is much easier to follow if everyone uses the same style. Individuals
may not agree with every aspect of the formatting rules, and some of
the rules may be hard to get used to. Even so, it is important that all
project contributors
follow the style rules so that
they
can all read and understand everyone's code easily.
</p>
<STYLEPOINT title="Line Length">
<SUMMARY>
Each line of text in your code should be at most 100 characters
long.
</SUMMARY>
<BODY>
<p>
Try keeping lines below 100 characters.
In some cases it may make sense to use much longer lines (e.g. for block editing).
But this should be confined to special sections in the code.
</p>
</BODY>
</STYLEPOINT>
<STYLEPOINT title="One Statement Per Line">
<SUMMARY>
Prefer one statement per line because it improves code readability.
</SUMMARY>
<BODY>
<CODE_SNIPPET>
// Good. One statement per line.
if (condition) {
doSomething();
}
else {
doAnotherThing;
}
</CODE_SNIPPET>
<BAD_CODE_SNIPPET>
// Bad. Two statements per line.
if (condition) doSomething(); else doAnotherThing;
</BAD_CODE_SNIPPET>
</BODY>
</STYLEPOINT>
<STYLEPOINT title="Spaces vs. Tabs">
<SUMMARY>
Indent code with at least 2 spaces. Prefer spaces over tabs.
</SUMMARY>
<BODY>
<p>
Spaces are used for indentation. Do not use tabs in your code.
You should set your editor to emit spaces when you hit the tab
key. The indent of a tab depends on the setting of the editor/viewer.
</p>
</BODY>
</STYLEPOINT>
<STYLEPOINT title="Function Declarations and Definitions">