root/library/doc/html/codingrules.html @ 651

Revision 651, 6.5 kB (checked in by mido, 15 years ago)

\doc directory cleaned a bit

Line 
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>
4<link href="tabs.css" rel="stylesheet" type="text/css">
5<link href="doxygen.css" rel="stylesheet" type="text/css">
6</head><body>
7<!-- Generated by Doxygen 1.5.9 -->
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>
49<div class="navigation" id="top">
50  <div class="tabs">
51    <ul>
52      <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
53      <li class="current"><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
54      <li><a href="annotated.html"><span>Classes</span></a></li>
55      <li><a href="files.html"><span>Files</span></a></li>
56    </ul>
57  </div>
58  <div class="navpath"><a class="el" href="dev_guide2.html">BDM Development - Contribution guide</a>
59  </div>
60</div>
61<div class="contents">
62<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">
63Default Naming Rules for Variables</a></h2>
64Generally, 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>
65<ul>
66<li>
67<code>`FFT_size'</code>  </li>
68<li>
69<code>`initial_RV'</code>  </li>
70<li>
71<code>`my_variable'</code>  </li>
72</ul>
73<h2><a class="anchor" name="cr_files">
74Default Naming Rules for Files</a></h2>
75Files 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>
76Source files are named using <code>`.cpp'</code> suffix, whereas header files end with <code>`.h'</code> extension. Examples:<p>
77<ul>
78<li>
79<code>`my_file.h'</code>  </li>
80<li>
81<code>`user_info.cpp'</code>  </li>
82</ul>
83<h2><a class="anchor" name="cr_file_templates">
84Form of the source files</a></h2>
85For 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>
86<ul>
87<li>
88if possible, each `#include ... ' dircetive should be located within the `.h' file, one obvious exception is the case of `#include "[filename].h"' written in `[filename].cpp' <p>
89</li>
90<li>
91firstly, system headers should be included (i.e. those with brackets `#include &lt;system_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>
92</li>
93<li>
94source 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>
95</li>
96</ul>
97<p>
98Rules considering formatting of the source code itself are stored in the file /system/astylerc, 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">
99Default Naming Rules for Functions</a></h2>
100Function 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>
101<ul>
102<li>
103<code>int my_function_name(int a, int b)</code>  </li>
104</ul>
105<h2><a class="anchor" name="cr_specialfunctions">
106Convention for sensitive functions</a></h2>
107For efficiency, some functions may return pointers to internal variables. Such functionality is indicated by underscore as the first letter in the the name.<p>
108<ul>
109<li>
110<code>mat* _internal_matrix()</code>  </li>
111</ul>
112<h2><a class="anchor" name="cr_classes">
113Default Naming Rules for Classes and Structures</a></h2>
114Each 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>
115<ul>
116<li>
117<code>`MyClassName'</code>  </li>
118<li>
119<code>`MyStructName'</code>  </li>
120<li>
121<code>`OFDM'</code>  </li>
122</ul>
123<h2><a class="anchor" name="cr_classes_functionality">
124Default Functionality of Classes</a></h2>
125All classes that are configured by input parameters should include:<p>
126<ul>
127<li>
128default empty constructor  </li>
129<li>
130one or more additional constructor(s) that takes input parameters and initializes the class instance  </li>
131<li>
132setup function, preferably named <code>`setup'</code> or <code>`set_parameters'</code>  </li>
133</ul>
134<p>
135Explicit 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>
136<hr size="1"><address style="text-align: right;"><small>Generated on Wed Oct 7 17:34:44 2009 for mixpp by&nbsp;
137<a href="http://www.doxygen.org/index.html">
138<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.9 </small></address>
139</body>
140</html>
Note: See TracBrowser for help on using the browser.