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

Revision 472, 6.4 kB (checked in by mido, 15 years ago)

obnovena dokumentace, vcetne pridani mnoha novych doc-souboru do svn

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>
59<div class="contents">
60<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">
61Default Naming Rules for Variables</a></h2>
62Generally, 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>
63<ul>
64<li>
65<code>`FFT_size'</code>  </li>
66<li>
67<code>`initial_RV'</code>  </li>
68<li>
69<code>`my_variable'</code>  </li>
70</ul>
71<h2><a class="anchor" name="cr_files">
72Default Naming Rules for Files</a></h2>
73Files 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>
74Source files are named using <code>`.cpp'</code> suffix, whereas header files end with <code>`.h'</code> extension. Examples:<p>
75<ul>
76<li>
77<code>`my_file.h'</code>  </li>
78<li>
79<code>`user_info.cpp'</code>  </li>
80</ul>
81<h2><a class="anchor" name="cr_file_templates">
82Form of the source files</a></h2>
83For 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>
84<ul>
85<li>
86if 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>
87</li>
88<li>
89firstly, 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>
90</li>
91<li>
92source 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>
93</li>
94</ul>
95<p>
96Rules 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">
97Default Naming Rules for Functions</a></h2>
98Function 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>
99<ul>
100<li>
101<code>int my_function_name(int a, int b)</code>  </li>
102</ul>
103<h2><a class="anchor" name="cr_specialfunctions">
104Convention for sensitive functions</a></h2>
105For efficiency, some functions may return pointers to internal variables. Such functionality is indicated by underscore as the first letter in the the name.<p>
106<ul>
107<li>
108<code>mat* _internal_matrix()</code>  </li>
109</ul>
110<h2><a class="anchor" name="cr_classes">
111Default Naming Rules for Classes and Structures</a></h2>
112Each 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>
113<ul>
114<li>
115<code>`MyClassName'</code>  </li>
116<li>
117<code>`MyStructName'</code>  </li>
118<li>
119<code>`OFDM'</code>  </li>
120</ul>
121<h2><a class="anchor" name="cr_classes_functionality">
122Default Functionality of Classes</a></h2>
123All classes that are configured by input parameters should include:<p>
124<ul>
125<li>
126default empty constructor  </li>
127<li>
128one or more additional constructor(s) that takes input parameters and initializes the class instance  </li>
129<li>
130setup function, preferably named <code>`setup'</code> or <code>`set_parameters'</code>  </li>
131</ul>
132<p>
133Explicit 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>
134<hr size="1"><address style="text-align: right;"><small>Generated on Wed Aug 5 00:06:50 2009 for mixpp by&nbsp;
135<a href="http://www.doxygen.org/index.html">
136<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.9 </small></address>
137</body>
138</html>
Note: See TracBrowser for help on using the browser.