guit
0.1
Main Page
Classes
Files
File List
All
Classes
Functions
Variables
Typedefs
Enumerations
Friends
gui
gobject.hpp
1
//
2
// Base class of Guit Objects.
3
// Guit GUI Toolkit
4
// Copyright © 2019/2020 Eric Lecolinet. All rights reserved.
5
// http://www.telecom-paris.fr/~elc
6
//
7
8
#ifndef Guit_Object_hpp
9
#define Guit_Object_hpp
10
#include <gtypes.hpp>
11
namespace
guit {
12
13
class
Gadget;
14
class
GBox;
15
class
GProp;
16
45
class
GObject
{
46
public
:
47
using
IsGObject = bool;
48
49
GObject
();
50
virtual
~
GObject
() =
default
;
51
52
virtual
GString typeName()
const
= 0;
53
56
virtual
void
error
(GString
const
& funname, GString
const
& message)
const
;
57
60
template
<
class
Sub
class
>
61
inline
Subclass*
to
() {
return
dynamic_cast<
Subclass*
>
(
this
);}
62
63
template
<
class
Sub
class
>
64
inline
Subclass
const
*
to
()
const
{
return
dynamic_cast<
Subclass const*
>
(
this
);}
65
66
virtual
Gadget* toGadget() {
return
nullptr
;}
67
virtual
GBox* toBox() {
return
nullptr
;}
68
virtual
GProp* toProp() {
return
nullptr
;}
69
70
virtual
Gadget
const
* toGadget()
const
{
return
nullptr
;}
71
virtual
GBox
const
* toBox()
const
{
return
nullptr
;}
72
virtual
GProp
const
* toProp()
const
{
return
nullptr
;}
74
76
void
operator
delete
(
void
*);
77
78
void
*
operator
new
(std::size_t);
79
84
void
ignoreSmartPointers
() {omodes_.plain = 1;}
85
bool
isIgnoringSmartPointers()
const
{
return
omodes_.plain;}
87
91
void
forgetSmartPointers
() {omodes_.autodel = 0;}
92
94
unsigned
int
useCount
()
const
{
return
refcount_;}
95
97
virtual
void
removeNotifiers
(
void
* obj) {}
98
99
// can't trivially copy object.
100
GObject
(
GObject
const
&) =
delete
;
101
GObject
(
GObject
const
&&) =
delete
;
102
GObject
& operator=(
GObject
const
&) =
delete
;
103
GObject
& operator=(
GObject
const
&&) =
delete
;
104
friend
void
gaddPtr(
GObject
*,
bool
will_autodel);
105
friend
void
gremovePtr(
GObject
*);
106
110
uint16_t refcount_;
111
struct
{
112
uint8_t plain:1, autodel:1, immutable:1, initialized:1;
113
} omodes_;
115
};
116
117
}
118
#endif
Generated on Thu Feb 25 2021 16:42:45 for guit by
1.8.4