next up previous contents
Next: Setting and checking mask Up: Accessing the mask from Previous: Accessing the mask from   Contents


Registering a new type

Bits of the mask are allocated to a new type using the function:

$\textstyle \parbox{\linewidth}{
\vspace{\baselineskip}\noindent\texttt{
int Spa...
...tate\_list}] A list of names, one for each state, or NULL.
\end{description}}
}$

An appropriate number of bits of the mask are allocated to hold a unique value for the $n$ states specified by the nstates argument. The registration must take place before the type can be used, so for instance, this could be scheduled at CCTK_STARTUP. The function returns a $-1$ if the required states cannot be allocated (for example, if there are not enough free bits remaining in the mask), otherwise it returns $0$.

It is possible to allocate a portion of the mask without assigning names to any of the states by passing NULL as the state_list. This is useful when some integer number of states is required for a given type, but the number of states and appropriate names are not known at compile time. States which are allocated in this way can be accessed using the SpaceMask_GetStateBitsList().

New states can be added to an already allocated type using the function:

$\textstyle \parbox{\linewidth}{
\vspace{\baselineskip}\noindent\texttt{
int Spa...
...e\_list}] A list of names, one for each of the new
states.
\end{description}}}$

A number of new bits will be added to the specified type appropriate to hold the number of existing states plus the extra states. The allocated bits need not be contiguous within the mask. The function returns $0$ if successful, otherwise a $-1$ if the new states could not be allocated.


next up previous contents
Next: Setting and checking mask Up: Accessing the mask from Previous: Accessing the mask from   Contents