(file) Return to listener.c CVS log (file) (dir) Up to [OMI] / omi / indication / indimgr

 1 krisbash 1.1 /*
 2              **==============================================================================
 3              **
 4              ** Open Management Infrastructure (OMI)
 5              **
 6              ** Copyright (c) Microsoft Corporation
 7              ** 
 8              ** Licensed under the Apache License, Version 2.0 (the "License"); you may not 
 9              ** use this file except in compliance with the License. You may obtain a copy 
10              ** of the License at 
11              **
12              **     http://www.apache.org/licenses/LICENSE-2.0 
13              **
14              ** THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15              ** KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 
16              ** WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 
17              ** MERCHANTABLITY OR NON-INFRINGEMENT. 
18              **
19              ** See the Apache 2 License for the specific language governing permissions 
20              ** and limitations under the License.
21              **
22 krisbash 1.1 **==============================================================================
23              */
24              
25              #include <indication/common/indilog.h>
26              #include "listener.h"
27              
28              const MI_Uint32 g_ListenerMagic = 0xF11EE1FF;
29              MI_Uint32 g_ListenerTempID = 1;
30              
31              void Listener_Finalize(CimBase *self)
32              {
33                  DEBUG_ASSERT(self);
34                  trace_FunctionEntered(__FILE__, __LINE__);
35                  return;
36              }
37              
38              /* Create identifier of current object */
39              MI_Char* CreateListenerIdentifier(_In_ CimBase *self)
40              {
41                  DEBUG_ASSERT(self);
42                  if (self->_magic != g_ListenerMagic)
43 krisbash 1.1     {
44                      trace_ObjectIsnotValidListener(self);
45                      return NULL;
46                  }
47                  return GetID(g_ListenerTempID++, TEMP_LISTENER_ID_PREFIX, self->batch);;
48              }
49              
50              CimBaseFT g_listenerft =
51              {
52                  CimBase_AddRef,
53                  CimBase_Release,
54                  Listener_Finalize,
55                  CimBase_OnAdd,
56                  CimBase_OnRemove,
57                  CreateListenerIdentifier,
58              };
59              
60              Listener* Listener_New(PersistenceType type)
61              {
62                  Listener* listener = NULL;
63                  listener = (Listener*)CimBase_Create(sizeof(Listener));
64 krisbash 1.1     if (NULL == listener)
65                  {
66                      LOGD_BATCH_OOM;
67                      return NULL;
68                  }
69                  listener->PersistenceType = type;
70                  CimBase_Set_Magic(&listener->base, g_ListenerMagic);
71                  CimBase_Set_FT(&listener->base, &g_listenerft);
72              
73                  Listener_AddRef(listener);
74                  return listener;
75              }
76              
77              /* Add a reference to a Listener object */
78              _Use_decl_annotations_
79              int Listener_AddRef(Listener* self)
80              {
81                  DEBUG_ASSERT(self);
82                  return self->base._ft->addref((CimBase*)self);
83              }
84              
85 krisbash 1.1 /* Release a reference to a Listener object */
86              _Use_decl_annotations_
87              int Listener_Release(Listener* self)
88              {
89                  DEBUG_ASSERT(self);
90                  return self->base._ft->release((CimBase*)self);
91              }
92              
93              /* Get reference count */
94              int Listener_GetRefcount(_In_ Listener *self)
95              {
96                  DEBUG_ASSERT(self);
97                  return CimBase_GetRefcount((CimBase*)self);
98              }
99              

ViewCVS 0.9.2