Actual source code: gcookie.c
1: /*$Id: gcookie.c,v 1.25 2001/03/23 23:20:38 balay Exp $*/
2: /*
3: Provides utility routines for manulating any type of PETSc object.
4: */
5: #include petsc.h
7: #undef __FUNCT__
9: /*@C
10: PetscObjectGetCookie - Gets the cookie for any PetscObject,
12: Not Collective
13:
14: Input Parameter:
15: . obj - any PETSc object, for example a Vec, Mat or KSP.
16: Thus must be cast with a (PetscObject), for example,
17: PetscObjectGetCookie((PetscObject)mat,&cookie);
19: Output Parameter:
20: . cookie - the cookie
22: Level: developer
24: @*/
25: int PetscObjectGetCookie(PetscObject obj,int *cookie)
26: {
28: if (!obj) SETERRQ(PETSC_ERR_ARG_CORRUPT,"Null object");
29: *cookie = obj->cookie;
30: return(0);
31: }
33: #undef __FUNCT__
35: /*@
36: PetscObjectExists - Determines whether a PETSc object has been destroyed.
38: Not Collective
40: Input Parameter:
41: . obj - any PETSc object, for example a Vec, Mat or KSP.
42: Thus must be cast with a (PetscObject), for example,
43: PetscObjectGetCookie((PetscObject)mat,&exists);
45: Output Parameter:
46: . exists - PETSC_FALSE if object does not exist; PETSC_TRUE if object does exist.
48: Level: developer
50: @*/
51: int PetscObjectExists(PetscObject obj,PetscTruth *exists)
52: {
54: *exists = PETSC_FALSE;
55: if (!obj) return(0);
56: if (obj->cookie >= PETSC_COOKIE && obj->cookie <= PETSC_LARGEST_COOKIE) *exists = PETSC_TRUE;
57: return(0);
58: }