@@ -35,10 +35,12 @@ import (
3535
3636// maps of named clients and servers
3737var clientMap map [int ]* Client
38+
3839var serverMap map [int ]* Server
3940
4041// maps of named SAPs and ASEs
4142var serviceMap map [int ]* ServiceAccessPoint
43+
4244var elementMap map [int ]* ApplicationServiceElement
4345
4446func init () {
@@ -356,12 +358,12 @@ type ServiceAccessPointRequirements interface {
356358 SapRequest (Args , KWArgs ) error
357359 SapIndication (Args , KWArgs ) error
358360 SapResponse (Args , KWArgs ) error
359- _setServiceElement (serviceElement _ApplicationServiceElement )
361+ _setServiceElement (serviceElement ApplicationServiceElementContract )
360362}
361363
362364type ServiceAccessPoint struct {
363365 serviceID * int
364- serviceElement _ApplicationServiceElement
366+ serviceElement ApplicationServiceElementContract
365367
366368 log zerolog.Logger
367369}
@@ -419,6 +421,7 @@ func (s *ServiceAccessPoint) SapRequest(args Args, kwargs KWArgs) error {
419421}
420422
421423func (s * ServiceAccessPoint ) SapIndication (Args , KWArgs ) error {
424+ // TODO: we should remove this asap to check where we have actual caps because we can compile here
422425 panic ("this should be implemented by outer struct" )
423426}
424427
@@ -432,15 +435,20 @@ func (s *ServiceAccessPoint) SapResponse(args Args, kwargs KWArgs) error {
432435}
433436
434437func (s * ServiceAccessPoint ) SapConfirmation (Args , KWArgs ) error {
438+ // TODO: we should remove this asap to check where we have actual caps because we can compile here
435439 panic ("this should be implemented by outer struct" )
436440}
437441
438- func (s * ServiceAccessPoint ) _setServiceElement (serviceElement _ApplicationServiceElement ) {
442+ func (s * ServiceAccessPoint ) _setServiceElement (serviceElement ApplicationServiceElementContract ) {
439443 s .serviceElement = serviceElement
440444}
441445
442- // _ApplicationServiceElement is an interface used for documentation
443- type _ApplicationServiceElement interface {
446+ type ApplicationServiceElementRequirements interface {
447+ Confirmation (args Args , kwargs KWArgs ) error
448+ }
449+
450+ // ApplicationServiceElementContract is an interface used for documentation
451+ type ApplicationServiceElementContract interface {
444452 Request (args Args , kwargs KWArgs ) error
445453 Indication (args Args , kwargs KWArgs ) error
446454 Response (args Args , kwargs KWArgs ) error
@@ -455,7 +463,7 @@ type ApplicationServiceElement struct {
455463 log zerolog.Logger
456464}
457465
458- func NewApplicationServiceElement (localLog zerolog.Logger , rootStruct _ApplicationServiceElement , opts ... func (* ApplicationServiceElement )) (* ApplicationServiceElement , error ) {
466+ func NewApplicationServiceElement (localLog zerolog.Logger , requirements ApplicationServiceElementRequirements , opts ... func (* ApplicationServiceElement )) (* ApplicationServiceElement , error ) {
459467 a := & ApplicationServiceElement {
460468 log : localLog ,
461469 }
@@ -476,8 +484,8 @@ func NewApplicationServiceElement(localLog zerolog.Logger, rootStruct _Applicati
476484 return nil , errors .Errorf ("service access point %d already bound" , aseID )
477485 }
478486
479- // Note: we need to pass the rootStruct (which should contain a as delegate) here
480- if err := Bind (localLog , rootStruct , service ); err != nil {
487+ // Note: we need to pass the requirements (which should contain us as a delegate) here
488+ if err := Bind (localLog , requirements , service ); err != nil {
481489 return nil , errors .Wrap (err , "error binding" )
482490 }
483491 }
@@ -502,6 +510,7 @@ func (a *ApplicationServiceElement) Request(args Args, kwargs KWArgs) error {
502510}
503511
504512func (a * ApplicationServiceElement ) Indication (Args , KWArgs ) error {
513+ // TODO: we should remove this asap to check where we have actual caps because we can compile here
505514 panic ("this should be implemented by outer struct" )
506515}
507516
@@ -516,6 +525,7 @@ func (a *ApplicationServiceElement) Response(args Args, kwargs KWArgs) error {
516525}
517526
518527func (a * ApplicationServiceElement ) Confirmation (Args , KWArgs ) error {
528+ // TODO: we should remove this asap to check where we have actual caps because we can compile here
519529 panic ("this should be implemented by outer struct" )
520530}
521531
@@ -608,7 +618,7 @@ func Bind(localLog zerolog.Logger, args ...any) error {
608618 // make sure we're binding clients and servers
609619 clientCast , okClient := left .(_Client )
610620 serverCast , okServer := right .(_Server )
611- elementServiceCast , okElementService := left .(_ApplicationServiceElement )
621+ elementServiceCast , okElementService := left .(ApplicationServiceElementContract )
612622 serviceAccessPointCast , okServiceAccessPoint := right .(ServiceAccessPointRequirements )
613623 if okClient && okServer {
614624 localLog .Trace ().Msg ("linking client-server" )
0 commit comments