root/doc/html/codingrules.html @ 368

Revision 368, 6.5 kB (checked in by smidl, 15 years ago)

doc

RevLine 
[32]1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
3<title>mixpp: Coding Rules (Mostly inherited from IT++)</title>
[290]4<link href="tabs.css" rel="stylesheet" type="text/css">
[32]5<link href="doxygen.css" rel="stylesheet" type="text/css">
6</head><body>
[290]7<!-- Generated by Doxygen 1.5.8 -->
[271]8<script type="text/javascript">
9<!--
10function changeDisplayState (e){
11  var num=this.id.replace(/[^[0-9]/g,'');
12  var button=this.firstChild;
13  var sectionDiv=document.getElementById('dynsection'+num);
14  if (sectionDiv.style.display=='none'||sectionDiv.style.display==''){
15    sectionDiv.style.display='block';
16    button.src='open.gif';
17  }else{
18    sectionDiv.style.display='none';
19    button.src='closed.gif';
20  }
21}
22function initDynSections(){
23  var divs=document.getElementsByTagName('div');
24  var sectionCounter=1;
25  for(var i=0;i<divs.length-1;i++){
26    if(divs[i].className=='dynheader'&&divs[i+1].className=='dynsection'){
27      var header=divs[i];
28      var section=divs[i+1];
29      var button=header.firstChild;
30      if (button!='IMG'){
31        divs[i].insertBefore(document.createTextNode(' '),divs[i].firstChild);
32        button=document.createElement('img');
33        divs[i].insertBefore(button,divs[i].firstChild);
34      }
35      header.style.cursor='pointer';
36      header.onclick=changeDisplayState;
37      header.id='dynheader'+sectionCounter;
38      button.src='closed.gif';
39      section.id='dynsection'+sectionCounter;
40      section.style.display='none';
41      section.style.marginLeft='14px';
42      sectionCounter++;
43    }
44  }
45}
46window.onload = initDynSections;
47-->
48</script>
[91]49<div class="navigation" id="top">
50  <div class="tabs">
51    <ul>
[271]52      <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
[290]53      <li class="current"><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
[219]54      <li><a href="modules.html"><span>Modules</span></a></li>
[290]55      <li><a href="annotated.html"><span>Classes</span></a></li>
[91]56      <li><a href="files.html"><span>Files</span></a></li>
57    </ul>
58  </div>
[32]59</div>
[91]60<div class="contents">
61<h1><a class="anchor" name="codingrules">Coding Rules (Mostly inherited from IT++) </a></h1>In the following sections we describe the naming conventions which are used for files, classes, structures, local variables, and global variables.<h2><a class="anchor" name="cr_variables">
[32]62Default Naming Rules for Variables</a></h2>
[368]63Generally, variables are named using lower-case letters and words are separated using under-score. But there are many exceptions, for instance abbreviations or classical matematical notations. Therefore, coding rules for variables are quite free. Examples:<p>
[32]64<ul>
65<li>
[368]66<code>`FFT_size'</code>  </li>
[32]67<li>
[368]68<code>`initial_RV'</code>  </li>
[32]69<li>
[368]70<code>`my_variable'</code>  </li>
[32]71</ul>
72<h2><a class="anchor" name="cr_files">
73Default Naming Rules for Files</a></h2>
[368]74Files are named using lower-case letters and words are separated using under-score. If an abbreviation is inevitable within file name, it is written with lower-case letters.<p>
[32]75Source files are named using <code>`.cpp'</code> suffix, whereas header files end with <code>`.h'</code> extension. Examples:<p>
76<ul>
77<li>
78<code>`my_file.h'</code>  </li>
79<li>
[368]80<code>`user_info.cpp'</code>  </li>
[32]81</ul>
[368]82<h2><a class="anchor" name="cr_file_templates">
83Form of the source files</a></h2>
84For all the library classes, both header file `[filename].h' and source file `[filename].cpp' should be implemented. And the following few rules should be respected<p>
85<ul>
86<li>
87if possible, each `inline ... ' dircetive should be located within the `.h' file, one obvious exception is the case of `inline [filename].h' written in `[filename].cpp' <p>
88</li>
89<li>
90firstly, system headers should be included (i.e. those with brackets `include &lt;header_name&gt;'), other headers (like `include my_header_name.h') should follow (this rule leads to the faster search of an error on some compilators) <p>
91</li>
92<li>
93source code itself should be placed in the `.cpp' file, `.h' should contains only class declarations and documentation (this rule has a few exceptions like inline functions, templates and some extremely short function bodies)<p>
94</li>
95</ul>
96<p>
97Rules considering formatting of the source code itself are stored in the file , which is a configuration file for code formating utility named ASTYLE. To apply them, download the proper version from its web page <a href="http://astyle.sourceforge.net/">http://astyle.sourceforge.net/</a><h2><a class="anchor" name="cr_functions">
[32]98Default Naming Rules for Functions</a></h2>
99Function names are named using lower-case letters and words are separated using under-score. Abbreviations, when used in function names, are also written with lower-case letters. This rule applies both to stand-alone functions as well as to member functions of classes. Example:<p>
100<ul>
101<li>
102<code>int my_function_name(int a, int b)</code>  </li>
103</ul>
104<h2><a class="anchor" name="cr_specialfunctions">
105Convention for sensitive functions</a></h2>
106For efficiency, some functions may return pointers to internal variables. Such functionality is indicated by underscore as the first letter in the the name.<p>
107<ul>
108<li>
109<code>mat* _internal_matrix()</code>  </li>
110</ul>
111<h2><a class="anchor" name="cr_classes">
112Default Naming Rules for Classes and Structures</a></h2>
[368]113Each new word in a class or structure name should always start with a capital letter and the words should not be separated. Abbreviations are written with capital letters. Examples:<p>
[32]114<ul>
115<li>
[368]116<code>`MyClassName'</code>  </li>
[32]117<li>
[368]118<code>`MyStructName'</code>  </li>
[32]119<li>
120<code>`OFDM'</code>  </li>
121</ul>
122<h2><a class="anchor" name="cr_classes_functionality">
123Default Functionality of Classes</a></h2>
124All classes that are configured by input parameters should include:<p>
125<ul>
126<li>
127default empty constructor  </li>
128<li>
129one or more additional constructor(s) that takes input parameters and initializes the class instance  </li>
130<li>
131setup function, preferably named <code>`setup'</code> or <code>`set_parameters'</code>  </li>
132</ul>
133<p>
[91]134Explicit destructor functions are not required, unless they are needed. It shall not be possible to use any of the other member functions unless the class has been properly initiated with the input parameters. </div>
[368]135<hr size="1"><address style="text-align: right;"><small>Generated on Mon Jun 8 18:02:34 2009 for mixpp by&nbsp;
[32]136<a href="http://www.doxygen.org/index.html">
[290]137<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address>
[32]138</body>
139</html>
Note: See TracBrowser for help on using the browser.