mcr_Interface
More...
Go to the source code of this file.
|
| MCR_API void | mcr_Interface_init (struct mcr_Interface *interfacePt) |
| |
| MCR_API void | mcr_Interface_ctor (struct mcr_Interface *interfacePt, struct mcr_context *context, size_t dataSize, void *(*allocate)(), void(*deallocate)(void *), mcr_data_fnc init, mcr_data_fnc deinit, mcr_compare_fnc compare, mcr_copy_fnc copy) |
| |
| MCR_API void | mcr_Interface_deinit (struct mcr_Interface *interfacePt) |
| |
| MCR_API void | mcr_Interface_set_all (struct mcr_Interface *interfacePt, struct mcr_context *context, size_t dataSize, void *(*allocate)(), void(*deallocate)(void *), mcr_data_fnc init, mcr_data_fnc deinit, mcr_compare_fnc compare, mcr_copy_fnc copy) |
| |
| MCR_API size_t | mcr_Interface_id (struct mcr_Interface *interfacePt) |
| |
| MCR_API int | mcr_Interface_allocate (const struct mcr_Interface *interfacePt, struct mcr_DataMember *dataMemberPt) |
| |
| MCR_API int | mcr_Interface_deallocate (const struct mcr_Interface *interfacePt, struct mcr_DataMember *dataMemberPt) |
| |
| MCR_API int | mcr_Interface_compare (const struct mcr_Interface *interfacePt, const struct mcr_DataMember *lhs, const struct mcr_DataMember *rhs) |
| |
| MCR_API int | mcr_Interface_copy (const struct mcr_Interface *interfacePt, struct mcr_DataMember *dstPt, const struct mcr_DataMember *srcPt) |
| |
| MCR_API int | mcr_Interface_set_data (const struct mcr_Interface *interfacePt, struct mcr_DataMember *dataMemberPt, void *data, bool heapFlag) |
| |
| MCR_API int | mcr_Interface_reset (const struct mcr_Interface *interfacePt, struct mcr_DataMember *dataMemberPt) |
| |
§ mcr_Interface_allocate()
Heap-allocate and initialize an object
1) Use malloc to allocate object
2) Initialize object with mcr_Interface::init
3) Set mcr_DataMember::deallocate to free
- Parameters
-
| interfacePt | opt The initialized object will be empty without this |
| dataMemberPt | opt Object to initialize |
- Returns
- reterr
§ mcr_Interface_compare()
Use an interface to compare two objects
mcr_compare_fnc
- Parameters
-
| interfacePt | |
| lhs | opt Left side of comparison |
| rhs | opt Right side of comparison |
- Returns
- retcmp
§ mcr_Interface_copy()
Use an interface to copy an object
mcr_copy_fnc If no source is given, destination will be freed.
- Parameters
-
| interfacePt | |
| dstPt | Object data is copied into |
| srcPt | opt Object data is copied from |
- Returns
- reterr
§ mcr_Interface_ctor()
§ mcr_Interface_deallocate()
§ mcr_Interface_deinit()
| MCR_API void mcr_Interface_deinit |
( |
struct mcr_Interface * |
interfacePt | ) |
|
dtor
Removes self from registry, if the registry is set.
- Parameters
-
§ mcr_Interface_id()
| MCR_API size_t mcr_Interface_id |
( |
struct mcr_Interface * |
interfacePt | ) |
|
Get the id of an interface.
- Parameters
-
- Returns
- retid
§ mcr_Interface_init()
| MCR_API void mcr_Interface_init |
( |
struct mcr_Interface * |
interfacePt | ) |
|
§ mcr_Interface_reset()
Deinit and reinitialize data.
- Precondition
- If mcr_Interface::init and mcr_Interface::deinit are not defined then nothing will be done. Zeroing object would be unsafe here.
- Parameters
-
| interfacePt | |
| dataMemberPt | opt Data to reset. Do nothing if this is null |
- Returns
- reterr
§ mcr_Interface_set_all()
Set all functions
- Parameters
-
§ mcr_Interface_set_data()
| MCR_API int mcr_Interface_set_data |
( |
const struct mcr_Interface * |
interfacePt, |
|
|
struct mcr_DataMember * |
dataMemberPt, |
|
|
void * |
data, |
|
|
bool |
heapFlag |
|
) |
| |
Replace object reference using an interface
Existing data will be freed. The assigned data will be copied directly and without modification.
- Parameters
-
- Returns
- reterr