Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
opcodegarray.h File Reference

Go to the source code of this file.

Macros

#define CS_TYPEDEF_GROWING_ARRAY_EXT(Name, Type, ExtraConstructor, Extra)
 
#define CS_TYPEDEF_GROWING_ARRAY(Name, Type)   CS_TYPEDEF_GROWING_ARRAY_EXT (Name, Type, ;, ;)
 
#define CS_TYPEDEF_GROWING_ARRAY_REF(Name, Type)
 
#define CS_DECLARE_GROWING_ARRAY(Name, Type)   CS_TYPEDEF_GROWING_ARRAY(__##Name##_##Type,Type) Name
 
#define CS_DECLARE_GROWING_ARRAY_REF(Name, Type)   CS_TYPEDEF_GROWING_ARRAY_REF(__##Name,Type) Name
 

Macro Definition Documentation

#define CS_DECLARE_GROWING_ARRAY (   Name,
  Type 
)    CS_TYPEDEF_GROWING_ARRAY(__##Name##_##Type,Type) Name

This is a shortcut for above to declare a dummy class and a single instance of that class.

Usage examples:

CS_DECLARE_GROWING_ARRAY (la, csLight*);
CS_DECLARE_GROWING_ARRAY (ia, int);

Definition at line 136 of file opcodegarray.h.

#define CS_DECLARE_GROWING_ARRAY_REF (   Name,
  Type 
)    CS_TYPEDEF_GROWING_ARRAY_REF(__##Name,Type) Name

Same as above but declares an object which has a reference counter.

Definition at line 142 of file opcodegarray.h.

#define CS_TYPEDEF_GROWING_ARRAY (   Name,
  Type 
)    CS_TYPEDEF_GROWING_ARRAY_EXT (Name, Type, ;, ;)

This is a macro that will declare a growable array variable that is able to contain a number of elements of given type.

Methods:

  • void SetLimit (int) - set max number of values the array can hold
  • int Limit () - query max number of values the array can hold
  • void SetLength (int) - set the amount of elements that are actually used
  • int Length () - query the amount of elements that are actually used
  • operator [] (int) - return a reference to Nth element of the array

Usage examples:

CS_TYPEDEF_GROWING_ARRAY (csLightArray, csLight*);
CS_TYPEDEF_GROWING_ARRAY (csIntArray, int);
static csLightArray la;
static csIntArray ia;

Definition at line 101 of file opcodegarray.h.

#define CS_TYPEDEF_GROWING_ARRAY_EXT (   Name,
  Type,
  ExtraConstructor,
  Extra 
)

Definition at line 24 of file opcodegarray.h.

#define CS_TYPEDEF_GROWING_ARRAY_REF (   Name,
  Type 
)
Value:
CS_TYPEDEF_GROWING_ARRAY_EXT (Name, Type, RefCount = 0, \
int RefCount; \
void IncRef () \
{ RefCount++; } \
void DecRef () \
{ \
if (RefCount == 1) SetLimit (0); \
RefCount--; \
})

Same as TYPEDEF_GROWING_ARRAY but contains additionally an reference counter, so that the object can be shared among different clients. If you do an IncRef each time you make use of it and an DecRef when you're done, the array will be automatically freed when there are no more references to it.

Methods:

  • void IncRef ()/void DecRef () - Reference counter management

Definition at line 115 of file opcodegarray.h.