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 #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 
24 #define TIME_INFINITE 0
25 #define TIME_NONBLOCK ((Time)-1)
26 
27 class Object_impl;
28 class Widget_impl;
29 
30 namespace flair {
31 namespace core {
32 
33 class FrameworkManager;
34 
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 };
44 
49 typedef unsigned long long Time;
50 
58 Time GetTime(void);
59 
67 void Printf(const char *format, ...);
68 
77 class Object {
78  friend class ::Widget_impl;
79 
80 public:
81  typedef enum { Auto = 0, Red = 31, Green = 32, Orange = 33 } color_t;
91  Object(const Object *parent = NULL, std::string name = "",
92  std::string type = "");
93 
100  virtual ~Object();
101 
107  std::string ObjectName(void) const;
108 
114  std::string ObjectType(void) const;
115 
121  const Object *Parent(void) const;
122 
128  std::vector<const Object *> *TypeChilds(void) const;
129 
135  std::vector<const Object *> *Childs(void) const;
136 
148  void Information(const char *function, int line, const char *format,
149  ...) const;
150 
161  void Warning(const char *function, const char *format, ...) const;
162 
174  void Error(const char *function, const char *format, ...) const;
175 
185  bool ErrorOccured(bool recursive = true) const;
186 
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 };
192 
193 } // end namespace core
194 } // end namespace flair
195 
196 #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:77
namespace of the flair Framework
Definition: Ahrs.h:19
unsigned long long Time
Time definition, in ns.
Definition: Object.h:49
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:35
void Printf(const char *format,...)
Formatted print.
virtual ~Object()
Destructor.
Object(const Object *parent=NULL, std::string name="", std::string type="")
Constructor.