smalltalk
/
osmo-st-mgcp
Archived
1
0
Fork 0

callagent: Create a shared routine to verify the state transition

This commit is contained in:
Holger Hans Peter Freyther 2011-06-24 10:15:22 +02:00
parent ab1e189087
commit 03348c1e8d
1 changed files with 13 additions and 21 deletions

View File

@ -68,34 +68,30 @@ Object subclass: MGCPEndpoint [
^ state = self class stateUsed.
]
requireState: aState [
<category: 'allocation'>
state = aState ifFalse: [
^ self error: 'MGCPEndpoint(%1) not %2.'
% {self endpointName. aState} area: #mgcp.
].
]
reserve [
<category: 'allocation'>
state = self class stateUnused ifFalse: [
^ self error: 'MGCPEndpoint(%1) not unused.'
% {self endpointName} area: #mgcp.
].
self requireState: self class stateUnused.
state := self class stateReserved.
]
used [
<category: 'allocation'>
state = self class stateReserved ifFalse: [
^ self error: 'MGCPEndpoint(%1) not reserved.'
% {self endpointName} area: #mgcp.
].
self requireState: self class stateReserved.
state := self class stateUsed.
]
free [
<category: 'allocation'>
state = self class stateUsed ifFalse: [
^ self error: 'MGCPEndpoint(%1) not used.'
% {self endpointName} area: #mgcp.
].
state := self class stateUnused.
self requireState: self class stateUsed.
state := self class stateUsed.
]
tryBlock [
@ -110,11 +106,7 @@ Object subclass: MGCPEndpoint [
unblock [
<category: 'allocation'>
state = self class stateBlocked ifFalse: [
^ self error: 'MGCPEndpoint(%1) not blocked.'
% {self endpointName} area: #mgcp.
].
self requireState: self class stateBlocked.
state := self class stateUnused.
]