summaryrefslogtreecommitdiffstats
path: root/pkg/icingadb/scoped_entity.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/icingadb/scoped_entity.go')
-rw-r--r--pkg/icingadb/scoped_entity.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/pkg/icingadb/scoped_entity.go b/pkg/icingadb/scoped_entity.go
new file mode 100644
index 0000000..7c1688c
--- /dev/null
+++ b/pkg/icingadb/scoped_entity.go
@@ -0,0 +1,32 @@
+package icingadb
+
+import (
+ "github.com/icinga/icingadb/pkg/contracts"
+ "github.com/icinga/icingadb/pkg/utils"
+)
+
+// ScopedEntity combines an entity and a scope that specifies
+// the WHERE conditions that entities of the
+// enclosed entity type must satisfy in order to be SELECTed.
+type ScopedEntity struct {
+ contracts.Entity
+ scope interface{}
+}
+
+// Scope implements the contracts.Scoper interface.
+func (e ScopedEntity) Scope() interface{} {
+ return e.scope
+}
+
+// TableName implements the contracts.TableNamer interface.
+func (e ScopedEntity) TableName() string {
+ return utils.TableName(e.Entity)
+}
+
+// NewScopedEntity returns a new ScopedEntity.
+func NewScopedEntity(entity contracts.Entity, scope interface{}) *ScopedEntity {
+ return &ScopedEntity{
+ Entity: entity,
+ scope: scope,
+ }
+}