|
|
|||
File indexing completed on 2026-06-02 08:51:43
0001 /* 0002 * SortingMode.h 0003 * 0004 * Created on: Dec 7, 2015 0005 * Author: debian 0006 */ 0007 0008 #ifndef SORTING_MODE_H 0009 #define SORTING_MODE_H 0010 0011 #include <string> 0012 0013 namespace PARTONS { 0014 0015 /** 0016 * @class SortingMode 0017 * 0018 * @brief Definition of sorting modes. 0019 * 0020 * This class defines a set of enumeration values that are used to distinguish between sorting modes. In addition, a declared object of this class is always associated to one sorting mode (see SortingMode::m_type), so member functions can act on it. E.g. 0021 \code{.cpp} 0022 //this is single enum variable - nothing to play with 0023 SortingMode::Type enum_variable = SortingMode::ASCENDING; 0024 0025 //this is declared object 0026 SortingMode enum_object; 0027 0028 //let us assign some type (default is SortingMode::UNDEFINED) 0029 enum_object.setType(enum_variable); 0030 0031 //with objects you can use available functions, e.g. you can represent enumeration type by a corresponding string 0032 std::string enum_string_1 = enum_object.toString(); 0033 0034 //you can achieve some basic operations without the explicit declaration of objects by using the assignment constructor 0035 std::string enum_string_2 = SortingMode(SortingMode::DESCENDING).toString(); 0036 0037 Partons::getInstance()->getLoggerManager()->info("example", __func__, ElemUtils::Formatter() << "Sorting mode is: " << enum_string_1); 0038 Partons::getInstance()->getLoggerManager()->info("example", __func__, ElemUtils::Formatter() << "Sorting mode is: " << enum_string_2); 0039 \endcode 0040 which gives via Logger: 0041 \code 0042 20-05-2017 12:13:02 [INFO] (example::main) Sorting mode is: ASCENDING 0043 20-05-2017 12:13:02 [INFO] (example::main) Sorting mode is: DESCENDING 0044 \endcode 0045 */ 0046 class SortingMode { 0047 0048 public: 0049 0050 enum Type { 0051 UNDEFINED = 0, //!< Undefined type. 0052 ASCENDING = 1, //!< Ascending sorting. 0053 DESCENDING = 2 //!< Descending sorting. 0054 }; 0055 0056 /** 0057 * Default constructor. 0058 */ 0059 SortingMode(); 0060 0061 /** 0062 * Assignment constructor. 0063 * @param type Type to be assigned. 0064 */ 0065 SortingMode(Type type); 0066 0067 /** 0068 * Automatic cast to enum. 0069 */ 0070 operator Type() const; 0071 0072 /** 0073 * Get string representation of type being assigned to a declared object of this class. 0074 * @return String representation of assigned type, like "ASCENDING" for SortingMode::ASCENDING. 0075 */ 0076 std::string toString() const; 0077 0078 /** 0079 * Get short name representation of type being assigned to a declared object of this class. 0080 * @return Short string representation of assigned type, like "ASCENDING" for SortingMode::ASCENDING. 0081 */ 0082 std::string getShortName(); 0083 0084 //******************************************************** 0085 //*** SETTERS AND GETTERS ******************************** 0086 //******************************************************** 0087 0088 /** 0089 * Get type being assigned to a declared object of this class. 0090 */ 0091 SortingMode::Type getType() const; 0092 0093 /** 0094 * Assign type to a declared object of this class. 0095 */ 0096 void setType(Type type); 0097 0098 private: 0099 0100 /** 0101 * Type associated to a declared object of this class. 0102 */ 0103 SortingMode::Type m_type; 0104 }; 0105 0106 } /* namespace PARTONS */ 0107 0108 #endif /* SORTING_MODE_H */
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|