2015-10-01 10:10:40 -04:00
|
|
|
package core
|
|
|
|
|
|
|
|
type Capability byte
|
|
|
|
|
|
|
|
const (
|
|
|
|
TCPConnection = Capability(0x01)
|
|
|
|
UDPConnection = Capability(0x02)
|
|
|
|
)
|
|
|
|
|
|
|
|
type Capabilities interface {
|
|
|
|
HasCapability(cap Capability) bool
|
|
|
|
AddCapability(cap Capability)
|
|
|
|
}
|
|
|
|
|
|
|
|
type listCapabilities struct {
|
|
|
|
data []Capability
|
|
|
|
}
|
|
|
|
|
2015-10-01 10:14:05 -04:00
|
|
|
func NewCapabilities() Capabilities {
|
2015-10-01 10:10:40 -04:00
|
|
|
return &listCapabilities{
|
|
|
|
data: make([]Capability, 0, 16),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *listCapabilities) HasCapability(cap Capability) bool {
|
|
|
|
for _, v := range c.data {
|
|
|
|
if v == cap {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *listCapabilities) AddCapability(cap Capability) {
|
|
|
|
c.data = append(c.data, cap)
|
|
|
|
}
|