Skip to content

Commit a27828d

Browse files
Add BaseImpl (#912)
Signed-off-by: Michael Carlstrom <[email protected]>
1 parent 3198512 commit a27828d

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

rosidl_pycommon/rosidl_pycommon/interface_base_classes.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,24 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
from __future__ import annotations
16+
1517
# Base Classes
1618
from abc import ABC
1719
from abc import ABCMeta
1820
from abc import abstractmethod
1921
from typing import Any
2022
from typing import ClassVar
2123
from typing import Generic
24+
from typing import TYPE_CHECKING
2225
from typing import TypeVar
2326

2427

28+
if TYPE_CHECKING:
29+
from action_msgs.srv._cancel_goal import CancelGoal
30+
from action_msgs.msg._goal_status_array import GoalStatusArray
31+
32+
2533
class MessageTypeSupportMeta(ABCMeta):
2634

2735
_CREATE_ROS_MESSAGE: ClassVar[Any]
@@ -69,9 +77,24 @@ class BaseService(ABC, Generic[RequestT, ResponseT], metaclass=ServiceTypeSuppor
6977
Response: type[ResponseT]
7078

7179

80+
SendGoalServiceT = TypeVar('SendGoalServiceT')
81+
GetResultServiceT = TypeVar('GetResultServiceT')
82+
FeedbackMessageT = TypeVar('FeedbackMessageT')
83+
84+
85+
class BaseImpl(ABC, Generic[SendGoalServiceT, GetResultServiceT, FeedbackMessageT]):
86+
87+
SendGoalService: type[SendGoalServiceT]
88+
GetResultService: type[GetResultServiceT]
89+
FeedbackMessage: type[FeedbackMessageT]
90+
CancelGoalService: type[CancelGoal]
91+
GoalStatusMessage: type[GoalStatusArray]
92+
93+
7294
GoalT = TypeVar('GoalT')
7395
ResultT = TypeVar('ResultT')
7496
FeedbackT = TypeVar('FeedbackT')
97+
ImplT = TypeVar('ImplT', bound=BaseImpl[Any, Any, Any])
7598

7699

77100
class ActionTypeSupportMeta(ABCMeta):
@@ -83,8 +106,10 @@ class ActionTypeSupportMeta(ABCMeta):
83106
def __import_type_support__(cls) -> None: ...
84107

85108

86-
class BaseAction(ABC, Generic[GoalT, ResultT, FeedbackT], metaclass=ActionTypeSupportMeta):
109+
class BaseAction(ABC, Generic[GoalT, ResultT, FeedbackT, ImplT], metaclass=ActionTypeSupportMeta):
87110

88111
Goal: type[GoalT]
89112
Result: type[ResultT]
90113
Feedback: type[FeedbackT]
114+
115+
Impl: type[ImplT]

0 commit comments

Comments
 (0)