Changeset 13 in flair-dev for trunk/include/FlairCore/Object.h
- Timestamp:
- Apr 8, 2016, 3:39:24 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/FlairCore/Object.h
r2 r13 18 18 #include <stdarg.h> 19 19 20 #define Warn(...) Warning(__PRETTY_FUNCTION__, __VA_ARGS__)21 #define Err(...) Error(__PRETTY_FUNCTION__, __VA_ARGS__)22 #define Info(...) Information(__PRETTY_FUNCTION__, __LINE__,__VA_ARGS__)20 #define Warn(...) Warning(__PRETTY_FUNCTION__, __VA_ARGS__) 21 #define Err(...) Error(__PRETTY_FUNCTION__, __VA_ARGS__) 22 #define Info(...) Information(__PRETTY_FUNCTION__, __LINE__, __VA_ARGS__) 23 23 24 24 #define TIME_INFINITE 0 … … 28 28 class Widget_impl; 29 29 30 namespace flair 31 { 32 namespace core 33 { 30 namespace flair { 31 namespace core { 34 32 35 33 class FrameworkManager; 36 34 37 class Message { 38 public: 39 Message(unsigned int myBufferSize):bufferSize(myBufferSize) { 40 buffer=new char[bufferSize]; 41 } 42 ~Message() { 43 delete buffer; 44 } 45 char *buffer; 46 size_t bufferSize; 47 }; 35 class Message { 36 public: 37 Message(unsigned int myBufferSize) : bufferSize(myBufferSize) { 38 buffer = new char[bufferSize]; 39 } 40 ~Message() { delete buffer; } 41 char *buffer; 42 size_t bufferSize; 43 }; 48 44 49 50 51 52 53 45 /*! 46 * \brief Time definition, in ns 47 * 48 */ 49 typedef unsigned long long Time; 54 50 55 /*! 56 * \brief Time 57 * 58 * \return actual time in ns (origin depends on whether the method is compiled in hard real time mode or not. As a conquence, only time differences should be used) 59 */ 60 Time GetTime(void); 51 /*! 52 * \brief Time 53 * 54 * \return actual time in ns (origin depends on whether the method is compiled in 55 *hard real time mode or not. As a conquence, only time differences should be 56 *used) 57 */ 58 Time GetTime(void); 61 59 62 63 64 65 66 67 68 69 60 /*! 61 * \brief Formatted print 62 * 63 * See standard printf for syntax. 64 * 65 * \param format text string to display 66 */ 67 void Printf(const char *format, ...); 70 68 71 /*! \class Object 72 * 73 * \brief Base class for all Framework's classes 74 * 75 * This is the base class for all other classes. \n 76 * It handles parent/child links and thus allow auto destruction of childs. 77 * 78 */ 79 class Object 80 { 81 friend class ::Widget_impl; 69 /*! \class Object 70 * 71 * \brief Base class for all Framework's classes 72 * 73 * This is the base class for all other classes. \n 74 * It handles parent/child links and thus allow auto destruction of childs. 75 * 76 */ 77 class Object { 78 friend class ::Widget_impl; 82 79 83 public: 84 typedef enum { 85 Auto=0, 86 Red=31, 87 Green=32, 88 Orange=33 89 } color_t; 90 /*! 91 * \brief Constructor 92 * 93 * Construct an Object, which is child of its parent. 94 * 95 * \param parent parent 96 * \param name name 97 * \param type type 98 */ 99 Object(const Object* parent=NULL,std::string name="",std::string type=""); 80 public: 81 typedef enum { Auto = 0, Red = 31, Green = 32, Orange = 33 } color_t; 82 /*! 83 * \brief Constructor 84 * 85 * Construct an Object, which is child of its parent. 86 * 87 * \param parent parent 88 * \param name name 89 * \param type type 90 */ 91 Object(const Object *parent = NULL, std::string name = "", 92 std::string type = ""); 100 93 101 102 103 104 105 106 107 94 /*! 95 * \brief Destructor 96 * 97 * Calling it will automatically destruct all childs. 98 * 99 */ 100 virtual ~Object(); 108 101 109 110 111 112 113 114 102 /*! 103 * \brief Name 104 * 105 * \return Object's name 106 */ 107 std::string ObjectName(void) const; 115 108 116 117 118 119 120 121 109 /*! 110 * \brief Type 111 * 112 * \return Object's type 113 */ 114 std::string ObjectType(void) const; 122 115 123 124 125 126 127 128 const Object*Parent(void) const;116 /*! 117 * \brief Parent 118 * 119 * \return Object's parent 120 */ 121 const Object *Parent(void) const; 129 122 130 131 132 133 134 135 std::vector<const Object*>*TypeChilds(void) const;123 /*! 124 * \brief Childs of the same type 125 * 126 * \return a vector of all childs of the same type 127 */ 128 std::vector<const Object *> *TypeChilds(void) const; 136 129 137 138 139 140 141 142 std::vector<const Object*>*Childs(void) const;130 /*! 131 * \brief Childs 132 * 133 * \return a vector of all childs 134 */ 135 std::vector<const Object *> *Childs(void) const; 143 136 144 /*! 145 * \brief Formatted information 146 * 147 * Green colored Printf(). \n 148 * Note that it is better to call Info macro, which automatically fills function parameter. 149 * 150 * \param function name of calling function 151 * \param line line number in calling function 152 * \param format text string to display 153 */ 154 void Information(const char *function, int line, const char *format, ...) const; 137 /*! 138 * \brief Formatted information 139 * 140 * Green colored Printf(). \n 141 * Note that it is better to call Info macro, which automatically fills 142 *function parameter. 143 * 144 * \param function name of calling function 145 * \param line line number in calling function 146 * \param format text string to display 147 */ 148 void Information(const char *function, int line, const char *format, 149 ...) const; 155 150 156 /*! 157 * \brief Formatted warning 158 * 159 * Orange colored Printf(). \n 160 * Note that it is better to call Warn macro, which automatically fills function parameter. 161 * 162 * \param function name of calling function 163 * \param format text string to display 164 */ 165 void Warning(const char *function,const char *format, ...) const; 151 /*! 152 * \brief Formatted warning 153 * 154 * Orange colored Printf(). \n 155 * Note that it is better to call Warn macro, which automatically fills 156 *function parameter. 157 * 158 * \param function name of calling function 159 * \param format text string to display 160 */ 161 void Warning(const char *function, const char *format, ...) const; 166 162 167 /*! 168 * \brief Formatted error 169 * 170 * Red colored Printf(). \n 171 * Note that it is better to call Err macro, which automatically fills function parameter. \n 172 * After calling this method, ErrorOccured() will always return true. 173 * 174 * \param function name of calling function 175 * \param format text string to display 176 */ 177 void Error(const char *function,const char *format, ...) const; 163 /*! 164 * \brief Formatted error 165 * 166 * Red colored Printf(). \n 167 * Note that it is better to call Err macro, which automatically fills function 168 *parameter. \n 169 * After calling this method, ErrorOccured() will always return true. 170 * 171 * \param function name of calling function 172 * \param format text string to display 173 */ 174 void Error(const char *function, const char *format, ...) const; 178 175 179 180 181 182 183 184 185 186 187 188 bool ErrorOccured(bool recursive=true) const;176 /*! 177 * \brief Has an errror occured? 178 * 179 * Check if an error occured, in fact if Error() was called at least once. \n 180 * Once Error() was called, this method will never return back false. 181 * 182 * \param recursive if true, recursively check among childs 183 * \return true if an error occured 184 */ 185 bool ErrorOccured(bool recursive = true) const; 189 186 190 private: 191 class Object_impl* pimpl_; 192 void ColorPrintf(color_t, const char *function, int line, const char *format, va_list *args) const; 193 }; 187 private: 188 class Object_impl *pimpl_; 189 void ColorPrintf(color_t, const char *function, int line, const char *format, 190 va_list *args) const; 191 }; 194 192 195 193 } // end namespace core
Note: See TracChangeset
for help on using the changeset viewer.