cohtml::Binder
Provides binding between C++ and the UI.
#include <Binder.h>
Public Types
Name | |
---|---|
enum | BindingMode { BM_Value, BM_Scoped, BM_ScopedSafe, BM_ScopedSafeKeyValue, BM_GetTypeInfo} |
typedef void(*)(Binder *, void *, size_t) | ArrayElementReader |
typedef void(*)(Binder *, void *, size_t) | ArrayElementBinder |
typedef void ()(void *, size_t) | ArrayElementGetter |
typedef size_t(*)(void *) | ArrayLengthGetter |
Public Functions
Name | |
---|---|
virtual | ~Binder() =0 |
Binder() | |
virtual TypeDescription | RegisterType(const char * name, void * object) Register type in the binding. |
virtual TypeDescription | RegisterType(const char * name, const void * object) Register type in the binding. |
virtual void | AddProperty(void * object, const Property & property) |
virtual void | AddMethod(const char * name, IEventHandler * method) |
virtual void | BeginType() |
virtual void | ReadType() |
virtual TypeInfo * | GetTypeInfo() const |
virtual void | EndType(void * ) |
virtual void | BeginEvent(const char * eventName, int arguments) =0 |
virtual void | EndEvent() =0 |
virtual void | BeginExposeObject() =0 |
virtual void | SetAsGlobal(const char * name, void * object) =0 |
virtual void | EnableSafeDataBinding(bool enable) =0 Enable or disable safe data binding by reference of properties of exposed models. Enabled by default. |
virtual bool | IsSafeDataBindingEnabled() const =0 |
virtual void | SetMode(BindingMode mode) =0 |
virtual Binder::BindingMode | GetMode() =0 |
virtual void | NotifyKeyValuePropertyBindingDone() =0 |
virtual bool | BindObject(TypeInfo * type, void * object) =0 |
virtual void | TypeName(const char * name) =0 |
virtual void | PropertyName(const char * name) =0 |
virtual void | BindUndefined() =0 |
virtual void | BindNull() =0 |
virtual void | Bind(bool value) =0 |
virtual void | Bind(signed short value) =0 |
virtual void | Bind(unsigned short value) =0 |
virtual void | Bind(signed int value) =0 |
virtual void | Bind(unsigned int value) =0 |
virtual void | Bind(signed long long value) =0 |
virtual void | Bind(unsigned long long value) =0 |
virtual void | Bind(signed long value) =0 |
virtual void | Bind(unsigned long value) =0 |
virtual void | Bind(signed char value) =0 |
virtual void | Bind(unsigned char value) =0 |
virtual void | Bind(float value) =0 |
virtual void | Bind(double value) =0 |
virtual void | Bind(const char * value) =0 |
virtual void | Bind(const wchar_t * value) =0 |
virtual void | Bind(const char16_t * value) =0 |
virtual void | Bind(const char32_t * value) =0 |
virtual void | BindArray(const int * values, size_t count) =0 |
virtual void | BindArray(const float * values, size_t count) =0 |
virtual bool | TryBindArrayByRef(void * arr, ArrayElementBinder elementBinder, ArrayElementReader elementReader, ArrayLengthGetter lengthGetter, ArrayElementGetter elementGetter) =0 |
virtual void | ArrayBegin(size_t size) =0 Start exporting an array. |
virtual void | ArrayEnd() =0 End exporting an array. |
virtual void | MapBegin(size_t size) =0 Start exporting a map (object) |
virtual void | MapEnd() =0 End exporting a map. |
virtual void | OnTypeBegin() =0 |
virtual void | OnTypeEnd() =0 |
virtual void | OnReadTypeBegin() =0 |
virtual void | OnReadTypeEnd() =0 |
virtual void | SkipValue() =0 |
virtual void | ReadNull() =0 Deprecated Use SkipValue. |
virtual void | Read(bool & value) =0 |
virtual void | Read(signed short & value) =0 |
virtual void | Read(unsigned short & value) =0 |
virtual void | Read(signed int & value) =0 |
virtual void | Read(unsigned int & value) =0 |
virtual void | Read(signed long long & value) =0 |
virtual void | Read(unsigned long long & value) =0 |
virtual void | Read(signed long & value) =0 |
virtual void | Read(unsigned long & value) =0 |
virtual void | Read(char & value) =0 |
virtual void | Read(signed char & value) =0 |
virtual void | Read(unsigned char & value) =0 |
virtual void | Read(float & value) =0 |
virtual void | Read(double & value) =0 |
virtual void | Read(const char *& buffer, size_t & size) =0 |
virtual void | Read(const wchar_t *& value, size_t & size) =0 |
virtual void | Read(const char16_t *& value, size_t & size) =0 |
virtual void | Read(const char32_t *& value, size_t & size) =0 |
virtual bool | ReadProperty(const char * name) =0 |
virtual bool | ReadType(const char * name) =0 |
virtual void | ReadAsString(const char *& buffer, size_t & size) =0 Like Read but ensures the value will be read as string. |
virtual size_t | ReadArrayBegin() =0 Start reading an array. |
virtual void | ReadArrayElement(size_t index) =0 Read element from an array. |
virtual void | ReadArrayEnd() =0 End reading an array. |
virtual size_t | ReadMapBegin() =0 Start reading a map (object) |
virtual void | ReadKeyValuePair() =0 Read next key-value pair from a map. |
virtual void | ReadMapEnd() =0 End reading a map. |
virtual ValueType | PeekValueType() =0 Peek the type of the current value. |
template <typename T > PreciseHandle | CreatePreciseHandle(T * instance, const char * propertyName) Create a handle for updating a specific property of a model. |
virtual PreciseHandle | CreatePreciseHandle(void * instance, const char * propertyName, const TypeInfo * typeInfo) =0 Create a handle for updating a specific property of a model. |
virtual bool | UpdatePreciseHandle(void * instance, PreciseHandle propertyHandle) =0 Mark the property defined by handle to be updated on the next SynchronizeModels |
virtual void | InstanceMoved(void * oldAddress, void * newAddress) =0 Notify the binding layer that a model has been relocated to a new address. |
virtual bool | ElementUpdated(void * instance, PreciseHandle propertyHandle, size_t index) =0 Mark an element in a collection to be updated. |
virtual bool | ElementAdded(void * instance, PreciseHandle propertyHandle, size_t index) =0 Mark an element as added to the collection. |
virtual bool | ElementRemoved(void * instance, PreciseHandle propertyHandle, size_t index) =0 Mark an element as removed from the collection. |
Protected Functions
Name | |
---|---|
Binder(const Binder & ) | |
Binder & | operator=(const Binder & ) |
Protected Attributes
Name | |
---|---|
BinderImpl * | m_Impl |
Friends
Name | |
---|---|
class | TypeDescription |
Public Types Documentation
enum BindingMode
Enumerator | Value | Description |
---|---|---|
BM_Value | ||
BM_Scoped | This mode is set before binding something by value. | |
BM_ScopedSafe | This mode is set before binding something by reference. | |
BM_ScopedSafeKeyValue | This mode is set before binding a property of a model by reference and Safe Data Binding is enabled. | |
BM_GetTypeInfo | This mode is set before binding a key-value property of a model by reference and Safe Data Binding is enabled. This mode is set to generate a TypeInfo. |
typedef ArrayElementReader
typedef void(* cohtml::Binder::ArrayElementReader) (Binder *, void *, size_t);
typedef ArrayElementBinder
typedef void(* cohtml::Binder::ArrayElementBinder) (Binder *, void *, size_t);
typedef ArrayElementGetter
typedef void*(* cohtml::Binder::ArrayElementGetter) (void *, size_t);
typedef ArrayLengthGetter
typedef size_t(* cohtml::Binder::ArrayLengthGetter) (void *);
Public Functions Documentation
function ~Binder
virtual ~Binder() =0
function Binder
Binder()
function RegisterType
virtual TypeDescription RegisterType(
const char * name,
void * object
)
Register type in the binding.
Parameters:
- name name for the type
- object instance of this type
Return: TypeDescription object to be used to describe the properties of object
Warning: The name of the type should be unique for each type. Using duplicated names is undefined behavior
function RegisterType
virtual TypeDescription RegisterType(
const char * name,
const void * object
)
Register type in the binding.
Parameters:
- name name for the type
- object instance of this type
Return: TypeDescription object to be used to describe the properties of object
Warning: The name of the type should be unique for each type. Using duplicated names is undefined behavior
function AddProperty
virtual void AddProperty(
void * object,
const Property & property
)
function AddMethod
virtual void AddMethod(
const char * name,
IEventHandler * method
)
function BeginType
virtual void BeginType()
function ReadType
virtual void ReadType()
function GetTypeInfo
virtual TypeInfo * GetTypeInfo() const
function EndType
virtual void EndType(
void *
)
function BeginEvent
virtual void BeginEvent(
const char * eventName,
int arguments
) =0
function EndEvent
virtual void EndEvent() =0
function BeginExposeObject
virtual void BeginExposeObject() =0
function SetAsGlobal
virtual void SetAsGlobal(
const char * name,
void * object
) =0
function EnableSafeDataBinding
virtual void EnableSafeDataBinding(
bool enable
) =0
Enable or disable safe data binding by reference of properties of exposed models. Enabled by default.
Parameters:
- enable
Warning: Changing this setting doesn’t affect already exposed properties
function IsSafeDataBindingEnabled
virtual bool IsSafeDataBindingEnabled() const =0
function SetMode
virtual void SetMode(
BindingMode mode
) =0
function GetMode
virtual Binder::BindingMode GetMode() =0
function NotifyKeyValuePropertyBindingDone
virtual void NotifyKeyValuePropertyBindingDone() =0
function BindObject
virtual bool BindObject(
TypeInfo * type,
void * object
) =0
function TypeName
virtual void TypeName(
const char * name
) =0
function PropertyName
virtual void PropertyName(
const char * name
) =0
function BindUndefined
virtual void BindUndefined() =0
function BindNull
virtual void BindNull() =0
function Bind
virtual void Bind(
bool value
) =0
function Bind
virtual void Bind(
signed short value
) =0
function Bind
virtual void Bind(
unsigned short value
) =0
function Bind
virtual void Bind(
signed int value
) =0
function Bind
virtual void Bind(
unsigned int value
) =0
function Bind
virtual void Bind(
signed long long value
) =0
function Bind
virtual void Bind(
unsigned long long value
) =0
function Bind
virtual void Bind(
signed long value
) =0
function Bind
virtual void Bind(
unsigned long value
) =0
function Bind
virtual void Bind(
signed char value
) =0
function Bind
virtual void Bind(
unsigned char value
) =0
function Bind
virtual void Bind(
float value
) =0
function Bind
virtual void Bind(
double value
) =0
function Bind
virtual void Bind(
const char * value
) =0
function Bind
virtual void Bind(
const wchar_t * value
) =0
function Bind
virtual void Bind(
const char16_t * value
) =0
function Bind
virtual void Bind(
const char32_t * value
) =0
function BindArray
virtual void BindArray(
const int * values,
size_t count
) =0
function BindArray
virtual void BindArray(
const float * values,
size_t count
) =0
function TryBindArrayByRef
virtual bool TryBindArrayByRef(
void * arr,
ArrayElementBinder elementBinder,
ArrayElementReader elementReader,
ArrayLengthGetter lengthGetter,
ArrayElementGetter elementGetter
) =0
function ArrayBegin
virtual void ArrayBegin(
size_t size
) =0
Start exporting an array.
Parameters:
- size size of the array
function ArrayEnd
virtual void ArrayEnd() =0
End exporting an array.
function MapBegin
virtual void MapBegin(
size_t size
) =0
Start exporting a map (object)
Parameters:
- size size of the map
Note: Every exported type that uses MapBegin() and MapEnd in its bind function, such as maps, pairs, etc, should wrap the call to CoherentBind
with CoherentBindKeyValueProperty()
. You can check Map.h
, UnorderedMap.h
and Pair.h
for example.
function MapEnd
virtual void MapEnd() =0
End exporting a map.
function OnTypeBegin
virtual void OnTypeBegin() =0
function OnTypeEnd
virtual void OnTypeEnd() =0
function OnReadTypeBegin
virtual void OnReadTypeBegin() =0
function OnReadTypeEnd
virtual void OnReadTypeEnd() =0
function SkipValue
virtual void SkipValue() =0
function ReadNull
virtual void ReadNull() =0
Deprecated Use SkipValue.
function Read
virtual void Read(
bool & value
) =0
function Read
virtual void Read(
signed short & value
) =0
function Read
virtual void Read(
unsigned short & value
) =0
function Read
virtual void Read(
signed int & value
) =0
function Read
virtual void Read(
unsigned int & value
) =0
function Read
virtual void Read(
signed long long & value
) =0
function Read
virtual void Read(
unsigned long long & value
) =0
function Read
virtual void Read(
signed long & value
) =0
function Read
virtual void Read(
unsigned long & value
) =0
function Read
virtual void Read(
char & value
) =0
function Read
virtual void Read(
signed char & value
) =0
function Read
virtual void Read(
unsigned char & value
) =0
function Read
virtual void Read(
float & value
) =0
function Read
virtual void Read(
double & value
) =0
function Read
virtual void Read(
const char *& buffer,
size_t & size
) =0
function Read
virtual void Read(
const wchar_t *& value,
size_t & size
) =0
function Read
virtual void Read(
const char16_t *& value,
size_t & size
) =0
function Read
virtual void Read(
const char32_t *& value,
size_t & size
) =0
function ReadProperty
virtual bool ReadProperty(
const char * name
) =0
function ReadType
virtual bool ReadType(
const char * name
) =0
function ReadAsString
virtual void ReadAsString(
const char *& buffer,
size_t & size
) =0
Like Read but ensures the value will be read as string.
function ReadArrayBegin
virtual size_t ReadArrayBegin() =0
Start reading an array.
Return: the size of the array
function ReadArrayElement
virtual void ReadArrayElement(
size_t index
) =0
Read element from an array.
Parameters:
- index the index of the element in the array
function ReadArrayEnd
virtual void ReadArrayEnd() =0
End reading an array.
function ReadMapBegin
virtual size_t ReadMapBegin() =0
Start reading a map (object)
Return: the size of the map
function ReadKeyValuePair
virtual void ReadKeyValuePair() =0
Read next key-value pair from a map.
function ReadMapEnd
virtual void ReadMapEnd() =0
End reading a map.
function PeekValueType
virtual ValueType PeekValueType() =0
Peek the type of the current value.
Return: the type of the current value
function CreatePreciseHandle
template <typename T >
inline PreciseHandle CreatePreciseHandle(
T * instance,
const char * propertyName
)
Create a handle for updating a specific property of a model.
Parameters:
- instance the model instance that will be updated with this handle
- propertyName the name of the property to be updated with this handle. Must match the name given when exposing the model.
Return: handle that can be used to update this property on this instace or different instances of the same type
Note: To be able to use the same handle on different instances their runtime types must be the same
function CreatePreciseHandle
virtual PreciseHandle CreatePreciseHandle(
void * instance,
const char * propertyName,
const TypeInfo * typeInfo
) =0
Create a handle for updating a specific property of a model.
Parameters:
- instance the model instance that will be updated with this handle
- propertyName the name of the property to be updated with this handle. Must match the name given when exposing the model.
- typeInfo the TypeInfo that describes the properties of instance
Return: handle that can be used to update this property on this instace or different instances of the same type
Note: To be able to use the same handle on different instances their runtime types must be the same
function UpdatePreciseHandle
virtual bool UpdatePreciseHandle(
void * instance,
PreciseHandle propertyHandle
) =0
Mark the property defined by handle to be updated on the next SynchronizeModels
Parameters:
- instance the model whose property has to be updated
- propertyHandle the handle for the property to be updated
Return: true if any data-binding expressions have been marked for update
function InstanceMoved
virtual void InstanceMoved(
void * oldAddress,
void * newAddress
) =0
Notify the binding layer that a model has been relocated to a new address.
Parameters:
- oldAddress the old address of the model
- newAddress the new address of the model
Note: does nothing if old_address and new_address are the same
function ElementUpdated
virtual bool ElementUpdated(
void * instance,
PreciseHandle propertyHandle,
size_t index
) =0
Mark an element in a collection to be updated.
Parameters:
- instance the model that contains the collection
- propertyHandle the handle for the collection to be updated
- index index of the updated element
Return: true if any data-binding expressions have been marked for update
function ElementAdded
virtual bool ElementAdded(
void * instance,
PreciseHandle propertyHandle,
size_t index
) =0
Mark an element as added to the collection.
Parameters:
- instance the model that contains the collection
- propertyHandle the handle for the collection to be updated
- index index of the added element
Return: true if any data-binding expressions have been marked for update
function ElementRemoved
virtual bool ElementRemoved(
void * instance,
PreciseHandle propertyHandle,
size_t index
) =0
Mark an element as removed from the collection.
Parameters:
- instance the model that contains the collection
- propertyHandle the handle for the collection to be updated
- index index of the removed element
Return: true if any data-binding expressions have been marked for update
Protected Functions Documentation
function Binder
Binder(
const Binder &
)
function operator=
Binder & operator=(
const Binder &
)
Protected Attributes Documentation
variable m_Impl
BinderImpl * m_Impl;
Friends
friend TypeDescription
friend class TypeDescription;