xref: /petsc/src/sys/objects/gcookie.c (revision 0700a8246d308f50502909ba325e6169d3ee27eb)
1 #define PETSC_DLL
2 /*
3      Provides utility routines for manulating any type of PETSc object.
4 */
5 #include "petscsys.h"  /*I   "petscsys.h"    I*/
6 
7 #undef __FUNCT__
8 #define __FUNCT__ "PetscObjectGetClassid"
9 /*@C
10    PetscObjectGetClassid - Gets the classid for any PetscObject,
11 
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          PetscObjectGetClassid((PetscObject)mat,&classid);
18 
19    Output Parameter:
20 .  classid - the classid
21 
22    Level: developer
23 
24 @*/
25 PetscErrorCode PETSC_DLLEXPORT PetscObjectGetClassid(PetscObject obj,PetscClassId *classid)
26 {
27   PetscFunctionBegin;
28   PetscValidHeader(obj,1);
29   *classid = obj->classid;
30   PetscFunctionReturn(0);
31 }
32 
33 #undef __FUNCT__
34 #define __FUNCT__ "PetscObjectExists"
35 /*@
36    PetscObjectExists - Determines whether a PETSc object has been destroyed.
37 
38    Not Collective
39 
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          PetscObjectGetClassid((PetscObject)mat,&exists);
44 
45    Output Parameter:
46 .  exists - PETSC_FALSE if object does not exist; PETSC_TRUE if object does exist.
47 
48    Level: developer
49 
50 @*/
51 PetscErrorCode PETSC_DLLEXPORT PetscObjectExists(PetscObject obj,PetscTruth *exists)
52 {
53   PetscFunctionBegin;
54   *exists = PETSC_FALSE;
55   if (!obj) PetscFunctionReturn(0);
56   if (obj->classid >= PETSC_SMALLEST_CLASSID && obj->classid <= PETSC_LARGEST_CLASSID) *exists = PETSC_TRUE;
57   PetscFunctionReturn(0);
58 }
59 
60