PMDA++  0.4.4
Header-only C++ library for writing PCP PMDAs
types.hpp
Go to the documentation of this file.
1 // Copyright Paul Colby 2013 - 2015.
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE.md or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
5 
6 /**
7  * @file
8  * @brief Declares various types used throughout the PMDA++ library.
9  */
10 
11 #ifndef __PCP_CPP_TYPES_HPP__
12 #define __PCP_CPP_TYPES_HPP__
13 
14 #include "config.hpp"
15 
16 #include <stdint.h>
17 
18 PCP_CPP_BEGIN_NAMESPACE
19 
20 namespace pcp {
21 
22 typedef uint_fast8_t atom_type_type; ///< PM_TYPE_* (0 - 9)
23 typedef uint_fast16_t cluster_id_type; ///< __pmID_int::cluster (12-bits)
24 typedef uint_fast16_t domain_id_type; ///< __pmID_int::cluster (9-bits); pmdaIndom::it_indom
25 typedef unsigned int instance_id_type; ///< https://github.com/pcolby/pcp-pmda-cpp/issues/11
26 typedef uint_fast16_t item_id_type; ///< __pmID_int::item (10-bits)
27 typedef uint_fast8_t semantic_type; ///< PM_SEM_* (0 - 4)
28 
29 /// @brief Get the PM_TYPE_* constant for a given C++ type.
30 template <typename Type> inline atom_type_type type();
31 
32 // Integer types.
33 template <> inline atom_type_type type<int8_t> () { return PM_TYPE_32; } ///< Template specialisation for int8_t.
34 template <> inline atom_type_type type<int16_t> () { return PM_TYPE_32; } ///< Template specialisation for int16_t.
35 template <> inline atom_type_type type<int32_t> () { return PM_TYPE_32; } ///< Template specialisation for int32_t.
36 template <> inline atom_type_type type<int64_t> () { return PM_TYPE_64; } ///< Template specialisation for int64_t.
37 template <> inline atom_type_type type<uint8_t> () { return PM_TYPE_U32; } ///< Template specialisation for uint8_t.
38 template <> inline atom_type_type type<uint16_t>() { return PM_TYPE_U32; } ///< Template specialisation for uint16_t.
39 template <> inline atom_type_type type<uint32_t>() { return PM_TYPE_U32; } ///< Template specialisation for uint32_t.
40 template <> inline atom_type_type type<uint64_t>() { return PM_TYPE_U64; } ///< Template specialisation for uint64_t.
41 
42 // Floating point types.
43 template <> inline atom_type_type type<float> () { return PM_TYPE_FLOAT; } ///< Template specialisation for float.
44 template <> inline atom_type_type type<double>() { return PM_TYPE_DOUBLE; } ///< Template specialisation for double.
45 
46 // String types.
47 template <> inline atom_type_type type<char *> () { return PM_TYPE_STRING; } ///< Template specialisation for `char *`.
48 template <> inline atom_type_type type<std::string> () { return PM_TYPE_STRING; } ///< Template specialisation for std::string.
49 
50 } // pcp namespace.
51 
52 PCP_CPP_END_NAMESPACE
53 
54 #endif
unsigned int instance_id_type
https://github.com/pcolby/pcp-pmda-cpp/issues/11
Definition: types.hpp:25
uint_fast8_t semantic_type
PM_SEM_* (0 - 4)
Definition: types.hpp:27
Definition: atom.hpp:20
uint_fast8_t atom_type_type
PM_TYPE_* (0 - 9)
Definition: types.hpp:22
Sets up common PMDA++ library macros.
atom_type_type type< uint8_t >()
Template specialisation for uint8_t.
Definition: types.hpp:37
atom_type_type type< int8_t >()
Template specialisation for int8_t.
Definition: types.hpp:33
atom_type_type type< int32_t >()
Template specialisation for int32_t.
Definition: types.hpp:35
atom_type_type type< int16_t >()
Template specialisation for int16_t.
Definition: types.hpp:34
uint_fast16_t item_id_type
__pmID_int::item (10-bits)
Definition: types.hpp:26
atom_type_type type< float >()
Template specialisation for float.
Definition: types.hpp:43
atom_type_type type< double >()
Template specialisation for double.
Definition: types.hpp:44
atom_type_type type< uint16_t >()
Template specialisation for uint16_t.
Definition: types.hpp:38
atom_type_type type< uint64_t >()
Template specialisation for uint64_t.
Definition: types.hpp:40
atom_type_type type< uint32_t >()
Template specialisation for uint32_t.
Definition: types.hpp:39
atom_type_type type< int64_t >()
Template specialisation for int64_t.
Definition: types.hpp:36
atom_type_type type()
Get the PM_TYPE_* constant for a given C++ type.
uint_fast16_t domain_id_type
__pmID_int::cluster (9-bits); pmdaIndom::it_indom
Definition: types.hpp:24
uint_fast16_t cluster_id_type
__pmID_int::cluster (12-bits)
Definition: types.hpp:23