cgv
Loading...
Searching...
No Matches
attach_slot.cxx
1#include "attach_slot.h"
2
3namespace cgv {
4 namespace base {
5
11
12
14void attach_slot::attach(base_ptr attachment_object, void* user_data)
15{
16 attachment_user_data = user_data;
17 attachment = attachment_object;
18}
19
20void attach_slot::attach(base_ptr attachment_object, int user_data)
21{
22 attach(attachment_object, (void*&)user_data);
23}
24
30
36
38bool attach(base_ptr slot_object, base_ptr attachment_object, void* user_data)
39{
40 attach_slot* as = slot_object->get_interface<attach_slot>();
41 if (!as)
42 return false;
43 as->attach(attachment_object, user_data);
44 return true;
45}
46
47bool attach(base_ptr slot_object, base_ptr attachment_object, int user_data)
48{
49 return attach(slot_object, attachment_object, (void*&) user_data);
50}
51
54{
55 attach_slot* as = slot_object->get_interface<attach_slot>();
56 if (!as)
57 return base_ptr();
58 return as->get_attachment();
59}
60
62void* get_attachment_data(base_ptr slot_object)
63{
64 attach_slot* as = slot_object->get_interface<attach_slot>();
65 if (!as)
66 return 0;
67 return as->get_attachement_data();
68}
69
70int get_attachment_data_int(base_ptr slot_object)
71{
72 void* ud = get_attachment_data(slot_object);
73 return (int&) ud;
74}
75
76 }
77}
interface for an attachment slot that can store a base pointer
Definition attach_slot.h:12
void * attachment_user_data
allow to add user data to the attachment
Definition attach_slot.h:17
base_ptr get_attachment() const
return current attachment
void attach(base_ptr attachment_object, void *user_data=0)
attach object to attachment slot
base_ptr attachment
allow to attach some object to group
Definition attach_slot.h:15
void * get_attachement_data() const
return current attachment
attach_slot()
init the user data
T * get_interface()
use dynamic type cast to check for the given interface
Definition base.h:128
the base namespace holds the base hierarchy, support for plugin registration and signals
Definition action.cxx:4
base_ptr get_attachment(base_ptr slot_object)
query the attachment of an attach_slot object.
data::ref_ptr< base, true > base_ptr
ref counted pointer to base
Definition base.h:37
bool attach(base_ptr slot_object, base_ptr attachment_object, void *user_data)
function to attach an object to an object of type attach_slot.
void * get_attachment_data(base_ptr slot_object)
query the user data of the attachment of an attach_slot object.
this header is dependency free
Definition print.h:11