1 
2 //
3 // This source file is part of appleseed.
4 // Visit https://appleseedhq.net/ for additional information and resources.
5 //
6 // This software is released under the MIT license.
7 //
8 // Copyright (c) 2018 Esteban Tovagliari, The appleseedhq Organization
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining a copy
11 // of this software and associated documentation files (the "Software"), to deal
12 // in the Software without restriction, including without limitation the rights
13 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 // copies of the Software, and to permit persons to whom the Software is
15 // furnished to do so, subject to the following conditions:
16 //
17 // The above copyright notice and this permission notice shall be included in
18 // all copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 // THE SOFTWARE.
27 //
28 
29 #pragma once
30 
31 // appleseed.renderer headers.
32 #include "renderer/modeling/shadergroup/shadergroup.h"
33 #include "renderer/modeling/entity/entitytraits.h"
34 #include "renderer/modeling/scene/containers.h"
35 
36 // appleseed.foundation headers.
37 #include "foundation/utility/autoreleaseptr.h"
38 #include "foundation/utility/containers/dictionary.h"
39 #include "foundation/utility/iostreamop.h"
40 
41 namespace renderer
42 {
43 
44 //
45 // ShaderGroup entity traits.
46 //
47 
48 template <>
49 struct EntityTraits<ShaderGroup>
50 {
51     typedef ShaderGroupContainer ContainerType;
52     typedef ShaderGroupFactory FactoryType;
53 
54     static const char* get_entity_type_name()                           { return "shader_group"; }
55     static const char* get_human_readable_entity_type_name()            { return "Shader Group"; }
56     static const char* get_human_readable_collection_type_name()        { return "Shader Groups"; }
57 
58     template <typename ParentEntity>
59     static ContainerType& get_entity_container(ParentEntity& parent)    { return parent.shader_groups(); }
60 
61     static foundation::Dictionary get_entity_values(const ShaderGroup* entity)
62     {
63         return foundation::Dictionary();
64     }
65 
66     template <typename ParentEntity>
67     static void insert_entity(
68         foundation::auto_release_ptr<ShaderGroup>   entity,
69         ParentEntity&                               parent)
70     {
71         get_entity_container(parent).insert(entity);
72     }
73 
74     template <typename ParentEntity>
75     static void remove_entity(
76         ShaderGroup*                                entity,
77         ParentEntity&                               parent)
78     {
79         get_entity_container(parent).remove(entity);
80     }
81 };
82 
83 }   // namespace renderer
84