This section describes some of the not directly obvious aspects of the coding style used for the Rulbus Device Class Library.
As a start, please take a look at the existing code.
Rulbus device class names look like RB8510_Dac12 and RB8515_clock. Note the suffix Dac, it's not spelled DAC or dac.
Function and method names follow the following convention:
bool isBipolar(); for a method that returns a boolean value (accessors)float frequency(); for a method that returns a value (accessors)void setFrequency(float f); for a method that defines a value (mutators)void getFrequency(float *f); for a method that obtains a value via an argument
Declare constants (e.g. for register offsets) in the class as static const type name = value;, for example
class Aclass { ... private: static const int OFF_CTRL = 2; ... };
This makes their documentation available in the same location as the other members. Otherwise it would appear in the devices' implementation page. There's no need to define the constant as long its location is not needed. The alternative of using enums does not provide type information.
Here is a template to create a Rulbus Device Class from.
/**
* \brief ...
*
* <h3>Purpose</h3>
* ...
*
* <h3>Description</h3>
* ...
*
* <h3>Usage</h3>
* ...
* \code
* \endcode
*
* <h3>Implementation</h3>
* ...
*
*/
class myClass : public RulbusDevice
{
public: // public interface
typedef int Value;
/// \name Construction
/// @{
myClass( CharCptr name, int addr = DEF_ADDR, int rack = DEF_RACK );
~myClass();
/// @}
/// \name Operators
/// @{
myClassRef operator= ( myClassCref rhs );
/// @}
/// \name Accessors
/// @{
Value value( );
/// @}
/// \name Mutators
/// @{
void setValue( Value aValue );
/// @}
protected: // protected interface
/// \name Construction and Assignment
/// @{
myClass(); ///< prevent default construction
myClass( myClassCref rhs ); ///< prevent copying
myClassRef operator= ( myClassCref rhs ); ///< prevent copying
/// @}
/// \name Checkers
/// @{
void checkValue( Value value );
/// @}
private: // private methods
public: // public member data
/// \name Defaults
/// @{
static const int DEF_ADDR = 0x..;
static const int DEF_RACK = 0;
/// @}
protected: // protected member data
private: // private member data
Value theValue;
/// \name Defaults
/// @{
static const int DEF_ADDR = 0x..;
static const int DEF_RACK = 0;
/// \name Register offsets
/// @{
static const int OFF_STS = 0;
static const int OFF_CTRL = 0;
/// @}
/// \name Limits
/// @{
static const int LIM_xxxx = 0xFF;
/// @}
};