Flair
Framework Libre Air
Object.h
Go to the documentation of this file.
1 // %flair:license{
2 // This file is part of the Flair framework distributed under the
3 // CECILL-C License, Version 1.0.
4 // %flair:license}
13 #ifndef OBJECT_H
14 #define OBJECT_H
15 
16 #include <string>
17 #include <vector>
18 #include <stdarg.h>
19 
20 //orange printf, with function call and object name display
21 #define Warn(...) Warning(__PRETTY_FUNCTION__, __VA_ARGS__)
22 //red printf, with function call and object name display
23 #define Err(...) Error(__PRETTY_FUNCTION__, __VA_ARGS__)
24 //green printf, with function call and object name display
25 #define Info(...) Information(__PRETTY_FUNCTION__, __LINE__, __VA_ARGS__)
26 
27 //orange printf
28 #define SimpleWarn(...) Warning(NULL, __VA_ARGS__)
29 
30 #define TIME_INFINITE 0
31 #define TIME_NONBLOCK ((Time)-1)
32 
33 class Object_impl;
34 class Widget_impl;
35 
36 namespace flair {
37 namespace core {
38 
39 class FrameworkManager;
40 
41 class Message {
42 public:
43  Message(unsigned int myBufferSize) : bufferSize(myBufferSize) {
44  buffer = new char[bufferSize];
45  }
46  ~Message() { delete buffer; }
47  char *buffer;
48  size_t bufferSize;
49 };
50 
55 typedef unsigned long long Time;
56 
64 Time GetTime(void);
65 
73 void Printf(const char *format, ...);
74 
83 class Object {
84  friend class ::Widget_impl;
85 
86 public:
87  typedef enum { Auto = 0, Red = 31, Green = 32, Orange = 33 } color_t;
97  Object(const Object *parent = NULL, std::string name = "",
98  std::string type = "");
99 
106  virtual ~Object();
107 
113  std::string ObjectName(void) const;
114 
120  std::string ObjectType(void) const;
121 
127  const Object *Parent(void) const;
128 
134  std::vector<const Object *> *TypeChilds(void) const;
135 
141  std::vector<const Object *> *Childs(void) const;
142 
154  void Information(const char *function, int line, const char *format,
155  ...) const;
156 
167  void Warning(const char *function, const char *format, ...) const;
168 
180  void Error(const char *function, const char *format, ...) const;
181 
191  bool ErrorOccured(bool recursive = true) const;
192 
193 private:
194  class Object_impl *pimpl_;
195  void ColorPrintf(color_t, const char *function, int line, const char *format,
196  va_list *args) const;
197 };
198 
199 } // end namespace core
200 } // end namespace flair
201 
202 #endif // OBJECT_H
std::vector< const Object * > * TypeChilds(void) const
Childs of the same type.
Base class for all Framework's classes.
Definition: Object.h:83
namespace of the flair Framework
Definition: Ahrs.h:19
unsigned long long Time
Time definition, in ns.
Definition: Object.h:55
void Error(const char *function, const char *format,...) const
Formatted error.
const Object * Parent(void) const
Parent.
void Information(const char *function, int line, const char *format,...) const
Formatted information.
std::string ObjectName(void) const
Name.
Time GetTime(void)
Time.
void Warning(const char *function, const char *format,...) const
Formatted warning.
bool ErrorOccured(bool recursive=true) const
Has an errror occured?
std::string ObjectType(void) const
Type.
std::vector< const Object * > * Childs(void) const
Childs.
Definition: Object.h:41
void Printf(const char *format,...)
Formatted print.
virtual ~Object()
Destructor.
Object(const Object *parent=NULL, std::string name="", std::string type="")
Constructor.