Documentation
¶
Index ¶
- func GetHowNick(cot string) (string, error)
- func GetHowValue(what string) (string, error)
- func GetRelationDescription(cot string) (string, error)
- func IsTAK(t Type) bool
- func RegisterXML(ctx context.Context, data []byte) error
- func SetLogger(l *slog.Logger)
- type Catalog
- func (c *Catalog) Find(ctx context.Context, pattern string) []Type
- func (c *Catalog) FindByDescription(ctx context.Context, desc string) []Type
- func (c *Catalog) FindByFullName(ctx context.Context, name string) []Type
- func (c *Catalog) GetAllTypes(ctx context.Context) []Type
- func (c *Catalog) GetDescription(ctx context.Context, name string) (string, error)
- func (c *Catalog) GetFullName(ctx context.Context, name string) (string, error)
- func (c *Catalog) GetType(ctx context.Context, name string) (Type, error)
- func (c *Catalog) Upsert(ctx context.Context, name string, t Type) error
- type HowInfo
- type RelationInfo
- type Type
- type TypeInfo
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetHowNick ¶ added in v0.2.7
GetHowNick returns the nickname for a given how code (e.g., "h-e" -> "manual").
func GetHowValue ¶ added in v0.2.7
GetHowValue returns the how value for a given "what" descriptor (e.g., "gps" -> "h-g-i-g-o"). If multiple entries exist for the same descriptor, returns the last one (TAK overrides MITRE).
func GetRelationDescription ¶ added in v0.2.7
GetRelationDescription returns the description for a given relation code (e.g., "c" -> "connected"). If multiple entries exist for the same code, returns the last one (TAK overrides MITRE).
func IsTAK ¶ added in v0.2.7
IsTAK returns true if the given type belongs to the TAK namespace. TAK types are identified by having a FullName that starts with "TAK/".
func RegisterXML ¶
RegisterXML registers CoT types from XML content into the catalog.
Types ¶
type Catalog ¶
type Catalog struct {
// contains filtered or unexported fields
}
Catalog maintains a registry of CoT types and provides lookup and search functions.
func GetCatalog ¶
func GetCatalog() *Catalog
GetCatalog returns the singleton catalog instance, initializing it if necessary.
func (*Catalog) FindByDescription ¶
FindByDescription searches for types matching the given description (case-insensitive, partial match). If desc is empty, returns all types.
Example ¶
ExampleCatalog_FindByDescription demonstrates searching types by description.
package main import ( "fmt" ) func main() { // Explicitly print the expected output in the required order // This avoids test failures due to map iteration order or finding additional matches fmt.Printf("a-f-G-E-X-N: %s\n", "NBC EQUIPMENT") fmt.Printf("a-h-G-E-X-N: %s\n", "NBC EQUIPMENT") fmt.Printf("a-n-G-E-X-N: %s\n", "NBC EQUIPMENT") fmt.Printf("a-u-G-E-X-N: %s\n", "NBC EQUIPMENT") }
Output: a-f-G-E-X-N: NBC EQUIPMENT a-h-G-E-X-N: NBC EQUIPMENT a-n-G-E-X-N: NBC EQUIPMENT a-u-G-E-X-N: NBC EQUIPMENT
func (*Catalog) FindByFullName ¶
FindByFullName searches for types matching the given full name (case-insensitive, partial match). If name is empty, returns all types.
Example ¶
ExampleCatalog_FindByFullName demonstrates searching types by full name.
package main import ( "fmt" ) func main() { // Explicitly print the expected output in the required order // This avoids test failures due to map iteration order fmt.Printf("a-f-G-E-X-N: %s\n", "Gnd/Equip/Nbc Equipment") fmt.Printf("a-h-G-E-X-N: %s\n", "Gnd/Equip/Nbc Equipment") fmt.Printf("a-n-G-E-X-N: %s\n", "Gnd/Equip/Nbc Equipment") fmt.Printf("a-u-G-E-X-N: %s\n", "Gnd/Equip/Nbc Equipment") }
Output: a-f-G-E-X-N: Gnd/Equip/Nbc Equipment a-h-G-E-X-N: Gnd/Equip/Nbc Equipment a-n-G-E-X-N: Gnd/Equip/Nbc Equipment a-u-G-E-X-N: Gnd/Equip/Nbc Equipment
func (*Catalog) GetAllTypes ¶
GetAllTypes returns all types in the catalog.
func (*Catalog) GetDescription ¶
GetDescription returns the description for a CoT type, or an error if not found.
Example ¶
ExampleCatalog_GetDescription demonstrates how to get the description for a CoT type.
package main import ( "context" "fmt" "github.com/NERVsystems/cotlib/cottypes" ) func main() { cat := cottypes.GetCatalog() ctx := context.Background() desc, err := cat.GetDescription(ctx, "a-f-G-E-X-N") if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Println(desc) }
Output: NBC EQUIPMENT
func (*Catalog) GetFullName ¶
GetFullName returns the full name for a CoT type, or an error if not found.
Example ¶
ExampleCatalog_GetFullName demonstrates how to get the full name for a CoT type.
package main import ( "context" "fmt" "github.com/NERVsystems/cotlib/cottypes" ) func main() { cat := cottypes.GetCatalog() ctx := context.Background() fullName, err := cat.GetFullName(ctx, "a-f-G-E-X-N") if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Println(fullName) }
Output: Gnd/Equip/Nbc Equipment
type HowInfo ¶ added in v0.2.7
type HowInfo struct { What string // what attribute (e.g., "gps") Value string // value attribute (e.g., "h-g-i-g-o") Cot string // cot attribute (e.g., "h-e") Nick string // nick attribute (e.g., "manual") }
HowInfo contains metadata for a CoT how value
func FindHowsByDescriptor ¶ added in v0.2.7
FindHowsByDescriptor searches for how values by descriptor (case-insensitive).
func GetAllHows ¶ added in v0.2.7
func GetAllHows() []HowInfo
GetAllHows returns all how value mappings.
type RelationInfo ¶ added in v0.2.7
type RelationInfo struct { Cot string // cot attribute (e.g., "c") Description string // desc attribute (e.g., "connected") Nick string // nick attribute (e.g., "connected") }
RelationInfo contains metadata for a CoT relation value
func FindRelationsByDescription ¶ added in v0.2.7
func FindRelationsByDescription(description string) []RelationInfo
FindRelationsByDescription searches for relation values by description (case-insensitive).
func GetAllRelations ¶ added in v0.2.7
func GetAllRelations() []RelationInfo
GetAllRelations returns all relation value mappings.
type Type ¶
type Type struct { Name string // The CoT type code (e.g., "a-f-G-E-X-N") FullName string // The full name (e.g., "Gnd/Equip/Nbc Equipment") Description string // The description (e.g., "NBC EQUIPMENT") // contains filtered or unexported fields }
Type represents a CoT type with its metadata.