Debian Codegraph @

pdata/pcommon/generated_resource.go

raw
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 // Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT.
5 // To regenerate this file run "make genpdata".
6
7 package pcommon
8
9 import (
10 "go.opentelemetry.io/collector/pdata/internal"
11 )
12
13 // Resource is a message representing the resource information.
14 //
15 // This is a reference type, if passed by value and callee modifies it the
16 // caller will see the modification.
17 //
18 // Must use NewResource function to create new instances.
19 // Important: zero-initialized instance is not valid for use.
20 type Resource internal.ResourceWrapper
21
22 func newResource(orig *internal.Resource, state *internal.State) Resource {
23 return Resource(internal.NewResourceWrapper(orig, state))
24 }
25
26 // NewResource creates a new empty Resource.
27 //
28 // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice,
29 // OR directly access the member if this is embedded in another struct.
30 func NewResource() Resource {
31 return newResource(internal.NewResource(), internal.NewState())
32 }
33
34 // MoveTo moves all properties from the current struct overriding the destination and
35 // resetting the current instance to its zero value
36 func (ms Resource) MoveTo(dest Resource) {
37 ms.getState().AssertMutable()
38 dest.getState().AssertMutable()
39 // If they point to the same data, they are the same, nothing to do.
40 if ms.getOrig() == dest.getOrig() {
41 return
42 }
43 internal.DeleteResource(dest.getOrig(), false)
44 *dest.getOrig(), *ms.getOrig() = *ms.getOrig(), *dest.getOrig()
45 }
46
47 // Attributes returns the Attributes associated with this Resource.
48 func (ms Resource) Attributes() Map {
49 return Map(internal.NewMapWrapper(&ms.getOrig().Attributes, ms.getState()))
50 }
51
52 // DroppedAttributesCount returns the droppedattributescount associated with this Resource.
53 func (ms Resource) DroppedAttributesCount() uint32 {
54 return ms.getOrig().DroppedAttributesCount
55 }
56
57 // SetDroppedAttributesCount replaces the droppedattributescount associated with this Resource.
58 func (ms Resource) SetDroppedAttributesCount(v uint32) {
59 ms.getState().AssertMutable()
60 ms.getOrig().DroppedAttributesCount = v
61 }
62
63 // CopyTo copies all properties from the current struct overriding the destination.
64 func (ms Resource) CopyTo(dest Resource) {
65 dest.getState().AssertMutable()
66 internal.CopyResource(dest.getOrig(), ms.getOrig())
67 }
68
69 func (ms Resource) getOrig() *internal.Resource {
70 return internal.GetResourceOrig(internal.ResourceWrapper(ms))
71 }
72
73 func (ms Resource) getState() *internal.State {
74 return internal.GetResourceState(internal.ResourceWrapper(ms))
75 }