Skip to content

Commit

Permalink
Merge pull request #346 from trozet/getExternalIDs
Browse files Browse the repository at this point in the history
Expose getter functions for fields with modelgen
  • Loading branch information
jcaamano authored Jan 13, 2023
2 parents c938090 + a4f2602 commit 19d82f4
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 2 deletions.
9 changes: 7 additions & 2 deletions modelgen/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ import "github.com/ovn-org/libovsdb/model"
{{- else }}
{{- $type = FieldType $tableName $field.Column $field.Schema }}
{{- end }}
{{- if or (eq (index $type 0) '*') (eq (slice $type 0 2) "[]") (eq (slice $type 0 3) "map") }}
func (a *{{ $structName }}) Get{{ $fieldName }}() {{ $type }} {
return a.{{ $fieldName }}
}
{{ if or (eq (index $type 0) '*') (eq (slice $type 0 2) "[]") (eq (slice $type 0 3) "map") }}
func copy{{ $structName }}{{ $fieldName }}(a {{ $type }}) {{ $type }} {
if a == nil {
return nil
Expand Down Expand Up @@ -88,7 +93,7 @@ func equal{{ $structName }}{{ $fieldName }}(a, b {{ $type }}) bool {
}
{{ end }}
{{- end }}
{{ end }}
func (a *{{ $structName }}) DeepCopyInto(b *{{ $structName }}) {
*b = *a
Expand Down
72 changes: 72 additions & 0 deletions modelgen/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,26 @@ type AtomicTable struct {
Str string ` + "`" + `ovsdb:"str"` + "`" + `
}
func (a *AtomicTable) GetUUID() string {
return a.UUID
}
func (a *AtomicTable) GetEventType() AtomicTableEventType {
return a.EventType
}
func (a *AtomicTable) GetFloat() float64 {
return a.Float
}
func (a *AtomicTable) GetInt() int {
return a.Int
}
func (a *AtomicTable) GetProtocol() *AtomicTableProtocol {
return a.Protocol
}
func copyAtomicTableProtocol(a *AtomicTableProtocol) *AtomicTableProtocol {
if a == nil {
return nil
Expand All @@ -207,6 +227,10 @@ func equalAtomicTableProtocol(a, b *AtomicTableProtocol) bool {
return *a == *b
}
func (a *AtomicTable) GetStr() string {
return a.Str
}
func (a *AtomicTable) DeepCopyInto(b *AtomicTable) {
*b = *a
b.Protocol = copyAtomicTableProtocol(a.Protocol)
Expand Down Expand Up @@ -352,6 +376,26 @@ func (a *AtomicTable) PrintAtomicTableOtherProtocol() bool {
fmt.Printf(a.OtherProtocol)
}
func (a *AtomicTable) GetUUID() string {
return a.UUID
}
func (a *AtomicTable) GetEventType() AtomicTableEventType {
return a.EventType
}
func (a *AtomicTable) GetFloat() float64 {
return a.Float
}
func (a *AtomicTable) GetInt() int {
return a.Int
}
func (a *AtomicTable) GetProtocol() *AtomicTableProtocol {
return a.Protocol
}
func copyAtomicTableProtocol(a *AtomicTableProtocol) *AtomicTableProtocol {
if a == nil {
return nil
Expand All @@ -370,6 +414,10 @@ func equalAtomicTableProtocol(a, b *AtomicTableProtocol) bool {
return *a == *b
}
func (a *AtomicTable) GetStr() string {
return a.Str
}
func (a *AtomicTable) DeepCopyInto(b *AtomicTable) {
*b = *a
b.Protocol = copyAtomicTableProtocol(a.Protocol)
Expand Down Expand Up @@ -435,6 +483,26 @@ type AtomicTable struct {
Str string ` + "`" + `ovsdb:"str"` + "`" + `
}
func (a *AtomicTable) GetUUID() string {
return a.UUID
}
func (a *AtomicTable) GetEventType() string {
return a.EventType
}
func (a *AtomicTable) GetFloat() float64 {
return a.Float
}
func (a *AtomicTable) GetInt() int {
return a.Int
}
func (a *AtomicTable) GetProtocol() *string {
return a.Protocol
}
func copyAtomicTableProtocol(a *string) *string {
if a == nil {
return nil
Expand All @@ -453,6 +521,10 @@ func equalAtomicTableProtocol(a, b *string) bool {
return *a == *b
}
func (a *AtomicTable) GetStr() string {
return a.Str
}
func (a *AtomicTable) DeepCopyInto(b *AtomicTable) {
*b = *a
b.Protocol = copyAtomicTableProtocol(a.Protocol)
Expand Down
36 changes: 36 additions & 0 deletions ovsdb/serverdb/database.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 19d82f4

Please sign in to comment.