root/ossiedev/trunk/system/ossie/framework/DeviceManager_impl.cpp @ 8759

Revision 8759, 24.3 KB (checked in by shereef, 4 years ago)

DeviceManager? now searches for matching Device implementations but it's not working yet

  • Property svn:eol-style set to native
Line 
1/****************************************************************************
2
3Copyright 2008, 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
21Nov/10/03       C. Neely        Created
22C. Aguayo
23
24****************************************************************************/
25#include <iostream>
26
27#include <string.h>
28#ifdef HAVE_UNISTD_H
29#include <unistd.h>
30#else  /// \todo change else to ifdef windows var
31#include <process.h>
32#endif
33#ifdef HAVE_STDLIB_H
34#include <stdlib.h>
35#endif
36#include <errno.h>
37
38#include "ossie/debug.h"
39#include "ossie/ossieSupport.h"
40#include "ossie/DeviceManager_impl.h"
41#include "ossie/DPDParser.h"
42#include "ossie/portability.h"
43
44DeviceManager_impl::~DeviceManager_impl ()
45{
46}
47
48
49DeviceManager_impl::DeviceManager_impl(const char *DCDInput, const char* _rootfs)
50{
51  _fsroot = _rootfs;
52  _deviceConfigurationProfile = DCDInput;
53}
54
55//Parsing constructor
56void DeviceManager_impl::post_constructor (CF::DeviceManager_var my_object_var) throw (CORBA::SystemException)
57
58{
59    orb_obj = new ossieSupport::ORB();
60
61    myObj = my_object_var;
62
63    _registeredDevices.length(0);
64    _registeredServices.length(0);
65
66    fs_servant = new FileSystem_impl(_fsroot.c_str());
67    _fileSys = fs_servant->_this();
68
69    try
70    {
71     _fileSys->exists(_deviceConfigurationProfile.c_str());
72    } catch( CF::InvalidFileName &_ex ) {
73     std::cout << "[DeviceManager::post_ctor] While testing for the existence of DCD: " << _ex.msg << "\n";
74     exit(EXIT_FAILURE);
75    } catch( ... ) {
76     std::cout << "[DeciceManager::post_ctor] While testing for the existence of DCD: Unknown Exception\n";
77     exit(EXIT_FAILURE);
78    }
79
80//Get Device Manager attributes (deviceConfigurationProfile, identifier and label)
81//from DCD file
82    CF::File_var _dcd;
83    try
84    {
85     _dcd = _fileSys->open( _deviceConfigurationProfile.c_str(), true );
86    } catch( CF::InvalidFileName &_ex ) {
87     std::cout << "[DeviceManager::post_ctor] While opening DCD: " << _ex.msg << "\n";
88     exit(EXIT_FAILURE);
89    } catch( CF::FileException &_ex ) {
90     std::cout << "[DeviceManager::post_ctor] While opening DCD: " << _ex.msg << "\n";
91     exit(EXIT_FAILURE);
92    } catch( ... ) {
93     std::cout << "[DeviceManager::post_ctor] While opening DCD: Unknown Exception\n";
94     exit(EXIT_FAILURE);
95    }
96
97    DCDParser _DCDParser ( _dcd );
98    _dcd->close();
99    _identifier = _DCDParser.getID();
100    _label = _DCDParser.getName();
101
102    std::string _devmgrsoftpkg = _DCDParser.getDeviceManagerSoftPkg();
103
104    CF::File_var _devmgrspd;
105    try
106    {
107     _devmgrspd = _fileSys->open( _devmgrsoftpkg.c_str(), true );
108    } catch( CF::InvalidFileName &_ex ) {
109     std::cout << "[DeviceManager::post_ctor] While opening DeviceManager SPD: " << _ex.msg << "\n";
110     exit(EXIT_FAILURE);
111    } catch( CF::FileException &_ex ) {
112     std::cout << "[DeviceManager::post_ctor] While opening DeviceManager SPD: " << _ex.msg << "\n";
113     exit(EXIT_FAILURE);
114    } catch( ... ) {
115     std::cout << "[DeviceManager::post_ctor] While opening DeviceManager SPD: Unknown Exception\n";
116     exit(EXIT_FAILURE);
117    }
118
119    SPDParser _devmgrspdparser( _devmgrspd );
120    _devmgrspd->close();
121
122    // Parse DPD Files
123    std::vector <std::string> DPDList;
124
125    // get DPD files from DCD
126    for (int i = 0; i < _DCDParser.getDeployOnComponents()->size(); i++)
127    {
128        for (int j = 0; j < _DCDParser.getDeployOnComponents()[i].size(); j++)
129        {
130            DPDList.push_back(_DCDParser.getDeployOnComponents()[i][j]->getDPDFile());
131        }
132    }
133
134    // once DPD file names collected, parse them
135    CF::File_var _dpdFile;
136    std::vector <DPDParser*> _dpd;
137    for (int k = 0; k < DPDList.size(); k++)
138    {
139        try
140        {
141            _dpdFile = _fileSys->open(DPDList[k].c_str(), true);
142        } catch (CF::InvalidFileName &_ex) {
143            std::cout << "While Opening DPD: " << _ex.msg  << "\n";
144            exit(EXIT_FAILURE);
145        } catch (CF::FileException &_ex) {
146            std::cout << "While Opening DPD: " << _ex.msg << "\n";
147            exit(EXIT_FAILURE);
148        } catch (...) {
149            std::cout << "While Opening DPD: Unknown Exception\n";
150        }
151
152        DPDParser *newDPD = new DPDParser(_dpdFile);
153        _dpd.push_back(newDPD);
154
155    }
156
157
158//get DomainManager reference
159    getDomainManagerReference ((char *)_DCDParser.getDomainManagerName ());
160//Register DeviceManager with DomainManager
161    DEBUG(2, DevMgr, "Registering with DomainManager" )
162    try
163    {
164     _dmnMgr->registerDeviceManager (my_object_var);
165    } catch( CF::InvalidObjectReference &_ex ) {
166     std::cout << "[DeviceManager::post_ctor] While registering DevMgr with DomMgr: " << _ex.msg << "\n";
167     exit(EXIT_FAILURE);
168    } catch( ... ) {
169     std::cout << "[DeviceManager::post_ctor] While registering DevMgr with DomMgr: Unknown Exception\n";
170     exit(EXIT_FAILURE);
171    }
172
173    _adminState = DEVMGR_REGISTERED;
174
175//parse filesystem names
176
177//Parse local componenents from DCD files
178     std::vector <componentPlacement> componentPlacements = _DCDParser.getComponentPlacements ();
179     DEBUG(2, DevMgr, "ComponentPlacement size is" << componentPlacements.size())
180     for (unsigned int i = 0; i < componentPlacements.size(); i++)
181     {
182//get spd reference
183//parse spd file
184      CF::File_var _spd;
185      DEBUG(2, DevMgr, "Parsing Device SPD")
186      try
187      {
188       _spd = _fileSys->open( _DCDParser.getFileNameFromRefId(componentPlacements[i].refId()), true );
189      } catch( CF::InvalidFileName &_ex ) {
190       std::cout << "[DeviceManager::post_ctor] While opening SPD " << i << ": " << _ex.msg << "\n";
191       exit(EXIT_FAILURE);
192      } catch( CF::FileException &_ex ) {
193       std::cout << "[DeviceManager::post_ctor] While opening SPD " << i << ": " << _ex.msg << "\n";
194       exit(EXIT_FAILURE);
195      } catch( ... ) {
196       std::cout << "[DeviceManager::post_ctor] While opening SPD " << i << ": Unknown Exception\n";
197       exit(EXIT_FAILURE);
198      }
199
200      SPDParser _SPDParser ( _spd );
201      _spd->close();
202//get code file name from implementation
203      std::vector < SPDImplementation * >*_implementations = _SPDParser.getImplementations ();
204      DEBUG(2, DevMgr, "Searching for matching implementation")
205///-- Acquire implementation of DevMgr
206      std::vector < SPDImplementation * >*_devmgrspdimpl = _devmgrspdparser.getImplementations ();
207      int _implIdx = -1;
208///-- Match Device implementation to the DevMgr implementation
209      for( unsigned int j = 0; j < _implementations->size(); j++ )
210      {
211       std::cout << "[DeviceManager::post_ctor] Checking idx: " << j << std::endl;
212       std::vector< std::string > _devprocessors = (*_implementations)[j]->getProcessors();
213       std::vector< std::string > _devmgrprocessors = (*_devmgrspdimpl)[j]->getProcessors();
214        // Assume only one processor per implementation
215        // -- test if the target processor matches; if not, get next implementation
216       if( _devprocessors[0] != _devmgrprocessors[0] ) continue;
217       OSAttributes _devosattr = (*_implementations)[j]->getOperatingSystem();
218       OSAttributes _devmgrosattr = (*_devmgrspdimpl)[j]->getOperatingSystem();
219        // -- test if the target OS matches; if not, get next implementation
220       if( strcmp( _devosattr.getOSName(), _devmgrosattr.getOSName() ) != 0 ) continue;
221       _implIdx = j;
222       break;
223      }
224        // Not the best error handling, but it's sufficient for now
225        // if the index is still < 0, then no implemenation match was made; ERROR
226      if( _implIdx == -1 )
227      {
228       std::cout << "[DeviceManager::post_ctor] Device implementation does NOT match the DeviceManager implementation\n";
229       exit(EXIT_FAILURE);
230      } else {
231       std::cout << "[DeviceManager::post_ctor] Device implementation " << _implIdx << " matches that of the DeviceManager\n";
232      }
233
234//spawn device
235#ifdef HAVE_WORKING_FORK
236      int myPid2;
237
238      DEBUG(2, DevMgr, "Launching Device file " << (*_implementations)[_implIdx]->getCodeFile () << " Usage name " << componentPlacements[_implIdx].usageName())
239
240      if ((myPid2 = fork()) < 0) std::cout << "Fork Error" << std::endl;
241      if (myPid2 == 0)
242      {
243        // in child
244       if (getenv("VALGRIND")) {
245        std::string logFile = "--log-file=";
246        logFile += (*_implementations)[_implIdx]->getCodeFile ();
247        char *val = "/usr/local/bin/valgrind";
248        execl(val, val, logFile.c_str(), (*_implementations)[_implIdx]->getCodeFile (), componentPlacements[i].id(), componentPlacements[i].usageName() , _DCDParser.getFileNameFromRefId(componentPlacements[i].refId()), NULL);
249        } else {
250         execl((*_implementations)[_implIdx]->getCodeFile (), (*_implementations)[_implIdx]->getCodeFile (),componentPlacements[i].id(), componentPlacements[i].usageName() , _DCDParser.getFileNameFromRefId(componentPlacements[i].refId()), NULL);
251        }
252        std::cout << "Device did not execute : " << strerror(errno) << std::endl;
253        exit (EXIT_FAILURE);
254      }
255#endif
256      ossieSupport::nsleep(0, 1000*1000);
257      CORBA::Object_var _obj = CORBA::Object::_nil();
258      char nameStr[255];
259      sprintf( nameStr, "DomainName1/%s", componentPlacements[i].usageName() );      DEBUG(3, DevMgr, "searching for "<< nameStr)
260      do
261      {
262/// \todo sleep prevents system from beating Name Service to death, Fix better
263       ossieSupport::nsleep(0, 50*1000);
264       try
265       {
266        _obj = orb_obj->get_object_from_name(nameStr);
267       } catch (CosNaming::NamingContext::NotFound) {
268        ossieSupport::nsleep(0, 100*1000);
269       } catch( ... ) {
270        std::cout << "[DeviceManager::post_ctor] While obtaining NamingContext: Unknown Exception\n";
271        exit(EXIT_FAILURE);
272       }
273      } while (CORBA::is_nil (_obj));
274      DEBUG(3, DevMgr, "found "<< nameStr)
275
276      CF::Device_var tempDevice = CF::Device::_narrow (_obj);
277      tempDevice->initialize ();
278
279      if( strlen( _SPDParser.getPRFFile() ) > 0 )
280      {
281//Get properties from PRF
282       CF::File_var _prf;
283       try
284       {
285        _prf = _fileSys->open( _SPDParser.getPRFFile(), true );
286       } catch( CF::InvalidFileName &_ex ) {
287        std::cout << "[DeviceManager::post_ctor] While opening PRF " << _SPDParser.getPRFFile() <<  ": " << _ex.msg << "\n";
288        exit(EXIT_FAILURE);
289       } catch( CF::FileException &_ex ) {
290        std::cout << "[DeviceManager::post_ctor] While opening PRF " << _SPDParser.getPRFFile() << ": " << _ex.msg << "\n";
291        exit(EXIT_FAILURE);
292       } catch( ... ) {
293        std::cout << "[DeviceManager::post_ctor] While opening PRF: Unknown Exception\n";
294        exit(EXIT_FAILURE);
295       }
296
297       PRFParser _PRFparser ( _prf );
298       _prf->close();
299       std::vector <PRFProperty *> *prfSimpleProp = _PRFparser.getConfigureProperties ();
300       CF::Properties configCapacities;
301       configCapacities.length (prfSimpleProp->size ());
302       for (unsigned int i = 0; i < prfSimpleProp->size (); i++)
303       {
304        configCapacities[i] = *((*prfSimpleProp)[i]->getDataType ());
305       }
306
307//configure properties
308       DEBUG(3, DevMgr, "Configuring capacities")
309       tempDevice->configure (configCapacities);
310      }
311
312      DEBUG(3, DevMgr, "Registering device")
313      try
314      {
315       registerDevice (CF::Device::_duplicate(tempDevice));
316      } catch( CF::InvalidObjectReference &_ex ) {
317       std::cout << "[DeviceManager::post_ctor] While registering Device: " << _ex.msg << "\n";
318       exit(EXIT_FAILURE);
319      } catch( ... ) {
320       std::cout << "[DeviceManager::post_ctor] While registering Device: Unknown Exception\n";
321       exit(EXIT_FAILURE);
322      }
323
324      DEBUG(3, DevMgr, "Device Registered")
325     }
326}
327
328
329void
330DeviceManager_impl::init ()
331{
332
333    _adminState = DEVMGR_UNREGISTERED;
334}
335
336
337void
338DeviceManager_impl::getDomainManagerReference (char *domainManagerName)
339{
340    CORBA::Object_var obj = CORBA::Object::_nil();
341
342/// \todo sleep prevents system from beating Name Service to death, Fix better
343    do{
344      obj = orb_obj->get_object_from_name (domainManagerName);
345      usleep(1000);
346    }while(CORBA::is_nil(obj));
347
348    _dmnMgr = CF::DomainManager::_narrow (obj);
349}
350
351
352char *DeviceManager_impl::deviceConfigurationProfile ()
353throw (CORBA::SystemException)
354{
355    return CORBA::string_dup(_deviceConfigurationProfile.c_str());
356}
357
358
359CF::FileSystem_ptr DeviceManager_impl::fileSys ()throw (CORBA::
360SystemException)
361{
362    CF::FileSystem_var result = _fileSys;
363    return result._retn();
364}
365
366
367char *DeviceManager_impl::identifier ()
368throw (CORBA::SystemException)
369{
370    return CORBA::string_dup (_identifier.c_str());
371}
372
373
374char *DeviceManager_impl::label ()
375throw (CORBA::SystemException)
376{
377    return CORBA::string_dup (_label.c_str());
378}
379
380
381CF::DeviceSequence *
382DeviceManager_impl::registeredDevices ()throw (CORBA::SystemException)
383{
384    CF::DeviceSequence_var result = new CF::DeviceSequence(_registeredDevices);
385    return result._retn();
386}
387
388
389CF::DeviceManager::ServiceSequence *
390DeviceManager_impl::registeredServices ()throw (CORBA::SystemException)
391{
392    CF::DeviceManager::ServiceSequence_var result = new CF::DeviceManager::ServiceSequence(_registeredServices);
393    return result._retn();
394}
395
396
397void
398DeviceManager_impl::registerDevice (CF::Device_ptr registeringDevice)
399throw (CORBA::SystemException, CF::InvalidObjectReference)
400{
401    if (CORBA::is_nil (registeringDevice)) {
402        //writeLogRecord(FAILURE_ALARM,invalid reference input parameter.)
403        throw (CF::
404            InvalidObjectReference
405            ("[DeviceManager::registerDevice] Cannot register Device. registeringDevice is a nil reference."));
406    }
407
408    // Register the device with the Device manager, unless it is already
409    // registered
410    if (!deviceIsRegistered (registeringDevice)) {
411        _registeredDevices.length (_registeredDevices.length () + 1);
412        _registeredDevices[_registeredDevices.length () - 1] =
413            registeringDevice;
414    }
415
416    // If this Device Manager is registered with a Domain Manager, register
417    // the new device with the Domain Manager
418    if (_adminState == DEVMGR_REGISTERED) {
419        _dmnMgr->registerDevice (registeringDevice, myObj);
420    }
421
422//The registerDevice operation shall write a FAILURE_ALARM log record to a
423//DomainManagers Log, upon unsuccessful registration of a Device to the DeviceManagers
424//registeredDevices.
425}
426
427
428//This function returns TRUE if the input registeredDevice is contained in the _registeredDevices list attribute
429bool DeviceManager_impl::deviceIsRegistered (CF::Device_ptr registeredDevice)
430{
431//Look for registeredDevice in _registeredDevices
432    for (unsigned int i = 0; i < _registeredDevices.length (); i++)
433    {
434        if (strcmp (_registeredDevices[i]->label (), registeredDevice->label ())
435            == 0)
436        {
437            return true;
438        }
439    }
440    return false;
441}
442
443
444//This function returns TRUE if the input serviceName is contained in the _registeredServices list attribute
445bool DeviceManager_impl::serviceIsRegistered (const char *serviceName)
446{
447//Look for registeredDevice in _registeredDevices
448    for (unsigned int i = 0; i < _registeredServices.length (); i++)
449    {
450        if (strcmp (_registeredServices[i].serviceName, serviceName)  == 0)
451        {
452            return true;
453        }
454    }
455    return false;
456}
457
458
459void
460DeviceManager_impl::unregisterDevice (CF::Device_ptr registeredDevice)
461throw (CORBA::SystemException, CF::InvalidObjectReference)
462{
463    bool deviceFound = false;
464    if (CORBA::is_nil (registeredDevice))         //|| !deviceIsRegistered(registeredDevice) )
465    {
466//The unregisterDevice operation shall write a FAILURE_ALARM log record, when it cannot
467//successfully remove a registeredDevice from the DeviceManagers registeredDevices.
468
469//The unregisterDevice operation shall raise the CF InvalidObjectReference when the input
470//registeredDevice is a nil CORBA object reference or does not exist in the DeviceManagers
471//registeredDevices attribute.
472/*writeLogRecord(FAILURE_ALARM,invalid reference input parameter.); */
473        throw (CF::
474            InvalidObjectReference
475            ("Cannot unregister Device. registeringDevice is a nil reference."));
476
477        return;
478    }
479
480//The unregisterDevice operation shall remove the input registeredDevice from the
481//DeviceManagers registeredDevices attribute.
482
483//Look for registeredDevice in _registeredDevices
484    for (unsigned int i = 0; i < _registeredDevices.length (); i++)
485    {
486        if (strcmp (_registeredDevices[i]->label (), registeredDevice->label ())
487            == 0)
488        {
489//when the appropiater device is found, remove it from the _registeredDevices sequence
490            deviceFound = true;
491            if (_adminState == DEVMGR_REGISTERED)
492            {
493                _dmnMgr->unregisterDevice (CF::Device::_duplicate (registeredDevice));
494                CORBA::release (registeredDevice);
495            }
496            for (unsigned int j = i; j < _registeredDevices.length () - 1; j++)
497            {
498//The unregisterDevice operation shall unregister
499//the input registeredDevice from the DomainManager when the input registeredDevice is
500//registered with the DeviceManager and the DeviceManager is not shutting down.
501                _registeredDevices[j] = _registeredDevices[j + 1];
502            }
503//_registeredDevices[_registeredDevices.length() - 1] = 0;
504            _registeredDevices.length (_registeredDevices.length () - 1);
505//TO DO: Avoid memory leaks by reducing the length of the sequence _registeredDevices
506            break;
507        }
508    }
509    if (!deviceFound)
510    {
511/*writeLogRecord(FAILURE_ALARM,invalid reference input parameter.); */
512
513        throw (CF::
514            InvalidObjectReference
515            ("Cannot unregister Device. registeringDevice was not registered."));
516        return;
517    }
518
519}
520
521
522void
523DeviceManager_impl::shutdown ()
524throw (CORBA::SystemException)
525{
526    _adminState = DEVMGR_SHUTTING_DOWN;
527
528//The shutdown operation shall unregister the DeviceManager from the DomainManager.
529    _dmnMgr->unregisterDeviceManager (this->_this ()); ///\bug This looks wrong.
530
531//The shutdown operation shall perform releaseObject on all of the DeviceManagers registered
532//Devices (DeviceManagers registeredDevices attribute).
533
534    for (int i = _registeredDevices.length () - 1; i >= 0; i--)
535    {
536//Important Note: It is necessary to manage the lenght of the _registeredDevices sequence
537//otherwise, some elements in the sequence will be null.
538        _registeredDevices[i]->label ();          ////////////////////////////////////////////////test
539        CF::Device_var tempDev = CF::Device::_duplicate (_registeredDevices[i]);
540//_registeredDevices[i]->releaseObject();
541        unregisterDevice (_registeredDevices[i]);
542        tempDev->releaseObject ();
543    }
544
545}
546
547
548void
549DeviceManager_impl::registerService (CORBA::Object_ptr registeringService,
550const char *name)
551throw (CORBA::SystemException, CF::InvalidObjectReference)
552{
553//This release does not support services
554    if (CORBA::is_nil (registeringService))
555    {
556/*writeLogRecord(FAILURE_ALARM,invalid reference input parameter.); */
557
558        throw (CF::
559            InvalidObjectReference
560            ("Cannot register Device. registeringDevice is a nil reference."));
561        return;
562    }
563
564//The registerService operation shall add the input registeringService to the DeviceManagers
565//registeredServices attribute when the input registeringService does not already exist in the
566//registeredServices attribute. The registeringService is ignored when duplicated.
567    if (!serviceIsRegistered (name))
568    {
569        _registeredServices.length (_registeredServices.length () + 1);
570        _registeredServices[_registeredServices.length () - 1].serviceObject = registeringService;
571        _registeredServices[_registeredServices.length () - 1].serviceName = name;
572    }
573
574//The registerService operation shall register the registeringService with the DomainManager
575//when the DeviceManager has already registered to the DomainManager and the
576//registeringService has been successfully added to the DeviceManagers registeredServices
577//attribute.
578    if (_adminState == DEVMGR_REGISTERED)
579    {
580        _dmnMgr->registerService (registeringService, this->_this (), name);
581    }
582
583//The registerService operation shall write a FAILURE_ALARM log record, upon unsuccessful
584//registration of a Service to the DeviceManagers registeredServices.
585//The registerService operation shall raise the CF InvalidObjectReference exception when the
586//input registeringService is a nil CORBA object reference.
587
588}
589
590
591void
592DeviceManager_impl::unregisterService (CORBA::Object_ptr registeredService,
593const char *name)
594throw (CORBA::SystemException, CF::InvalidObjectReference)
595{
596    if (CORBA::is_nil (registeredService))
597    {
598/*writeLogRecord(FAILURE_ALARM,invalid reference input parameter.); */
599
600        throw (CF::
601            InvalidObjectReference
602            ("Cannot unregister Service. registeringService is a nil reference."));
603        return;
604    }
605
606//The unregisterService operation shall remove the input registeredService from the
607//DeviceManagers registeredServices attribute. The unregisterService operation shall unregister
608//the input registeredService from the DomainManager when the input registeredService is
609//registered with the DeviceManager and the DeviceManager is not in the shutting down state.
610
611//Look for registeredService in _registeredServices
612    for (unsigned int i = 0; i < _registeredServices.length (); i++)
613    {
614        if (strcmp (_registeredServices[i].serviceName, name) == 0)
615        {
616//when the appropiater device is found, remove it from the _registeredDevices sequence
617            if (_adminState == DEVMGR_REGISTERED)
618            {
619                _dmnMgr->unregisterService (registeredService, name);
620            }
621
622            for (unsigned int j = i; j < _registeredServices.length ()-1; j++)
623            {
624
625                CORBA::release (registeredService);
626                _registeredServices[j] = _registeredServices[j+1];
627            }
628            _registeredServices.length (_registeredServices.length () - 1);
629            return;
630        }
631    }
632
633//If it didn't find registeredDevice, then throw an exception
634/*writeLogRecord(FAILURE_ALARM,invalid reference input parameter.);*/
635    throw (CF::
636        InvalidObjectReference
637        ("Cannot unregister Service. registeringService was not registered."));
638//The unregisterService operation shall write a FAILURE_ALARM log record, when it cannot
639//successfully remove a registeredService from the DeviceManagers registeredServices.
640//The unregisterService operation shall raise the CF InvalidObjectReference when the input
641//registeredService is a nil CORBA object reference or does not exist in the DeviceManagers
642//registeredServices attribute.
643}
644
645
646char *
647DeviceManager_impl::
648getComponentImplementationId (const char *componentInstantiationId)
649throw (CORBA::SystemException)
650{
651//The getComponentImplementationId operation shall return the SPD implementation elements
652//ID attribute that matches the SPD implementation element used to create the component
653//identified by the input componentInstantiationId parameter.
654
655#if 0
656    DCDParser _DCDParser (_deviceConfigurationProfile);
657    std::vector < char *>*LocalComponentsVector =
658        _DCDParser.getLocalComponents ();
659#endif
660
661    std::cout << "If this appears look at DeviceManager_impl.cpp line 572" << std::endl;
662/*for (int i = 0; i<localComponentsVector->size();i++)
663   {
664   //get componentInstatiationId from each loal component
665   std::vector<ComponentInstantiation*> instantiations = LocalComponentsVector[i].getInstantiations();
666   //assuming only one instantiation
667   if( strcmp(componentInstantiationId, instantiations[0]->getID()) == 0)
668   {
669   SPDParser spdParser ( LocalComponentsVector[i].getSPDFile() );
670   std::vector<SPDImplementation*>  implementations = spdParser.getImplementations();
671   return implementations[0]->getID();
672   }
673} */
674    return "";
675
676//The getComponentImplementationId operation shall return an empty string when the input
677//componentInstantiationId parameter does not match the ID attribute of any SPD implementation
678//element used to create the component.
679}
680
Note: See TracBrowser for help on using the browser.