models

package
v0.0.0-...-35ffcd0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2024 License: MIT Imports: 23 Imported by: 10

Documentation

Overview

Default generated models package docs (at least one file is necessary in a models package)

generated code - do not edit

generated code - do not edit

generated code - do not edit

generated code - do not edit

generated code - do not edit

generated code - do not edit

generated code - do not edit

generated code - do not edit

generated code - do not edit

generated code - do not edit

Index

Constants

View Source
const IdentifiersDecls = `
	{{Identifier}} := (&models.{{GeneratedStructName}}{}).Stage(stage)`
View Source
const NumberInitStatement = `
	{{Identifier}}.{{GeneratedFieldName}} = {{GeneratedFieldNameValue}}`
View Source
const PointerFieldInitStatement = `
	{{Identifier}}.{{GeneratedFieldName}} = {{GeneratedFieldNameValue}}`
View Source
const RFC3339MillisFormat = "2006-01-02T15:04:05.000Z07:00"
View Source
const SliceOfPointersFieldInitStatement = `
	{{Identifier}}.{{GeneratedFieldName}} = append({{Identifier}}.{{GeneratedFieldName}}, {{GeneratedFieldNameValue}})`
View Source
const StringEnumInitStatement = `
	{{Identifier}}.{{GeneratedFieldName}} = {{GeneratedFieldNameValue}}`
View Source
const StringInitStatement = `
	{{Identifier}}.{{GeneratedFieldName}} = ` + "`" + `{{GeneratedFieldNameValue}}` + "`"
View Source
const TimeInitStatement = `` /* 129-byte string literal not displayed */

Variables

View Source
var CpuProfile bool
View Source
var DisplayWatch bool
View Source
var Quit chan bool

Functions

func AfterCreateFromFront

func AfterCreateFromFront[Type Gongstruct](stage *StageStruct, instance *Type)

AfterCreateFromFront is called after a create from front

func AfterDeleteFromFront

func AfterDeleteFromFront[Type Gongstruct](stage *StageStruct, staged, front *Type)

AfterDeleteFromFront is called after a delete from front

func AfterReadFromFront

func AfterReadFromFront[Type Gongstruct](stage *StageStruct, instance *Type)

AfterReadFromFront is called after a Read from front

func AfterUpdateFromFront

func AfterUpdateFromFront[Type Gongstruct](stage *StageStruct, old, new *Type)

AfterUpdateFromFront is called after a update from front

func CompareGongstructByName

func CompareGongstructByName[T PointerToGongstruct](a, b T) int

func CopyBranch

func CopyBranch[Type Gongstruct](from *Type) (to *Type)

CopyBranch stages instance and apply CopyBranch on all gongstruct instances that are referenced by pointers or slices of pointers of the instance

the algorithm stops along the course of graph if a vertex is already staged

func EvictInOtherSlices

func EvictInOtherSlices[OwningType PointerToGongstruct, FieldType PointerToGongstruct](
	stage *StageStruct,
	owningInstance OwningType,
	sliceField []FieldType,
	fieldName string)

EvictInOtherSlices allows for adherance between the gong association model and go.

Says you have a Astruct struct with a slice field "anarrayofb []*Bstruct"

go allows many Astruct instance to have the anarrayofb field that have the same pointers. go slices are MANY-MANY association.

With gong it is only ZERO-ONE-MANY associations, a Bstruct can be pointed only once by an Astruct instance through a given field. This follows the requirement that gong is suited for full stack programming and therefore the association is encoded as a reverse pointer (not as a joint table). In gong, a named struct is translated in a table and each table is a named struct.

EvictInOtherSlices removes the fields instances from other fields of other instance

Note : algo is in O(N)log(N) of nb of Astruct and Bstruct instances

func GetAssociationName

func GetAssociationName[Type Gongstruct]() *Type

GetAssociationName is a generic function that returns an instance of Type where each association is filled with an instance whose name is the name of the association

This function can be handy for generating navigation function that are refactorable

func GetFieldStringValue

func GetFieldStringValue[Type Gongstruct](instance Type, fieldName string) (res string)

func GetFieldStringValueFromPointer

func GetFieldStringValueFromPointer[Type PointerToGongstruct](instance Type, fieldName string) (res string)

func GetFields

func GetFields[Type Gongstruct]() (res []string)

GetFields return the array of the fields

func GetFieldsFromPointer

func GetFieldsFromPointer[Type PointerToGongstruct]() (res []string)

GetFieldsFromPointer return the array of the fields

func GetGongstrucsSorted

func GetGongstrucsSorted[T PointerToGongstruct](stage *StageStruct) (sortedSlice []T)

func GetGongstructInstancesMap

func GetGongstructInstancesMap[Type Gongstruct](stage *StageStruct) *map[string]*Type

GetGongstructInstancesMap returns the map of staged GongstructType instances it is usefull because it allows refactoring of gong struct identifier

func GetGongstructInstancesSet

func GetGongstructInstancesSet[Type Gongstruct](stage *StageStruct) *map[*Type]any

GetGongstructInstancesSet returns the set staged GongstructType instances it is usefull because it allows refactoring of gongstruct identifier

func GetGongstructInstancesSetFromPointerType

func GetGongstructInstancesSetFromPointerType[Type PointerToGongstruct](stage *StageStruct) *map[Type]any

GetGongstructInstancesSetFromPointerType returns the set staged GongstructType instances it is usefull because it allows refactoring of gongstruct identifier

func GetGongstructName

func GetGongstructName[Type Gongstruct]() (res string)

GetGongstructName returns the name of the Gongstruct this can be usefull if one want program robust to refactoring

func GetPointerReverseMap

func GetPointerReverseMap[Start, End Gongstruct](fieldname string, stage *StageStruct) map[*End][]*Start

GetPointerReverseMap allows backtrack navigation of any Start.Fieldname associations (0..1) that is a pointer from one staged Gongstruct (type Start) instances to another (type End)

The function provides a map with keys as instances of End and values to arrays of *Start the map is construed by iterating over all Start instances and populationg keys with End instances and values with slice of Start instances

func GetPointerToGongstructName

func GetPointerToGongstructName[Type PointerToGongstruct]() (res string)

GetPointerToGongstructName returns the name of the Gongstruct this can be usefull if one want program robust to refactoring

func GetSliceOfPointersReverseMap

func GetSliceOfPointersReverseMap[Start, End Gongstruct](fieldname string, stage *StageStruct) map[*End]*Start

GetSliceOfPointersReverseMap allows backtrack navigation of any Start.Fieldname associations (0..N) between one staged Gongstruct instances and many others

The function provides a map with keys as instances of End and values to *Start instances the map is construed by iterating over all Start instances and populating keys with End instances and values with the Start instances

func GongGetMap

func GongGetMap[Type GongstructMapString](stage *StageStruct) *Type

GongGetMap returns the map of staged GongstructType instances it is usefull because it allows refactoring of gong struct identifier

func GongGetSet

func GongGetSet[Type GongstructSet](stage *StageStruct) *Type

GongGetSet returns the set staged GongstructType instances it is usefull because it allows refactoring of gong struct identifier

func IntToLetters

func IntToLetters(number int32) (letters string)

func IsStaged

func IsStaged[Type Gongstruct](stage *StageStruct, instance *Type) (ok bool)

func Min

func Min(x, y time.Duration) time.Duration

Min returns the larger of x or y.

func ParseAstFile

func ParseAstFile(stage *StageStruct, pathToFile string) error

ParseAstFile Parse pathToFile and stages all instances declared in the file

func ParseAstFileFromAst

func ParseAstFileFromAst(stage *StageStruct, inFile *ast.File, fset *token.FileSet) error

ParseAstFile Parse pathToFile and stages all instances declared in the file

func ReplaceOldDeclarationsInFile

func ReplaceOldDeclarationsInFile(pathToFile string) error

ReplaceOldDeclarationsInFile replaces specific text in a file at the given path.

func Serialize

func Serialize[Type Gongstruct](stage *StageStruct, tab Tabulator)

func SerializeExcelize

func SerializeExcelize[Type Gongstruct](stage *StageStruct, f *excelize.File)

func SerializeStage

func SerializeStage(stage *StageStruct, filename string)

func SetCallbackAfterCreateFromFront

func SetCallbackAfterCreateFromFront[Type Gongstruct](stage *StageStruct, callback OnAfterCreateInterface[Type])

func SetCallbackAfterDeleteFromFront

func SetCallbackAfterDeleteFromFront[Type Gongstruct](stage *StageStruct, callback OnAfterDeleteInterface[Type])

func SetCallbackAfterReadFromFront

func SetCallbackAfterReadFromFront[Type Gongstruct](stage *StageStruct, callback OnAfterReadInterface[Type])

func SetCallbackAfterUpdateFromFront

func SetCallbackAfterUpdateFromFront[Type Gongstruct](stage *StageStruct, callback OnAfterUpdateInterface[Type])

SetCallbackAfterUpdateFromFront is a function to set up callback that is robust to refactoring

func SetOrchestratorOnAfterUpdate

func SetOrchestratorOnAfterUpdate[Type Gongstruct](stage *StageStruct)

func SortGongstructSetByName

func SortGongstructSetByName[T PointerToGongstruct](set map[T]any) (sortedSlice []T)

func StageBranch

func StageBranch[Type Gongstruct](stage *StageStruct, instance *Type)

StageBranch stages instance and apply StageBranch on all gongstruct instances that are referenced by pointers or slices of pointers of the instance

the algorithm stops along the course of graph if a vertex is already staged

func UnmarshallGongstructStaging

func UnmarshallGongstructStaging(stage *StageStruct, cmap *ast.CommentMap, assignStmt *ast.AssignStmt, astCoordinate_ string) (
	instance any,
	identifier string,
	gongstructName string,
	fieldName string)

UnmarshallGoStaging unmarshall a go assign statement

func UnstageBranch

func UnstageBranch[Type Gongstruct](stage *StageStruct, instance *Type)

UnstageBranch stages instance and apply UnstageBranch on all gongstruct instances that are referenced by pointers or slices of pointers of the insance

the algorithm stops along the course of graph if a vertex is already staged

Types

type Agent

type Agent struct {
	TechName string

	// usefull to append an agent to the Engine from an agent
	// swagger:ignore
	Engine *Engine
	// contains filtered or unexported fields
}

Agent is the empty struct to perform generic agents chores

func (*Agent) AppendAgentToEngine

func (agent *Agent) AppendAgentToEngine(newAgent AgentInterface)

AppendAgentToEngine append an agent to the engine

func (*Agent) Events

func (agent *Agent) Events() []EventInterface

Events append an agent to the engine

func (*Agent) GetNextEvent

func (agent *Agent) GetNextEvent() (EventInterface, time.Time)

GetNextEvent provides the next event from a time point of view by convention 0 means infinity

func (*Agent) GetNextEventAndRemoveIt

func (agent *Agent) GetNextEventAndRemoveIt() (event EventInterface, t time.Time)

GetNextEventAndRemoveIt provides the next event from a time point of view by convention 0 means infinity

func (*Agent) GetTechName

func (agent *Agent) GetTechName() string

Events append an agent to the engine

func (*Agent) QueueEvent

func (agent *Agent) QueueEvent(event EventInterface)

QueueEvent is the function by which an agent queues an event from another agent (or of himself)

func (*Agent) QueueUpdateEvent

func (agent *Agent) QueueUpdateEvent(engine *Engine, duration time.Duration) *Agent

QueueUpdateEvent put an UpdateState event with duration to the agent with fire time equals to EngineSingloton current time

return the agent

func (*Agent) RemoveAgentToEngine

func (agent *Agent) RemoveAgentToEngine(newAgent AgentInterface)

RemoveAgentToEngine append an agent to the engine

func (*Agent) Reset

func (agent *Agent) Reset()

Reset removes all events from the agent and resets internal checks

func (*Agent) SetEngine

func (agent *Agent) SetEngine(engine *Engine)

func (*Agent) TransfertAndQueueEvent

func (agent *Agent) TransfertAndQueueEvent(event EventInterface)

type AgentInterface

type AgentInterface interface {

	// GetNextEvent provides the event with earliest fire time
	GetNextEvent() (event EventInterface, time time.Time)

	// FireNextEvent fire next Event
	FireNextEvent()

	// Events fire next Event
	Events() []EventInterface

	SetEngine(engine *Engine)

	// Reset
	Reset()

	// get technical name
	GetTechName() string

	QueueEvent(event EventInterface)
	TransfertAndQueueEvent(event EventInterface)
}

AgentInterface is the interface that must be followed by part of the simulation swagger:model AgentInterface

func AppendToSingloton

func AppendToSingloton(engine *Engine, agent AgentInterface) AgentInterface

Implements the interface function

type AllModelsStructCreateInterface

type AllModelsStructCreateInterface interface {
	CreateORMCommand(Command *Command)
	CreateORMDummyAgent(DummyAgent *DummyAgent)
	CreateORMEngine(Engine *Engine)
	CreateORMEvent(Event *Event)
	CreateORMStatus(Status *Status)
	CreateORMUpdateState(UpdateState *UpdateState)
}

swagger:ignore

type AllModelsStructDeleteInterface

type AllModelsStructDeleteInterface interface {
	DeleteORMCommand(Command *Command)
	DeleteORMDummyAgent(DummyAgent *DummyAgent)
	DeleteORMEngine(Engine *Engine)
	DeleteORMEvent(Event *Event)
	DeleteORMStatus(Status *Status)
	DeleteORMUpdateState(UpdateState *UpdateState)
}

type BackRepoInterface

type BackRepoInterface interface {
	Commit(stage *StageStruct)
	Checkout(stage *StageStruct)
	Backup(stage *StageStruct, dirPath string)
	Restore(stage *StageStruct, dirPath string)
	BackupXL(stage *StageStruct, dirPath string)
	RestoreXL(stage *StageStruct, dirPath string)
	// insertion point for Commit and Checkout signatures
	CommitCommand(command *Command)
	CheckoutCommand(command *Command)
	CommitDummyAgent(dummyagent *DummyAgent)
	CheckoutDummyAgent(dummyagent *DummyAgent)
	CommitEngine(engine *Engine)
	CheckoutEngine(engine *Engine)
	CommitEvent(event *Event)
	CheckoutEvent(event *Event)
	CommitStatus(status *Status)
	CheckoutStatus(status *Status)
	CommitUpdateState(updatestate *UpdateState)
	CheckoutUpdateState(updatestate *UpdateState)
	GetLastCommitFromBackNb() uint
	GetLastPushFromFrontNb() uint
}

type Command

type Command struct {
	Name        string
	Command     CommandType
	CommandDate string
	Engine      *Engine
	// contains filtered or unexported fields
}

Command is the struct of the instance that is updated by the front for issuing commands swagger:model Command

func CopyBranchCommand

func CopyBranchCommand(mapOrigCopy map[any]any, commandFrom *Command) (commandTo *Command)

insertion point for stage branch per struct

func NewCommand

func NewCommand(stage *StageStruct, engine *Engine) (command *Command)

func (*Command) Checkout

func (command *Command) Checkout(stage *StageStruct) *Command

Checkout command to the back repo (if it is already staged)

func (*Command) Commit

func (command *Command) Commit(stage *StageStruct) *Command

commit command to the back repo (if it is already staged)

func (*Command) CommitVoid

func (command *Command) CommitVoid(stage *StageStruct)

func (*Command) CopyBasicFields

func (from *Command) CopyBasicFields(to *Command)

func (*Command) GetName

func (command *Command) GetName() (res string)

for satisfaction of GongStruct interface

func (*Command) OnAfterUpdate

func (command *Command) OnAfterUpdate(stage *StageStruct, stagedCommand, frontCommand *Command)

func (*Command) SetupGongsimThreads

func (command *Command) SetupGongsimThreads() *Command

SetupGongsimThreads schedules gongsim threads

func (*Command) Stage

func (command *Command) Stage(stage *StageStruct) *Command

insertion point for cumulative sub template with model space calls Stage puts command to the model stage

func (*Command) Unstage

func (command *Command) Unstage(stage *StageStruct) *Command

Unstage removes command off the model stage

func (*Command) UnstageVoid

func (command *Command) UnstageVoid(stage *StageStruct)

UnstageVoid removes command off the model stage

type CommandOrchestrator

type CommandOrchestrator struct {
}

insertion point CommandOrchestrator

func (*CommandOrchestrator) OnAfterUpdate

func (orchestrator *CommandOrchestrator) OnAfterUpdate(
	gongsvgStage *StageStruct,
	stagedCommand, backRepoCommand *Command)

type CommandType

type CommandType string

swagger:enum CommandType

const (
	COMMAND_PLAY                          CommandType = "PLAY"
	COMMAND_PAUSE                         CommandType = "PAUSE"
	COMMAND_FIRE_NEXT_EVENT               CommandType = "FIRE_NEXT_EVENT"
	COMMAND_FIRE_EVENT_TILL_STATES_CHANGE CommandType = "FIRE_EVENT_TILL_STATES_CHANGE"
	COMMAND_RESET                         CommandType = "RESET"
	COMMAND_ADVANCE_10_MIN                CommandType = "ADVANCE_10_MIN"
	INCREASE_SPEED_100_PERCENTS           CommandType = "INCREASE_SPEED_100_PERCENTS"
	DECREASE_SPEED_50_PERCENTS            CommandType = "DECREASE_SPEED_50_PERCENTS"
)

values for EnumType

func (CommandType) CodeValues

func (commandtype CommandType) CodeValues() (res []string)

func (CommandType) Codes

func (commandtype CommandType) Codes() (res []string)

func (*CommandType) FromCodeString

func (commandtype *CommandType) FromCodeString(input string) (err error)

func (*CommandType) FromString

func (commandtype *CommandType) FromString(input string) (err error)

func (*CommandType) ToCodeString

func (commandtype *CommandType) ToCodeString() (res string)

func (CommandType) ToString

func (commandtype CommandType) ToString() (res string)

insertion point of enum utility functions Utility function for CommandType if enum values are string, it is stored with the value if enum values are int, they are stored with the code of the value

type Command_WOP

type Command_WOP struct {
	// insertion point
	Name        string
	Command     CommandType
	CommandDate string
}

insertion point

type ControlMode

type ControlMode string

swagger:enum ControlMode

const (
	AUTONOMOUS     ControlMode = "Autonomous" // iota
	CLIENT_CONTROL ControlMode = "ClientControl"
)

values for ControlMode

func (ControlMode) CodeValues

func (controlmode ControlMode) CodeValues() (res []string)

func (ControlMode) Codes

func (controlmode ControlMode) Codes() (res []string)

func (*ControlMode) FromCodeString

func (controlmode *ControlMode) FromCodeString(input string) (err error)

func (*ControlMode) FromString

func (controlmode *ControlMode) FromString(input string) (err error)

func (*ControlMode) ToCodeString

func (controlmode *ControlMode) ToCodeString() (res string)

func (ControlMode) ToString

func (controlmode ControlMode) ToString() (res string)

Utility function for ControlMode if enum values are string, it is stored with the value if enum values are int, they are stored with the code of the value

type DummyAgent

type DummyAgent struct {
	Agent

	Name string
}

func CopyBranchDummyAgent

func CopyBranchDummyAgent(mapOrigCopy map[any]any, dummyagentFrom *DummyAgent) (dummyagentTo *DummyAgent)

func (*DummyAgent) Checkout

func (dummyagent *DummyAgent) Checkout(stage *StageStruct) *DummyAgent

Checkout dummyagent to the back repo (if it is already staged)

func (*DummyAgent) Commit

func (dummyagent *DummyAgent) Commit(stage *StageStruct) *DummyAgent

commit dummyagent to the back repo (if it is already staged)

func (*DummyAgent) CommitVoid

func (dummyagent *DummyAgent) CommitVoid(stage *StageStruct)

func (*DummyAgent) CopyBasicFields

func (from *DummyAgent) CopyBasicFields(to *DummyAgent)

func (*DummyAgent) FireNextEvent

func (dummyAgent *DummyAgent) FireNextEvent()

func (*DummyAgent) GetName

func (dummyagent *DummyAgent) GetName() (res string)

for satisfaction of GongStruct interface

func (*DummyAgent) Stage

func (dummyagent *DummyAgent) Stage(stage *StageStruct) *DummyAgent

Stage puts dummyagent to the model stage

func (*DummyAgent) Unstage

func (dummyagent *DummyAgent) Unstage(stage *StageStruct) *DummyAgent

Unstage removes dummyagent off the model stage

func (*DummyAgent) UnstageVoid

func (dummyagent *DummyAgent) UnstageVoid(stage *StageStruct)

UnstageVoid removes dummyagent off the model stage

type DummyAgent_WOP

type DummyAgent_WOP struct {
	// insertion point
	TechName string
	Name     string
}

type Engine

type Engine struct {
	// Name of the engine "laundramat" for instance
	Name string

	EndTime string

	CurrentTime string

	DisplayFormat string

	// number of the seconds elapsed since the beginning of the simulation
	SecondsSinceStart float64

	// Fired events
	Fired int

	// control mode.
	ControlMode ControlMode

	// engine state
	State EngineState

	// LastEvent ...
	LastEvent *EventInterface `gorm:"-"`

	// LastEvent agent
	LastEventAgent *AgentInterface `gorm:"-"`

	// Simulation supportspecific callback
	// on the engine events
	Simulation SimulationInterface `gorm:"-"`

	// Speed compared to realtime
	Speed float64
	// contains filtered or unexported fields
}

Engine describes a tiny discrete event simulation engine it is responsible for advancing the time An engine manages a set of agents swagger:model Engine

func CopyBranchEngine

func CopyBranchEngine(mapOrigCopy map[any]any, engineFrom *Engine) (engineTo *Engine)

func (*Engine) Agents

func (engine *Engine) Agents() (agents []AgentInterface)

func (*Engine) AppendAgent

func (engine *Engine) AppendAgent(agent AgentInterface)

AppendAgent to the engine

func (*Engine) Checkout

func (engine *Engine) Checkout(stage *StageStruct) *Engine

Checkout engine to the back repo (if it is already staged)

func (*Engine) Commit

func (engine *Engine) Commit(stage *StageStruct) *Engine

commit engine to the back repo (if it is already staged)

func (*Engine) CommitVoid

func (engine *Engine) CommitVoid(stage *StageStruct)

func (*Engine) CopyBasicFields

func (from *Engine) CopyBasicFields(to *Engine)

func (*Engine) FireNextEvent

func (engine *Engine) FireNextEvent() (agent AgentInterface, nextTimeEvent time.Time, event EventInterface)

FireNextEvent fires earliest event advances current time

func (*Engine) GetCurrentTime

func (engine *Engine) GetCurrentTime() time.Time

func (*Engine) GetEndTime

func (engine *Engine) GetEndTime() time.Time

func (*Engine) GetLastCommitNb

func (engine *Engine) GetLastCommitNb() (commitNb uint)

func (*Engine) GetLastCommitNbFromFront

func (engine *Engine) GetLastCommitNbFromFront() (commitNb uint)

func (*Engine) GetName

func (engine *Engine) GetName() (res string)

for satisfaction of GongStruct interface

func (*Engine) GetNextEvent

func (engine *Engine) GetNextEvent() (agent AgentInterface, nextEventFireTime time.Time, event EventInterface)

GetNextEvent ...

func (*Engine) GetStartTime

func (engine *Engine) GetStartTime() time.Time

func (*Engine) ListEvents

func (engine *Engine) ListEvents()

ListEvents

func (*Engine) RemoveAgent

func (engine *Engine) RemoveAgent(agent AgentInterface)

RemoveAgent to the engine

func (*Engine) Run

func (engine *Engine) Run()

Run will advance time till currentTime > EndTime

func (*Engine) RunTillAnyStateHasChanged

func (engine *Engine) RunTillAnyStateHasChanged()

RunTillAnyStateHasChanged will advance time till currentTime > EndTime or one state Changed in the implementation

func (*Engine) SetCurrentTime

func (engine *Engine) SetCurrentTime(time time.Time)

func (*Engine) SetEndTime

func (engine *Engine) SetEndTime(time time.Time)

func (*Engine) SetStartTime

func (engine *Engine) SetStartTime(time time.Time)

func (*Engine) Stage

func (engine *Engine) Stage(stage *StageStruct) *Engine

Stage puts engine to the model stage

func (*Engine) Unstage

func (engine *Engine) Unstage(stage *StageStruct) *Engine

Unstage removes engine off the model stage

func (*Engine) UnstageVoid

func (engine *Engine) UnstageVoid(stage *StageStruct)

UnstageVoid removes engine off the model stage

type EngineDriverState

type EngineDriverState int

the states of the engine drivers

const (
	COMMIT_AGENT_STATES EngineDriverState = iota
	CHECKOUT_AGENT_STATES
	FIRE_ONE_EVENT
	SLEEP_100_MS
	RESET_SIMULATION
	UNKOWN
)

func (EngineDriverState) CodeValues

func (enginedriverstate EngineDriverState) CodeValues() (res []int)

func (EngineDriverState) Codes

func (enginedriverstate EngineDriverState) Codes() (res []string)

func (*EngineDriverState) FromCodeString

func (enginedriverstate *EngineDriverState) FromCodeString(input string) (err error)

func (*EngineDriverState) FromInt

func (enginedriverstate *EngineDriverState) FromInt(input int) (err error)

func (*EngineDriverState) ToCodeString

func (enginedriverstate *EngineDriverState) ToCodeString() (res string)

func (EngineDriverState) ToInt

func (enginedriverstate EngineDriverState) ToInt() (res int)

Utility function for EngineDriverState if enum values are string, it is stored with the value if enum values are int, they are stored with the code of the value

type EngineRunMode

type EngineRunMode int

the simulation can run with a relative speed to realtime or full speed

const (
	RELATIVE_SPEED EngineRunMode = iota
	FULL_SPEED
)

func (EngineRunMode) CodeValues

func (enginerunmode EngineRunMode) CodeValues() (res []int)

func (EngineRunMode) Codes

func (enginerunmode EngineRunMode) Codes() (res []string)

func (*EngineRunMode) FromCodeString

func (enginerunmode *EngineRunMode) FromCodeString(input string) (err error)

func (*EngineRunMode) FromInt

func (enginerunmode *EngineRunMode) FromInt(input int) (err error)

func (*EngineRunMode) ToCodeString

func (enginerunmode *EngineRunMode) ToCodeString() (res string)

func (EngineRunMode) ToInt

func (enginerunmode EngineRunMode) ToInt() (res int)

Utility function for EngineRunMode if enum values are string, it is stored with the value if enum values are int, they are stored with the code of the value

type EngineState

type EngineState string

swagger:enum EngineState

const (
	RUNNING EngineState = "RUNNING" // iota
	PAUSED  EngineState = "PAUSED"
	OVER    EngineState = "OVER"
)

values for EngineState

func (EngineState) CodeValues

func (enginestate EngineState) CodeValues() (res []string)

func (EngineState) Codes

func (enginestate EngineState) Codes() (res []string)

func (*EngineState) FromCodeString

func (enginestate *EngineState) FromCodeString(input string) (err error)

func (*EngineState) FromString

func (enginestate *EngineState) FromString(input string) (err error)

func (*EngineState) ToCodeString

func (enginestate *EngineState) ToCodeString() (res string)

func (EngineState) ToString

func (enginestate EngineState) ToString() (res string)

Utility function for EngineState if enum values are string, it is stored with the value if enum values are int, they are stored with the code of the value

type EngineStopMode

type EngineStopMode int
const (
	TEN_MINUTES EngineStopMode = iota
	STATE_CHANGED
)

func (EngineStopMode) CodeValues

func (enginestopmode EngineStopMode) CodeValues() (res []int)

func (EngineStopMode) Codes

func (enginestopmode EngineStopMode) Codes() (res []string)

func (*EngineStopMode) FromCodeString

func (enginestopmode *EngineStopMode) FromCodeString(input string) (err error)

func (*EngineStopMode) FromInt

func (enginestopmode *EngineStopMode) FromInt(input int) (err error)

func (*EngineStopMode) ToCodeString

func (enginestopmode *EngineStopMode) ToCodeString() (res string)

func (EngineStopMode) ToInt

func (enginestopmode EngineStopMode) ToInt() (res int)

Utility function for EngineStopMode if enum values are string, it is stored with the value if enum values are int, they are stored with the code of the value

type Engine_WOP

type Engine_WOP struct {
	// insertion point
	Name              string
	EndTime           string
	CurrentTime       string
	DisplayFormat     string
	SecondsSinceStart float64
	Fired             int
	ControlMode       ControlMode
	State             EngineState
	Speed             float64
}

type Event

type Event struct {
	Name string

	// Duration is the difference between the current time and the fire time of the
	// event. It is handy to compute directly the fire time
	Duration time.Duration
	// contains filtered or unexported fields
}

Event is the elementary element of a discrete event simulation swagger:model Event

func CopyBranchEvent

func CopyBranchEvent(mapOrigCopy map[any]any, eventFrom *Event) (eventTo *Event)

func (*Event) Checkout

func (event *Event) Checkout(stage *StageStruct) *Event

Checkout event to the back repo (if it is already staged)

func (*Event) Commit

func (event *Event) Commit(stage *StageStruct) *Event

commit event to the back repo (if it is already staged)

func (*Event) CommitVoid

func (event *Event) CommitVoid(stage *StageStruct)

func (*Event) CopyBasicFields

func (from *Event) CopyBasicFields(to *Event)

func (*Event) GetAgent

func (event *Event) GetAgent() *Agent

func (*Event) GetDuration

func (event *Event) GetDuration() time.Duration

GetDuration ...

func (*Event) GetFireTime

func (event *Event) GetFireTime() time.Time

GetFireTime ...

func (*Event) GetName

func (event *Event) GetName() (res string)

for satisfaction of GongStruct interface

func (*Event) SetAgent

func (event *Event) SetAgent(agent *Agent)

func (*Event) SetFireTime

func (event *Event) SetFireTime(t time.Time)

func (*Event) Stage

func (event *Event) Stage(stage *StageStruct) *Event

Stage puts event to the model stage

func (*Event) Unstage

func (event *Event) Unstage(stage *StageStruct) *Event

Unstage removes event off the model stage

func (*Event) UnstageVoid

func (event *Event) UnstageVoid(stage *StageStruct)

UnstageVoid removes event off the model stage

type EventInterface

type EventInterface interface {
	GetFireTime() time.Time
	SetFireTime(time.Time)
	GetDuration() time.Duration
	GetName() string
	SetAgent(agent *Agent)
	GetAgent() *Agent
}

EventInterface ... swagger:ignore

type Event_WOP

type Event_WOP struct {
	// insertion point
	Name     string
	Duration time.Duration
}

type ExcelizeTabulator

type ExcelizeTabulator struct {
	// contains filtered or unexported fields
}

func (*ExcelizeTabulator) AddCell

func (tab *ExcelizeTabulator) AddCell(sheetName string, rowId, columnIndex int, value string)

func (*ExcelizeTabulator) AddRow

func (tab *ExcelizeTabulator) AddRow(sheetName string) (rowId int)

func (*ExcelizeTabulator) AddSheet

func (tab *ExcelizeTabulator) AddSheet(sheetName string)

func (*ExcelizeTabulator) SetExcelizeFile

func (tab *ExcelizeTabulator) SetExcelizeFile(f *excelize.File)

type GONG__ExpressionType

type GONG__ExpressionType string

swagger:ignore

const (
	GONG__STRUCT_INSTANCE      GONG__ExpressionType = "STRUCT_INSTANCE"
	GONG__FIELD_OR_CONST_VALUE GONG__ExpressionType = "FIELD_OR_CONST_VALUE"
	GONG__FIELD_VALUE          GONG__ExpressionType = "FIELD_VALUE"
	GONG__ENUM_CAST_INT        GONG__ExpressionType = "ENUM_CAST_INT"
	GONG__ENUM_CAST_STRING     GONG__ExpressionType = "ENUM_CAST_STRING"
	GONG__IDENTIFIER_CONST     GONG__ExpressionType = "IDENTIFIER_CONST"
)

type GONG__Identifier

type GONG__Identifier struct {
	Ident string
	Type  GONG__ExpressionType
}

type GongStructInterface

type GongStructInterface interface {
	GetName() (res string)
}

GongStructInterface is the interface met by GongStructs It allows runtime reflexion of instances (without the hassle of the "reflect" package)

type Gongstruct

type Gongstruct interface {
}

Gongstruct is the type parameter for generated generic function that allows - access to staged instances - navigation between staged instances by going backward association links between gongstruct - full refactoring of Gongstruct identifiers / fields

type GongstructEnumIntField

type GongstructEnumIntField interface {
	int | EngineDriverState | EngineRunMode | EngineStopMode
	Codes() []string
	CodeValues() []int
}

type GongstructEnumStringField

type GongstructEnumStringField interface {
	Codes() []string
	CodeValues() []string
	ToString() string
}

type GongstructMapString

type GongstructMapString interface {
	map[any]any
}

type GongstructSet

type GongstructSet interface {
	map[any]any
}

type GongtructBasicField

type GongtructBasicField interface {
	int | float64 | bool | string | time.Time | time.Duration
}

type OnAfterCreateInterface

type OnAfterCreateInterface[Type Gongstruct] interface {
	OnAfterCreate(stage *StageStruct,
		instance *Type)
}

OnAfterCreateInterface callback when an instance is updated from the front

type OnAfterDeleteInterface

type OnAfterDeleteInterface[Type Gongstruct] interface {
	OnAfterDelete(stage *StageStruct,
		staged, front *Type)
}

OnAfterDeleteInterface callback when an instance is updated from the front

type OnAfterReadInterface

type OnAfterReadInterface[Type Gongstruct] interface {
	OnAfterRead(stage *StageStruct,
		instance *Type)
}

OnAfterReadInterface callback when an instance is updated from the front

type OnAfterUpdateInterface

type OnAfterUpdateInterface[Type Gongstruct] interface {
	OnAfterUpdate(stage *StageStruct, old, new *Type)
}

OnAfterUpdateInterface callback when an instance is updated from the front

type OnInitCommitInterface

type OnInitCommitInterface interface {
	BeforeCommit(stage *StageStruct)
}

type PointerToGongstruct

type PointerToGongstruct interface {
	GetName() string
	CommitVoid(*StageStruct)
	UnstageVoid(stage *StageStruct)
	comparable
}

Gongstruct is the type parameter for generated generic function that allows - access to staged instances - navigation between staged instances by going backward association links between gongstruct - full refactoring of Gongstruct identifiers / fields

type PointerToGongstructEnumIntField

type PointerToGongstructEnumIntField interface {
	*EngineDriverState | *EngineRunMode | *EngineStopMode
	FromCodeString(input string) (err error)
}

type PointerToGongstructEnumStringField

type PointerToGongstructEnumStringField interface {
	FromCodeString(input string) (err error)
}

type ReverseField

type ReverseField struct {
	GongstructName string
	Fieldname      string
}

func GetReverseFields

func GetReverseFields[Type Gongstruct]() (res []ReverseField)

type Simulation

type Simulation struct {
	DB *gorm.DB
}

the simplest possible simulation

func (*Simulation) CheckoutAgents

func (specificEngine *Simulation) CheckoutAgents(engine *Engine)

func (*Simulation) CommitAgents

func (specificEngine *Simulation) CommitAgents(engine *Engine)

func (*Simulation) EventFired

func (specificEngine *Simulation) EventFired(engine *Engine)

func (*Simulation) GetLastCommitNb

func (specificEngine *Simulation) GetLastCommitNb() uint

func (*Simulation) GetLastCommitNbFromFront

func (specificEngine *Simulation) GetLastCommitNbFromFront() uint

func (*Simulation) HasAnyStateChanged

func (specificEngine *Simulation) HasAnyStateChanged(engine *Engine) bool

func (*Simulation) Reset

func (specificEngine *Simulation) Reset(engine *Engine)

type SimulationInterface

type SimulationInterface interface {

	// HasAnyStateChanged provides the generic engine infos about the behavior
	// of simulation
	//
	// It is used in order to have the "advance till one state changes" call
	//
	// the simulation shall implement this callback
	// it returns true if one state of the specific has changed
	HasAnyStateChanged(engine *Engine) bool

	// CommitAgents requests the simulation to commit the instances values to the back repo
	//
	// This is used when the simulation states has to be read by an outside component (the front component for instance)
	CommitAgents(engines *Engine)

	// CheckoutAgents requests the simulation to checkout the instances values from the back repo
	//
	// This is used when the simulation states has to be updated by values set by an outside component (the front component for instance)
	CheckoutAgents(engine *Engine)

	// GetLastCommitNb fetch the last commit nb from the simulation
	// this enables the engine to compute when it is necessary to update the stage following
	// updates to the back repo from the front
	GetLastCommitNb() uint

	// GetLastCommitNbFromFront fetch the last commit nb from the front to the simulation
	GetLastCommitNbFromFront() uint

	// Reset simulation
	Reset(engine *Engine)
}

SimulationInterface is the callback support for events that happens on the generic engine

type SpeedCommandType

type SpeedCommandType string

swagger:enum GongsimCommandType

const (
	COMMAND_INCREASE_SPEED_100_PERCENTS SpeedCommandType = "INCREASE_SPEED_100_PERCENTS"
	COMMAND_DECREASE_SPEED_50_PERCENTS  SpeedCommandType = "COMMAND_DECREASE_SPEED_50_PERCENTS "
	COMMAND_SPEED_STEADY                SpeedCommandType = "COMMAND_SPEED_STEADY"
)

func (SpeedCommandType) CodeValues

func (speedcommandtype SpeedCommandType) CodeValues() (res []string)

func (SpeedCommandType) Codes

func (speedcommandtype SpeedCommandType) Codes() (res []string)

func (*SpeedCommandType) FromCodeString

func (speedcommandtype *SpeedCommandType) FromCodeString(input string) (err error)

func (*SpeedCommandType) FromString

func (speedcommandtype *SpeedCommandType) FromString(input string) (err error)

func (*SpeedCommandType) ToCodeString

func (speedcommandtype *SpeedCommandType) ToCodeString() (res string)

func (SpeedCommandType) ToString

func (speedcommandtype SpeedCommandType) ToString() (res string)

Utility function for SpeedCommandType if enum values are string, it is stored with the value if enum values are int, they are stored with the code of the value

type StageStruct

type StageStruct struct {

	// insertion point for definition of arrays registering instances
	Commands           map[*Command]any
	Commands_mapString map[string]*Command

	// insertion point for slice of pointers maps
	OnAfterCommandCreateCallback OnAfterCreateInterface[Command]
	OnAfterCommandUpdateCallback OnAfterUpdateInterface[Command]
	OnAfterCommandDeleteCallback OnAfterDeleteInterface[Command]
	OnAfterCommandReadCallback   OnAfterReadInterface[Command]

	DummyAgents           map[*DummyAgent]any
	DummyAgents_mapString map[string]*DummyAgent

	// insertion point for slice of pointers maps
	OnAfterDummyAgentCreateCallback OnAfterCreateInterface[DummyAgent]
	OnAfterDummyAgentUpdateCallback OnAfterUpdateInterface[DummyAgent]
	OnAfterDummyAgentDeleteCallback OnAfterDeleteInterface[DummyAgent]
	OnAfterDummyAgentReadCallback   OnAfterReadInterface[DummyAgent]

	Engines           map[*Engine]any
	Engines_mapString map[string]*Engine

	// insertion point for slice of pointers maps
	OnAfterEngineCreateCallback OnAfterCreateInterface[Engine]
	OnAfterEngineUpdateCallback OnAfterUpdateInterface[Engine]
	OnAfterEngineDeleteCallback OnAfterDeleteInterface[Engine]
	OnAfterEngineReadCallback   OnAfterReadInterface[Engine]

	Events           map[*Event]any
	Events_mapString map[string]*Event

	// insertion point for slice of pointers maps
	OnAfterEventCreateCallback OnAfterCreateInterface[Event]
	OnAfterEventUpdateCallback OnAfterUpdateInterface[Event]
	OnAfterEventDeleteCallback OnAfterDeleteInterface[Event]
	OnAfterEventReadCallback   OnAfterReadInterface[Event]

	Statuss           map[*Status]any
	Statuss_mapString map[string]*Status

	// insertion point for slice of pointers maps
	OnAfterStatusCreateCallback OnAfterCreateInterface[Status]
	OnAfterStatusUpdateCallback OnAfterUpdateInterface[Status]
	OnAfterStatusDeleteCallback OnAfterDeleteInterface[Status]
	OnAfterStatusReadCallback   OnAfterReadInterface[Status]

	UpdateStates           map[*UpdateState]any
	UpdateStates_mapString map[string]*UpdateState

	// insertion point for slice of pointers maps
	OnAfterUpdateStateCreateCallback OnAfterCreateInterface[UpdateState]
	OnAfterUpdateStateUpdateCallback OnAfterUpdateInterface[UpdateState]
	OnAfterUpdateStateDeleteCallback OnAfterDeleteInterface[UpdateState]
	OnAfterUpdateStateReadCallback   OnAfterReadInterface[UpdateState]

	AllModelsStructCreateCallback AllModelsStructCreateInterface

	AllModelsStructDeleteCallback AllModelsStructDeleteInterface

	BackRepo BackRepoInterface

	// if set will be called before each commit to the back repo
	OnInitCommitCallback          OnInitCommitInterface
	OnInitCommitFromFrontCallback OnInitCommitInterface
	OnInitCommitFromBackCallback  OnInitCommitInterface

	// store the number of instance per gongstruct
	Map_GongStructName_InstancesNb map[string]int

	// store meta package import
	MetaPackageImportPath  string
	MetaPackageImportAlias string

	// to be removed after fix of [issue](https://github.com/golang/go/issues/57559)
	// map to enable docLink renaming when an identifier is renamed
	Map_DocLink_Renaming map[string]GONG__Identifier
	// contains filtered or unexported fields
}

StageStruct enables storage of staged instances swagger:ignore

func NewStage

func NewStage(path string) (stage *StageStruct)

func (*StageStruct) Backup

func (stage *StageStruct) Backup(dirPath string)

backup generates backup files in the dirPath

func (*StageStruct) BackupXL

func (stage *StageStruct) BackupXL(dirPath string)

backup generates backup files in the dirPath

func (*StageStruct) Checkout

func (stage *StageStruct) Checkout()

func (*StageStruct) Commit

func (stage *StageStruct) Commit()

func (*StageStruct) CommitWithSuspendedCallbacks

func (stage *StageStruct) CommitWithSuspendedCallbacks()

func (*StageStruct) ComputeReverseMaps

func (stage *StageStruct) ComputeReverseMaps()

ComputeReverseMaps computes the reverse map, for all intances, for all slice to pointers field Its complexity is in O(n)O(p) where p is the number of pointers

func (*StageStruct) GetPath

func (stage *StageStruct) GetPath() string

func (*StageStruct) GetType

func (stage *StageStruct) GetType() string

func (*StageStruct) IsStagedCommand

func (stage *StageStruct) IsStagedCommand(command *Command) (ok bool)

insertion point for stage per struct

func (*StageStruct) IsStagedDummyAgent

func (stage *StageStruct) IsStagedDummyAgent(dummyagent *DummyAgent) (ok bool)

func (*StageStruct) IsStagedEngine

func (stage *StageStruct) IsStagedEngine(engine *Engine) (ok bool)

func (*StageStruct) IsStagedEvent

func (stage *StageStruct) IsStagedEvent(event *Event) (ok bool)

func (*StageStruct) IsStagedStatus

func (stage *StageStruct) IsStagedStatus(status *Status) (ok bool)

func (*StageStruct) IsStagedUpdateState

func (stage *StageStruct) IsStagedUpdateState(updatestate *UpdateState) (ok bool)

func (*StageStruct) Marshall

func (stage *StageStruct) Marshall(file *os.File, modelsPackageName, packageName string)

Marshall marshall the stage content into the file as an instanciation into a stage

func (*StageStruct) Nil

func (stage *StageStruct) Nil()

func (*StageStruct) Reset

func (stage *StageStruct) Reset()

func (*StageStruct) Restore

func (stage *StageStruct) Restore(dirPath string)

Restore resets Stage & BackRepo and restores their content from the restore files in dirPath

func (*StageStruct) RestoreXL

func (stage *StageStruct) RestoreXL(dirPath string)

Restore resets Stage & BackRepo and restores their content from the restore files in dirPath

func (*StageStruct) StageBranchCommand

func (stage *StageStruct) StageBranchCommand(command *Command)

insertion point for stage branch per struct

func (*StageStruct) StageBranchDummyAgent

func (stage *StageStruct) StageBranchDummyAgent(dummyagent *DummyAgent)

func (*StageStruct) StageBranchEngine

func (stage *StageStruct) StageBranchEngine(engine *Engine)

func (*StageStruct) StageBranchEvent

func (stage *StageStruct) StageBranchEvent(event *Event)

func (*StageStruct) StageBranchStatus

func (stage *StageStruct) StageBranchStatus(status *Status)

func (*StageStruct) StageBranchUpdateState

func (stage *StageStruct) StageBranchUpdateState(updatestate *UpdateState)

func (*StageStruct) Unstage

func (stage *StageStruct) Unstage()

func (*StageStruct) UnstageBranchCommand

func (stage *StageStruct) UnstageBranchCommand(command *Command)

insertion point for unstage branch per struct

func (*StageStruct) UnstageBranchDummyAgent

func (stage *StageStruct) UnstageBranchDummyAgent(dummyagent *DummyAgent)

func (*StageStruct) UnstageBranchEngine

func (stage *StageStruct) UnstageBranchEngine(engine *Engine)

func (*StageStruct) UnstageBranchEvent

func (stage *StageStruct) UnstageBranchEvent(event *Event)

func (*StageStruct) UnstageBranchStatus

func (stage *StageStruct) UnstageBranchStatus(status *Status)

func (*StageStruct) UnstageBranchUpdateState

func (stage *StageStruct) UnstageBranchUpdateState(updatestate *UpdateState)

type Status

type Status struct {
	Name                       string
	CurrentCommand             CommandType
	CompletionDate             string
	CurrentSpeedCommand        SpeedCommandType
	SpeedCommandCompletionDate string
}

Status is the struct of the instance that is updated by the front for issuing Statuss swagger:model Status

func CopyBranchStatus

func CopyBranchStatus(mapOrigCopy map[any]any, statusFrom *Status) (statusTo *Status)

func (*Status) Checkout

func (status *Status) Checkout(stage *StageStruct) *Status

Checkout status to the back repo (if it is already staged)

func (*Status) Commit

func (status *Status) Commit(stage *StageStruct) *Status

commit status to the back repo (if it is already staged)

func (*Status) CommitVoid

func (status *Status) CommitVoid(stage *StageStruct)

func (*Status) CopyBasicFields

func (from *Status) CopyBasicFields(to *Status)

func (*Status) GetName

func (status *Status) GetName() (res string)

for satisfaction of GongStruct interface

func (*Status) Stage

func (status *Status) Stage(stage *StageStruct) *Status

Stage puts status to the model stage

func (*Status) Unstage

func (status *Status) Unstage(stage *StageStruct) *Status

Unstage removes status off the model stage

func (*Status) UnstageVoid

func (status *Status) UnstageVoid(stage *StageStruct)

UnstageVoid removes status off the model stage

type Status_WOP

type Status_WOP struct {
	// insertion point
	Name                       string
	CurrentCommand             CommandType
	CompletionDate             string
	CurrentSpeedCommand        SpeedCommandType
	SpeedCommandCompletionDate string
}

type Tabulator

type Tabulator interface {
	AddSheet(sheetName string)
	AddRow(sheetName string) int
	AddCell(sheetName string, rowId, columnIndex int, value string)
}

Tabulator is an interface for writing to a table strings

type UpdateState

type UpdateState struct {
	Event

	// Period is the time between two fires of FireTime
	Period time.Duration
}

UpdateState is an event whose role is to ask the agant to compute its new vector state swagger:model UpdateState

func CopyBranchUpdateState

func CopyBranchUpdateState(mapOrigCopy map[any]any, updatestateFrom *UpdateState) (updatestateTo *UpdateState)

func (*UpdateState) Checkout

func (updatestate *UpdateState) Checkout(stage *StageStruct) *UpdateState

Checkout updatestate to the back repo (if it is already staged)

func (*UpdateState) Commit

func (updatestate *UpdateState) Commit(stage *StageStruct) *UpdateState

commit updatestate to the back repo (if it is already staged)

func (*UpdateState) CommitVoid

func (updatestate *UpdateState) CommitVoid(stage *StageStruct)

func (*UpdateState) CopyBasicFields

func (from *UpdateState) CopyBasicFields(to *UpdateState)

func (*UpdateState) GetName

func (updatestate *UpdateState) GetName() (res string)

for satisfaction of GongStruct interface

func (*UpdateState) Stage

func (updatestate *UpdateState) Stage(stage *StageStruct) *UpdateState

Stage puts updatestate to the model stage

func (*UpdateState) Unstage

func (updatestate *UpdateState) Unstage(stage *StageStruct) *UpdateState

Unstage removes updatestate off the model stage

func (*UpdateState) UnstageVoid

func (updatestate *UpdateState) UnstageVoid(stage *StageStruct)

UnstageVoid removes updatestate off the model stage

type UpdateState_WOP

type UpdateState_WOP struct {
	// insertion point
	Name     string
	Duration time.Duration
	Period   time.Duration
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL