[2] | 1 | // %flair:license{
|
---|
[13] | 2 | // This file is part of the Flair framework distributed under the
|
---|
| 3 | // CECILL-C License, Version 1.0.
|
---|
[2] | 4 | // %flair:license}
|
---|
| 5 | /*!
|
---|
| 6 | * \file Box.h
|
---|
| 7 | * \brief Abstract class to display a box on the ground station
|
---|
| 8 | * \author Guillaume Sanahuja, Copyright Heudiasyc UMR UTC/CNRS 7253
|
---|
| 9 | * \date 2011/10/28
|
---|
| 10 | * \version 4.0
|
---|
| 11 | */
|
---|
| 12 |
|
---|
| 13 | #ifndef BOX_H
|
---|
| 14 | #define BOX_H
|
---|
| 15 |
|
---|
| 16 | #include <Widget.h>
|
---|
| 17 |
|
---|
[13] | 18 | namespace flair {
|
---|
| 19 | namespace gui {
|
---|
[2] | 20 |
|
---|
[13] | 21 | class Layout;
|
---|
| 22 | class LayoutPosition;
|
---|
[2] | 23 |
|
---|
[13] | 24 | /*! \class Box
|
---|
| 25 | *
|
---|
| 26 | * \brief Abstract class to display a box on the ground station
|
---|
| 27 | *
|
---|
| 28 | * This is an abstract class to display boxes (like CheckBox, SpinBox, etc). \n
|
---|
| 29 | * To access reimplemented box's value, use Box::GetMutex and Box::ReleaseMutex.
|
---|
| 30 | *\n
|
---|
| 31 | * Note that this mutex is in reality the one from the parent Layout. To minimize
|
---|
| 32 | *memory
|
---|
| 33 | * footprint, each Box does not have its own Mutex.
|
---|
| 34 | */
|
---|
| 35 | class Box : public Widget {
|
---|
| 36 | public:
|
---|
| 37 | /*!
|
---|
| 38 | * \brief Constructor
|
---|
| 39 | *
|
---|
| 40 | * Construct a Box. \n
|
---|
| 41 | * Type must agree with predifined (hard coded) types
|
---|
| 42 | * in ground station code. \n
|
---|
| 43 | * The Box will automatically be child of position->getLayout() Layout. After
|
---|
| 44 | *calling this method,
|
---|
| 45 | * position will be deleted as it is no longer usefull.
|
---|
| 46 | *
|
---|
| 47 | * \param position position
|
---|
| 48 | * \param name name
|
---|
| 49 | * \param type type
|
---|
| 50 | */
|
---|
| 51 | Box(const LayoutPosition *position, std::string name, std::string type);
|
---|
[2] | 52 |
|
---|
[13] | 53 | /*!
|
---|
| 54 | * \brief Destructor
|
---|
| 55 | *
|
---|
| 56 | */
|
---|
| 57 | ~Box();
|
---|
[2] | 58 |
|
---|
[13] | 59 | /*!
|
---|
| 60 | * \brief Has the value changed since last call?
|
---|
| 61 | *
|
---|
| 62 | * This method returns the value of an internal flag
|
---|
| 63 | * which is set through SetValueChanged(). \n
|
---|
| 64 | * After calling this method, the internal flag is
|
---|
| 65 | * set to false.
|
---|
| 66 | *
|
---|
| 67 | * \return true is valued has changed since last call
|
---|
| 68 | */
|
---|
| 69 | bool ValueChanged(void);
|
---|
[2] | 70 |
|
---|
[13] | 71 | protected:
|
---|
| 72 | /*!
|
---|
| 73 | * \brief Set the value changed flag
|
---|
| 74 | *
|
---|
| 75 | * The reimplemented class must call this method when Box's value is changed.
|
---|
| 76 | *\n
|
---|
| 77 | * This method must be called with Mutex locked. Indeed, as reimplemented class
|
---|
| 78 | * also has to lock the Mutex to change the Box value, this mecanism avoid two
|
---|
| 79 | *successives
|
---|
| 80 | * lock and unlock.
|
---|
| 81 | *
|
---|
| 82 | */
|
---|
| 83 | void SetValueChanged(void);
|
---|
[2] | 84 |
|
---|
[13] | 85 | /*!
|
---|
| 86 | * \brief Get Mutex
|
---|
| 87 | *
|
---|
| 88 | * This method must be called before changing Box's value or
|
---|
| 89 | * calling SetValueChanged().
|
---|
| 90 | *
|
---|
| 91 | */
|
---|
| 92 | void GetMutex(void) const;
|
---|
[2] | 93 |
|
---|
[13] | 94 | /*!
|
---|
| 95 | * \brief Release Mutex
|
---|
| 96 | *
|
---|
| 97 | * This method must be called after changing Box's value or
|
---|
| 98 | * calling SetValueChanged().
|
---|
| 99 | *
|
---|
| 100 | */
|
---|
| 101 | void ReleaseMutex(void) const;
|
---|
[2] | 102 |
|
---|
[13] | 103 | private:
|
---|
| 104 | bool value_changed;
|
---|
| 105 | };
|
---|
[2] | 106 |
|
---|
| 107 | } // end namespace gui
|
---|
| 108 | } // end namespace flair
|
---|
| 109 |
|
---|
| 110 | #endif // BOX_H
|
---|