BUG#: 8763
[tpot/pegasus/.git] / src / Pegasus / ProviderManagerService / OOPProviderManagerRouter.h
1 //%LICENSE////////////////////////////////////////////////////////////////
2 //
3 // Licensed to The Open Group (TOG) under one or more contributor license
4 // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
5 // this work for additional information regarding copyright ownership.
6 // Each contributor licenses this file to you under the OpenPegasus Open
7 // Source License; you may not use this file except in compliance with the
8 // License.
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining a
11 // copy of this software and associated documentation files (the "Software"),
12 // to deal in the Software without restriction, including without limitation
13 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 // and/or sell copies of the Software, and to permit persons to whom the
15 // Software is furnished to do so, subject to the following conditions:
16 //
17 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28 //////////////////////////////////////////////////////////////////////////
29 //
30 //%/////////////////////////////////////////////////////////////////////////////
31
32 #ifndef Pegasus_OOPProviderManagerRouter_h
33 #define Pegasus_OOPProviderManagerRouter_h
34
35 #include <Pegasus/Common/Config.h>
36 #include <Pegasus/Common/String.h>
37 #include <Pegasus/Common/HashTable.h>
38 #include <Pegasus/Common/CIMMessage.h>
39
40 #include <Pegasus/ProviderManager2/ProviderManager.h>
41 #include <Pegasus/ProviderManagerService/ProviderManagerRouter.h>
42 #include <Pegasus/ProviderManagerService/Linkage.h>
43
44 #include \
45     <Pegasus/Server/ProviderRegistrationManager/ProviderRegistrationManager.h>
46
47 PEGASUS_NAMESPACE_BEGIN
48
49 typedef void (*PEGASUS_PROVIDERMODULEFAIL_CALLBACK_T)(const String &,
50     const String &, Uint16);
51
52 class ProviderAgentContainer;
53
54 typedef HashTable<String, ProviderAgentContainer*, EqualFunc<String>,
55     HashFunc<String> > ProviderAgentTable;
56
57 class PEGASUS_PMS_LINKAGE OOPProviderManagerRouter
58     : public ProviderManagerRouter
59 {
60 public:
61     OOPProviderManagerRouter(
62         ProviderRegistrationManager *providerRegistrationManager,
63         PEGASUS_INDICATION_CALLBACK_T indicationCallback,
64         PEGASUS_RESPONSE_CHUNK_CALLBACK_T responseChunkCallback,
65         PEGASUS_PROVIDERMODULEFAIL_CALLBACK_T providerModuleFailCallback);
66
67     virtual ~OOPProviderManagerRouter();
68
69     virtual Message* processMessage(Message* message);
70
71     virtual void unloadIdleProviders();
72
73     static ProviderRegistrationManager* getProviderRegistrationManager();
74
75 private:
76     //
77     // Private methods
78     //
79
80     /** determine moduleName from providerModule, function sets moduleName */
81     void _getProviderModuleName(
82         const CIMInstance & providerModule,
83         String & moduleName);
84
85     /**
86         Determine groupName from the providerModule. Function sets
87         groupName. A type prefix(grp or mod) is added to distinguish
88         between group and module names.
89         If ModuleGroupName property value is not specified, moduleName is set
90         to groupName.
91     */
92     void _getGroupNameWithType(
93         const CIMInstance &providerModule,
94         String &groupNameWithType);
95
96     /** Unimplemented */
97     OOPProviderManagerRouter();
98     /** Unimplemented */
99     OOPProviderManagerRouter(const OOPProviderManagerRouter&);
100     /** Unimplemented */
101     OOPProviderManagerRouter& operator=(const OOPProviderManagerRouter&);
102
103     /**
104         Return a pointer to the ProviderAgentContainer for the specified
105         module instance and requesting user.  If no appropriate
106         ProviderAgentContainer exists, one is created in an uninitialized state.
107      */
108     ProviderAgentContainer* _lookupProviderAgent(
109         const CIMInstance& providerModule,
110         CIMRequestMessage* request);
111
112     /**
113         Return an array of pointers to ProviderAgentContainers for the
114         specified moduleName.
115      */
116     Array<ProviderAgentContainer*> _lookupProviderAgents(
117         const String& moduleName);
118
119     /**
120         Send the specified CIMRequestMessage to all initialized Provider
121         Agents in the _providerAgentTable.
122      */
123     CIMResponseMessage* _forwardRequestToAllAgents(CIMRequestMessage* request);
124
125     //
126     // Private data
127     //
128
129     /**
130         Callback function to which all generated indications are sent for
131         processing.
132      */
133     PEGASUS_INDICATION_CALLBACK_T _indicationCallback;
134
135     /**
136         Callback function to which all response chunks are sent for processing.
137      */
138     PEGASUS_RESPONSE_CHUNK_CALLBACK_T _responseChunkCallback;
139
140     /**
141         Callback function to be called upon detection of failure of a
142         provider module.
143      */
144     PEGASUS_PROVIDERMODULEFAIL_CALLBACK_T _providerModuleFailCallback;
145
146     /**
147         The _providerAgentTable contains a ProviderAgentContainer entry for
148         each of the Provider Agent processes for which a request has been
149         processed.  ProviderAgentContainer objects are persistent; once one
150         is created it is never deleted.
151      */
152     ProviderAgentTable _providerAgentTable;
153     /**
154         The _providerAgentTableMutex must be locked whenever the
155         _providerAgentTable is accessed.
156      */
157     Mutex _providerAgentTableMutex;
158
159     static ProviderRegistrationManager *_providerRegistrationManager;
160
161 };
162
163 PEGASUS_NAMESPACE_END
164
165 #endif