Ocean
AttributeSet.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #ifndef META_OCEAN_RENDERING_ATTRIBUTE_SET_H
9 #define META_OCEAN_RENDERING_ATTRIBUTE_SET_H
10 
13 #include "ocean/rendering/Object.h"
15 
16 #include <set>
17 
18 namespace Ocean
19 {
20 
21 namespace Rendering
22 {
23 
24 // Forward declaration
25 class AttributeSet;
26 
27 /**
28  * Definition of a smart object reference holding an attribute set.
29  * @see SmartObjectRef, AttributeSet.
30  * @ingroup rendering
31  */
33 
34 /**
35  * This class is the base class for all attribute set objects.
36  * An attribute set holds several attributes like material, texture or blend attributes.<br>
37  * The attributes of this set determine the appearance of a geometry node.<br>
38  * Each geometry node can hold at most one attribute set.<br>
39  * @see Attribute, Geometry
40  * @ingroup rendering
41  */
42 class OCEAN_RENDERING_EXPORT AttributeSet : virtual public Object
43 {
44  protected:
45 
46  /**
47  * Definition of a set holding attribute objects.
48  */
49  typedef std::set<AttributeRef> Attributes;
50 
51  public:
52 
53  /**
54  * Returns the number of registered attributes.
55  * @return Number of attributes
56  */
57  virtual unsigned int numberAttributes() const;
58 
59  /**
60  * Returns an attribute specified by the index.
61  * @param index Index of the attribute to return
62  * @return Requested attribute
63  */
64  virtual AttributeRef attribute(const unsigned int index) const;
65 
66  /**
67  * Returns the attribute with a specific type.
68  * @param attributeType Attribute type to return
69  * @return Requested attribute, an empty reference if the specific attribute type is not defined
70  */
71  virtual AttributeRef attribute(const ObjectType attributeType) const;
72 
73  /**
74  * Returns wehether an attribute with a specific type exists in this set.
75  * @param attributeType Attribute type to check
76  * @return True, if at least one attribute with the specified type exists
77  */
78  virtual bool hasAttribute(const ObjectType attributeType) const;
79 
80  /**
81  * Adds a new attribute to this attribute set.
82  * @param attribute New attribute to add
83  */
84  virtual void addAttribute(const AttributeRef& attribute);
85 
86  /**
87  * Removes a registered attribute from this attribute ses.
88  * @param attribute Attribute to remove
89  */
90  virtual void removeAttribute(const AttributeRef& attribute);
91 
92  /**
93  * Removes the first registered attribute having a specified attribute type.
94  * @param attributeType Type of the attribute to be removed
95  * @return True, if an attribute existed and has been removed
96  */
97  virtual bool removeAttribute(const ObjectType attributeType);
98 
99  /**
100  * Returns the type of this object.
101  * @see Object::type().
102  */
103  ObjectType type() const override;
104 
105  protected:
106 
107  /**
108  * Creates a new attribute set object.
109  */
111 
112  /**
113  * Destructs an attribute set object.
114  */
115  ~AttributeSet() override;
116 
117  protected:
118 
119  /// Set holding registered attributes.
121 };
122 
123 }
124 
125 }
126 
127 #endif // META_OCEAN_RENDERING_ATTRIBUTE_SET_H
This class is the base class for all attribute set objects.
Definition: AttributeSet.h:43
virtual bool hasAttribute(const ObjectType attributeType) const
Returns wehether an attribute with a specific type exists in this set.
Attributes setAttributes
Set holding registered attributes.
Definition: AttributeSet.h:120
virtual AttributeRef attribute(const unsigned int index) const
Returns an attribute specified by the index.
virtual AttributeRef attribute(const ObjectType attributeType) const
Returns the attribute with a specific type.
std::set< AttributeRef > Attributes
Definition of a set holding attribute objects.
Definition: AttributeSet.h:49
virtual unsigned int numberAttributes() const
Returns the number of registered attributes.
virtual void addAttribute(const AttributeRef &attribute)
Adds a new attribute to this attribute set.
virtual void removeAttribute(const AttributeRef &attribute)
Removes a registered attribute from this attribute ses.
ObjectType type() const override
Returns the type of this object.
AttributeSet()
Creates a new attribute set object.
virtual bool removeAttribute(const ObjectType attributeType)
Removes the first registered attribute having a specified attribute type.
~AttributeSet() override
Destructs an attribute set object.
This class is the base class for all rendering objects.
Definition: Object.h:54
ObjectType
Definition of different object type.
Definition: Object.h:63
SmartObjectRef< AttributeSet > AttributeSetRef
Definition of a smart object reference holding an attribute set.
Definition: AttributeSet.h:25
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15