root/ossie/branches/ossie-0.6.0/ossie/include/ossie/DomainManager_impl.h @ 2694

Revision 2694, 10.4 KB (checked in by phelps, 6 years ago)

Set svn property eol-style to native.

  • Property svn:eol-style set to native
Line 
1/****************************************************************************
2
3Copyright 2004, Virginia Polytechnic Institute and State University
4
5This file is part of the OSSIE Core Framework.
6
7OSSIE Core Framework is free software; you can redistribute it and/or modify
8it under the terms of the Lesser GNU General Public License as published by
9the Free Software Foundation; either version 2.1 of the License, or
10(at your option) any later version.
11
12OSSIE Core Framework is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15Lesser GNU General Public License for more details.
16
17You should have received a copy of the Lesser GNU General Public License
18along with OSSIE Core Framework; if not, write to the Free Software
19Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
21****************************************************************************/
22
23#ifndef __DOMAINMANAGER_IMPL__
24#define __DOMAINMANAGER_IMPL__
25
26
27#ifdef MS_dotNET
28#pragma warning( disable : 4290 )    // there's an annoying VC7 warning that I wanted to make go away
29#endif
30
31#include <vector>
32
33#ifdef HAVE_OMNIEVENTS
34#include "CosEventComm.hh"
35#include "CosEventChannelAdmin.hh"
36#endif
37
38#include "cf.h"
39
40#ifdef MS_dotNET
41#include "ossiecf.h"
42#endif
43
44#include "FileManager_impl.h"
45
46#include "DeviceManager_impl.h"
47
48#include "ApplicationFactory_impl.h"
49
50#include "DMDParser.h"
51
52#include "SPDParser.h"
53
54#include "PRFParser.h"
55
56#include "SCDParser.h"
57
58#include "StandardEvent.h"
59
60#include "automaticTest.h"
61
62#define MAX_APPS        10
63
64#define MAX_APP_FACS    10
65
66#define MAX_DEV_MGRS    10
67
68class OSSIECF_API DomainManager_impl;
69
70#ifdef HAVE_OMNIEVENTS
71class OSSIECF_API DomainManagerEventHandler:public virtual
72POA_CosEventComm::PushConsumer
73{
74    public:DomainManagerEventHandler (DomainManager_impl * _dmn);
75    void
76        push (const CORBA::Any & _any)
77        throw (CosEventComm::Disconnected, CORBA::SystemException);
78    void
79        disconnect_push_consumer ()
80        throw (CORBA::SystemException);
81
82    private:DomainManager_impl *
83            _dmnMgr;
84
85};
86#endif
87
88class OSSIECF_API
89DomainManager_impl:
90public
91    virtual
92    POA_CF::DomainManager,
93public
94    PropertySet_impl
95    {
96        public:DomainManager_impl (int argc, char **argv);
97        ~
98            DomainManager_impl ();
99
100        char *
101            identifier (void)
102            throw (CORBA::SystemException);
103        char *
104            domainManagerProfile (void)
105            throw (CORBA::SystemException);
106        void
107            registerDevice (CF::Device_ptr registeringDevice,
108            CF::DeviceManager_ptr registeredDeviceMgr)
109            throw (CF::DomainManager::RegisterError,
110            CF::DomainManager::DeviceManagerNotRegistered, CF::InvalidProfile,
111            CF::InvalidObjectReference, CORBA::SystemException);
112        void
113            registerDeviceManager (CF::DeviceManager_ptr deviceMgr)
114            throw (CF::DomainManager::RegisterError, CF::InvalidProfile,
115            CF::InvalidObjectReference, CORBA::SystemException);
116        void
117            unregisterDeviceManager (CF::DeviceManager_ptr deviceMgr)
118            throw (CF::DomainManager::UnregisterError, CF::InvalidObjectReference,
119            CORBA::SystemException);
120        void
121            unregisterDevice (CF::Device_ptr unregisteringDevice)
122            throw (CF::DomainManager::UnregisterError, CF::InvalidObjectReference,
123            CORBA::SystemException);
124        void
125            installApplication (const char *profileFileName)
126            throw (CF::DomainManager::ApplicationInstallationError, CF::InvalidFileName,
127            CF::InvalidProfile, CORBA::SystemException);
128        void
129            uninstallApplication (const char *applicationId)
130            throw (CF::DomainManager::ApplicationUninstallationError,
131            CF::DomainManager::InvalidIdentifier, CORBA::SystemException);
132        void
133            registerService (CORBA::Object_ptr registeringService,
134            CF::DeviceManager_ptr registeredDeviceMgr,
135            const char *name)
136            throw (CF::DomainManager::RegisterError,
137            CF::DomainManager::DeviceManagerNotRegistered,
138            CF::InvalidObjectReference, CORBA::SystemException);
139        void
140            unregisterService (CORBA::Object_ptr unregisteringService, const char *name)
141            throw (CF::DomainManager::UnregisterError, CF::InvalidObjectReference,
142            CORBA::SystemException);
143        void
144            registerWithEventChannel (CORBA::Object_ptr registeringObject,
145            const char *registeringId,
146            const char *eventChannelName)
147            throw (CF::DomainManager::AlreadyConnected,
148            CF::DomainManager::InvalidEventChannelName,
149            CF::InvalidObjectReference, CORBA::SystemException);
150        void
151            unregisterFromEventChannel (const char *unregisteringId,
152            const char *eventChannelName)
153            throw (CF::DomainManager::NotConnected,
154            CF::DomainManager::InvalidEventChannelName, CORBA::SystemException);
155        CF::FileManager_ptr
156            fileMgr (void)
157            throw (CORBA::SystemException);
158        CF::DomainManager::ApplicationFactorySequence *
159            applicationFactories (void)
160            throw (CORBA::SystemException);
161        CF::DomainManager::ApplicationSequence *
162            applications (void)
163            throw (CORBA::SystemException);
164        CF::DomainManager::DeviceManagerSequence *
165            deviceManagers (void)
166            throw (CORBA::SystemException);
167
168#ifdef AUTOMATIC_TEST
169        void
170            displayAttributes (void);
171        void
172            displayDeviceManagers (void);
173        void
174            displayRegisteredDevices (void);
175        void
176            displayRegisteredServices (void);
177#endif                                        //End AUTOMATIC_TEST
178
179#ifdef HAVE_OMNIEVENTS
180        friend void
181            DomainManagerEventHandler::push (const CORBA::Any &);
182        friend void
183            DomainManagerEventHandler::disconnect_push_consumer ();
184#endif
185
186        protected:
187        struct DeviceNode
188        {
189            CF::Device_ptr  devicePtr;
190            char*   softwareProfile;
191            char*   label;
192
193            CF::DeviceManager_ptr   devMgrPtr;
194
195            CF::Properties  properties;
196
197            DeviceNode():softwareProfile(NULL), label(NULL)
198            {}
199
200            ~DeviceNode()
201            {
202                if (softwareProfile!=NULL) delete []softwareProfile;    // technically, you can safely delete NULL ptr -TP
203                if (label!=NULL) delete []label;
204
205                CORBA::release(devicePtr);
206                CORBA::release(devMgrPtr);
207            }
208        };
209
210        struct ServiceNode
211        {
212            CORBA::Object_ptr       objectPtr;
213            char*                   name;
214            CF::DeviceManager_ptr   devMgrPtr;
215
216            ServiceNode():name(NULL)
217            {}
218
219            ~ServiceNode()  // should we call CORBA::release() for those _ptr(s)? -TP
220            {
221                if (name!=NULL) delete []name;
222                CORBA::release(objectPtr);
223                CORBA::release(devMgrPtr);
224            }
225        };
226        enum ErrorCode
227        {
228            NULL_ERROR,
229            FILE_NOT_FOUND,
230            NOT_SCA_COMPLIANT,
231            NO_PROPERTIES
232        };
233        char *
234            _identifier;
235        char *
236            _domainManagerProfile;
237        vector <
238            DeviceNode * >
239            _registeredDevices;
240        vector <
241            ServiceNode * >
242            _registeredServices;
243        vector <
244            Connection * >
245            _pendingConnections;
246
247        CF::DomainManager::DeviceManagerSequence
248            _deviceManagers;
249        CF::DomainManager::ApplicationSequence
250            _applications;
251        int
252            _numApps;
253        int
254            _numDevMgrs;
255
256        CF::FileManager_ptr
257            _fileMgr;
258
259        void
260            validate (const char *_profile);
261        void
262            validateSPD (const char *_spdProfile, int _cnt = 0);
263        void
264            removeSPD (const char *_spdProfile, int _cnt = 0);
265        DomainManager_impl::ErrorCode
266            storeDeviceInDomainMgr (CF::Device_ptr, CF::DeviceManager_ptr);
267        void
268            storeServiceInDomainMgr (CORBA::Object_ptr, CF::DeviceManager_ptr, const char *);
269        DomainManager_impl::ErrorCode
270            getDeviceProperties (DeviceNode &);
271        void
272            removeDeviceFromDomainMgr (CF::Device_ptr);
273        void
274            removeServiceFromDomainMgr (CORBA::Object_ptr, const char *);
275        bool
276            deviceMgrIsRegistered (CF::DeviceManager_ptr);
277        bool
278            deviceIsRegistered (CF::Device_ptr);
279        bool
280            serviceIsRegistered (const char *);
281        void
282            establishServiceConnections (CF::Device_ptr, CF::DeviceManager_ptr);
283        void
284            establishPendingServiceConnections (const char *);
285        void
286            disconnectThisService (const char *);
287        void
288            disconectEventService ();
289        void
290            sendEventToOutgoingChannel (CORBA::Any & _event);
291        void
292            addDeviceMgr (CF::DeviceManager_ptr deviceMgr);
293        void
294            addDeviceMgrDevices (CF::DeviceManager_ptr deviceMgr);
295        void
296            addDeviceMgrServices (CF::DeviceManager_ptr deviceMgr);
297        void
298            removeDeviceMgrDevices (CF::DeviceManager_ptr deviceMgr);
299        void
300            removeDeviceMgrServices (CF::DeviceManager_ptr deviceMgr);
301        void
302            removeDeviceMgr (CF::DeviceManager_ptr deviceMgr);
303
304    private:
305        DomainManager_impl(DomainManager_impl &); // No copying
306        void init (int, char **);
307   
308   
309        vector <ApplicationFactory_impl *> appFact_servants;
310        CF::DomainManager::ApplicationFactorySequence _applicationFactories;
311
312    // Event Channel objects
313    void createEventChannels (void);
314
315#ifdef HAVE_OMNIEVENTS
316    /// todo Move all Event channel support into OSSIE support
317    CosEventChannelAdmin::EventChannel_var ODM_channel;
318    CosEventChannelAdmin::EventChannel_var IDM_channel;
319
320    CosEventChannelAdmin::ProxyPushConsumer_var ODM_Channel_consumer;
321
322    CosEventChannelAdmin::ProxyPushConsumer_var connectEventChannel(CosEventChannelAdmin::EventChannel_var eventChannel);
323#endif
324
325    };                                            /* END CLASS DEFINITION DomainManager */
326
327
328#endif                                            /* __DOMAINMANAGER_IMPL__ */
Note: See TracBrowser for help on using the browser.