1# -*- Mode: Python; -*- 2# Package : omniORBpy 3# ami.py Created on: 2012/06/27 4# Author : Duncan Grisby (dgrisby) 5# 6# Copyright (C) 2012 Apasphere Ltd. 7# 8# This file is part of the omniORBpy library 9# 10# The omniORBpy library is free software; you can redistribute it 11# and/or modify it under the terms of the GNU Lesser General 12# Public License as published by the Free Software Foundation; 13# either version 2.1 of the License, or (at your option) any later 14# version. 15# 16# This library is distributed in the hope that it will be useful, 17# but WITHOUT ANY WARRANTY; without even the implied warranty of 18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19# GNU Lesser General Public License for more details. 20# 21# You should have received a copy of the GNU Lesser General Public 22# License along with this library. If not, see http://www.gnu.org/licenses/ 23# 24# Description: 25# AMI support 26 27import omniORB 28Messaging = omniORB.openModule("Messaging") 29CORBA = omniORB.openModule("CORBA") 30 31try: 32 property 33except NameError: 34 def property(*args): 35 return None 36 37 38class PollerImpl (Messaging.Poller): 39 def __init__(self, poller): 40 self._poller = poller 41 42 def is_ready(self, timeout): 43 return self._poller.is_ready(timeout) 44 45 def create_pollable_set(self): 46 return PollableSetImpl(self._poller.create_pollable_set(self)) 47 48 def _get_operation_target(self): 49 return self._poller.operation_target() 50 51 operation_target = property(_get_operation_target) 52 53 def _get_operation_name(self): 54 return self._poller.operation_name() 55 56 operation_name = property(_get_operation_name) 57 58 def _get_associated_handler(self): 59 return self._poller.get_handler() 60 61 def _set_associated_handler(self, handler): 62 self._poller.set_handler(handler) 63 64 associated_handler = property(_get_associated_handler, 65 _set_associated_handler) 66 67 def _get_is_from_poller(self): 68 return self._poller.is_from_poller() 69 70 is_from_poller = property(_get_is_from_poller) 71 72 73class ExceptionHolderImpl (Messaging.ExceptionHolder): 74 def __init__(self, poller): 75 self._poller = poller 76 77 def raise_exception(self): 78 self._poller.raise_exception() 79 80 81class PollableSetImpl (CORBA.PollableSet): 82 def __init__(self, pset): 83 self._pset = pset 84 85 def create_dii_pollable(self): 86 raise CORBA.NO_IMPLEMENT(omniORB.NO_IMPLEMENT_Unsupported, 87 CORBA.COMPLETED_NO) 88 89 def add_pollable(self, potential): 90 if potential is not None: 91 self._pset.add_pollable(potential) 92 else: 93 raise CORBA.BAD_PARAM(omniORB.BAD_PARAM_InvalidPollerType, 94 CORBA.COMPLETED_NO) 95 96 def get_ready_pollable(self, timeout): 97 return self._pset.get_ready_pollable(timeout) 98 99 def remove(self, potential): 100 if potential is not None: 101 self._pset.remove(potential) 102 else: 103 raise CORBA.BAD_PARAM(omniORB.BAD_PARAM_InvalidPollerType, 104 CORBA.COMPLETED_NO) 105 106 def number_left(self): 107 return self._pset.number_left() 108