Documentation ¶
Index ¶
- Constants
- type APIKey
- type APIKeyManager
- func (m *APIKeyManager) CreateAPIKey() string
- func (m *APIKeyManager) DeleteAPIKey(apiKey string)
- func (m *APIKeyManager) GetAPIKey(apiKey string) *APIKey
- func (m *APIKeyManager) GetAPIKeys() []*APIKey
- func (m *APIKeyManager) IsValidAPIKey(apiKey string) bool
- func (m *APIKeyManager) ParseJSON(r io.Reader) error
- func (m *APIKeyManager) Read() error
- func (m *APIKeyManager) Write() error
- type APIKeyManagerV1
- type Map
- type MapFileData
- type MapFileDataV1
- type MapInfo
- type MapInfos
- type MapManager
- func (mm *MapManager) AddMap(mi MapInfo) (*ProxyMap, error)
- func (mm *MapManager) DeleteMap(mapID int) bool
- func (mm *MapManager) GetMaps() MapInfos
- func (mm *MapManager) GetProxyMap(mapID int) *ProxyMap
- func (mm *MapManager) ImportMap(path string) (*ProxyMap, error)
- func (m *MapManager) ParseJSON(r io.Reader) error
- func (m *MapManager) Read() error
- func (mm *MapManager) UpdateMap(mapID int, title string, base string, file string)
- func (m *MapManager) Write() error
- type MapManagerV1
- type ProxyMap
- func (p *ProxyMap) AddResource(r *Resource) ResourceID
- func (p *ProxyMap) DeleteResource(resourceID ResourceID)
- func (p *ProxyMap) GetResource(id ResourceID) *Resource
- func (p *ProxyMap) OpenResource(r *Resource)
- func (p *ProxyMap) ParseJSON(r io.Reader) error
- func (p *ProxyMap) Read() error
- func (p *ProxyMap) Write() error
- type Resource
- type ResourceID
- type ResourcePos
- type ResourcePosV1
- type ResourceType
- type ResourceV1
Constants ¶
const ( APIKeysFileName = "apikeys.json" APIKeysVersion = 1 )
const ( // MapManagerVersion defines current MapManager version. MapManagerVersion = 1 // MapsFileName defines JSON filename MapsFileName = "maps.json" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIKeyManager ¶
type APIKeyManager APIKeyManagerV1
APIKeyManager manages API keys. APIKeyManager works as singleton pattern.
func CreateAPIKeyManager ¶
func CreateAPIKeyManager() (*APIKeyManager, error)
CreateAPIKeyManager creates APIKeyManager singleton instance.
func GetAPIKeyManager ¶
func GetAPIKeyManager() *APIKeyManager
GetAPIKeyManager returns instance of APIKeyManager.
func (*APIKeyManager) CreateAPIKey ¶
func (m *APIKeyManager) CreateAPIKey() string
CreateAPIKey generates new API key.
func (*APIKeyManager) DeleteAPIKey ¶
func (m *APIKeyManager) DeleteAPIKey(apiKey string)
DeleteAPIKey deletes given API key.
func (*APIKeyManager) GetAPIKey ¶
func (m *APIKeyManager) GetAPIKey(apiKey string) *APIKey
GetAPIKey returns given API key or nil.
func (*APIKeyManager) GetAPIKeys ¶
func (m *APIKeyManager) GetAPIKeys() []*APIKey
GetAPIKeys returns array of APIKey pointers.
func (*APIKeyManager) IsValidAPIKey ¶
func (m *APIKeyManager) IsValidAPIKey(apiKey string) bool
IsValidAPIKey returns true if given API key is valid.
func (*APIKeyManager) ParseJSON ¶ added in v0.1.1
func (m *APIKeyManager) ParseJSON(r io.Reader) error
ParseJSON parses API keys from Reader.
func (*APIKeyManager) Read ¶ added in v0.1.1
func (m *APIKeyManager) Read() error
Read decodes JSON data from file.
func (*APIKeyManager) Write ¶ added in v0.1.1
func (m *APIKeyManager) Write() error
Write encodes Map.MapFileData to JSON file.
type APIKeyManagerV1 ¶ added in v0.1.1
type APIKeyManagerV1 struct { Version int `json:"version"` APIKeys map[string]*APIKey `json:"apikeys"` }
APIKeyManagerV1 is first version of APIKeyManager struct.
type MapFileDataV1 ¶
type MapFileDataV1 struct { Version int `json:"version"` // Title2 is a copy from MapInfo.Title // Title2 is stored to file so it is permanent and shareable Title2 string `json:"title2"` Resources []*Resource `json:"resources"` }
MapFileDataV1 is version 1 from MapFileData struct.
type MapInfo ¶ added in v0.1.2
type MapInfo struct { ID int `json:"id"` Title string `json:"title"` Base string `json:"base"` File string `json:"file"` Opened time.Time `json:"opened"` }
MapInfo is info struct for FileMap.
type MapInfos ¶ added in v0.1.2
type MapInfos []MapInfo
MapInfos is a collection of MapInfo pointers.
type MapManager ¶
type MapManager MapManagerV1
MapManager manages Maps, reads and stores them. MapManager works as singleton pattern.
func CreateMapManager ¶
func CreateMapManager() (*MapManager, error)
CreateMapManager creates MapManager singleton instance.
func (*MapManager) AddMap ¶
func (mm *MapManager) AddMap(mi MapInfo) (*ProxyMap, error)
AddMap adds new Map and assigns new ID for it.
func (*MapManager) DeleteMap ¶
func (mm *MapManager) DeleteMap(mapID int) bool
DeleteMap deletes Map with given ID.
func (*MapManager) GetProxyMap ¶ added in v0.2.7
func (mm *MapManager) GetProxyMap(mapID int) *ProxyMap
func (*MapManager) ImportMap ¶
func (mm *MapManager) ImportMap(path string) (*ProxyMap, error)
ImportMap imports new Map from filemap JSON file.
func (*MapManager) ParseJSON ¶ added in v0.1.2
func (m *MapManager) ParseJSON(r io.Reader) error
ParseJSON parses API keys from Reader.
func (*MapManager) Read ¶ added in v0.1.2
func (m *MapManager) Read() error
Read decodes JSON data from file.
func (*MapManager) UpdateMap ¶ added in v0.4.0
func (mm *MapManager) UpdateMap(mapID int, title string, base string, file string)
UpdateMap updates information that goes both to maps.json and map.filemap
func (*MapManager) Write ¶ added in v0.1.2
func (m *MapManager) Write() error
Write encodes Map.MapFileData to JSON file.
type MapManagerV1 ¶ added in v0.1.2
type MapManagerV1 struct { Version int `json:"version"` MapInfos MapInfos `json:"maps"` // contains filtered or unexported fields }
MapManagerV1 is first version of MapManager struct.
type ProxyMap ¶
ProxyMap is virtual proxy for Map struct
func (*ProxyMap) AddResource ¶
func (p *ProxyMap) AddResource(r *Resource) ResourceID
AddResource adds new resource to map and assigns ID for it. Returns new ID.
func (*ProxyMap) DeleteResource ¶
func (p *ProxyMap) DeleteResource(resourceID ResourceID)
DeleteResource deletes resource from map.
func (*ProxyMap) GetResource ¶ added in v0.2.0
func (p *ProxyMap) GetResource(id ResourceID) *Resource
GetResource returns Resource by ResourceID.
func (*ProxyMap) OpenResource ¶ added in v0.4.0
type ResourcePos ¶
type ResourcePos ResourcePosV1
ResourcePos defines resource position in 3D space. Alias to the latest ResourcePos version
type ResourcePosV1 ¶
ResourcePosV1 is the first version from ResourcePos struct
type ResourceType ¶
type ResourceType int
ResourceType defines type of Resource
const ( ResourceFile ResourceType = iota ResourceDir )
Resource type enum
type ResourceV1 ¶
type ResourceV1 struct { ResourceID ResourceID `json:"id"` Type ResourceType `json:"type"` Path string `json:"path"` Pos ResourcePos `json:"pos"` }
ResourceV1 is the first version from Resource struct