the_Foundation 1.0
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Functions
object.h File Reference
#include "defs.h"
#include "class.h"
#include "atomic.h"

Data Structures

struct  iObject
 

Macros

#define iNew(typeName)   ((i##typeName *) new_Object(&Class_##typeName))
 
#define iDeclareObjectConstruction(typeName)
 
#define iDeclareObjectConstructionArgs(typeName, ...)
 
#define iDefineObjectConstruction(typeName)
 
#define iDefineObjectConstructionArgs(typeName, newArgs, ...)
 
#define iDeclareObjectSerialization(typeName)
 
#define iAssertIsObject(d)   checkSignature_Object(d)
 
#define iChangeRef(d, ptr)   { iRelease(d); (d) = ref_Object(ptr); }
 
#define iReleasePtr(d)   { iAssert((d) != NULL); if (d) { deref_Object(*(d)); *(d) = NULL; } }
 
#define iClob(d)   iReleaseLater(d)
 

Typedefs

typedef void iAnyObject
 

Functions

iAnyObject * new_Object (const iAnyClass *)
 
void deinit_Object (iAnyObject *)
 
iAnyObject * ref_Object (const iAnyObject *)
 
void deref_Object (const iAnyObject *)
 
const iClass * class_Object (const iAnyObject *)
 
void setUserData_Object (iAnyObject *, void *user)
 
void * userData_Object (const iAnyObject *)
 
iAudienceMember * audienceMember_Object (const iAnyObject *)
 
int totalCount_Object (void)
 
void checkSignature_Object (const iAnyObject *)
 

Detailed Description

Reference-counted object.

Object is reference-counted and gets deleted only after all references are gone. Object is used as a base class for many of the objects in the_Foundation.

Authors
Copyright (c) 2017 Jaakko Keränen jaakk.nosp@m.o.ke.nosp@m.ranen.nosp@m.@iki.nosp@m..fi
License

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Macro Definition Documentation

◆ iDeclareObjectConstruction

#define iDeclareObjectConstruction ( typeName)
Value:
i##typeName *new_##typeName(void); \
iLocalDef i##typeName *collect_##typeName(i##typeName *d) { \
return iCollectDel(d, (iDeleteFunc) deref_Object); \
} \
void init_##typeName(i##typeName *d); \
void deinit_##typeName(i##typeName *d); \
iLocalDef const i##typeName##Class *class_##typeName(const i##typeName *d) { \
return (const i##typeName##Class *) class_Object(d);\
}

◆ iDeclareObjectConstructionArgs

#define iDeclareObjectConstructionArgs ( typeName,
... )
Value:
i##typeName *new_##typeName(__VA_ARGS__); \
iLocalDef i##typeName *collect_##typeName(i##typeName *d) { \
return iCollectDel(d, (iDeleteFunc) deref_Object); \
} \
void init_##typeName(i##typeName *d, __VA_ARGS__); \
void deinit_##typeName(i##typeName *d); \
iLocalDef const i##typeName##Class *class_##typeName(const i##typeName *d) { \
return (const i##typeName##Class *) class_Object(d);\
}

◆ iDeclareObjectSerialization

#define iDeclareObjectSerialization ( typeName)
Value:
void serialize_##typeName(const i##typeName *, iStream *); \
void deserialize_##typeName(i##typeName *, iStream *);

◆ iDefineObjectConstruction

#define iDefineObjectConstruction ( typeName)
Value:
i##typeName *new_##typeName(void) { \
i##typeName *d = iNew(typeName); \
init_##typeName(d); \
return d; \
} \

◆ iDefineObjectConstructionArgs

#define iDefineObjectConstructionArgs ( typeName,
newArgs,
... )
Value:
i##typeName *new_##typeName newArgs { \
i##typeName *d = iNew(typeName); \
init_##typeName(d, __VA_ARGS__); \
return d; \
}

Function Documentation

◆ new_Object()

iAnyObject * new_Object ( const iAnyClass * )

Constructs a new object.

Parameters
classObject class. Determines how much memory is allocated for the object.