1 | |
2 | // |
3 | // This source file is part of appleseed. |
4 | // Visit http://appleseedhq.net/ for additional information and resources. |
5 | // |
6 | // This software is released under the MIT license. |
7 | // |
8 | // Copyright (c) 2014-2017 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 | #ifndef APPLESEED_PYTHON_METADATA_H |
30 | #define APPLESEED_PYTHON_METADATA_H |
31 | |
32 | // appleseed.python headers. |
33 | #include "pyseed.h" // has to be first, to avoid redefinition warnings |
34 | #include "dict2dict.h" |
35 | |
36 | // appleseed.foundation headers. |
37 | #include "foundation/utility/api/specializedapiarrays.h" |
38 | #include "foundation/utility/containers/dictionary.h" |
39 | |
40 | namespace detail |
41 | { |
42 | template <typename FactoryRegistrar> |
43 | boost::python::dict get_entity_model_metadata() |
44 | { |
45 | FactoryRegistrar registrar; |
46 | const typename FactoryRegistrar::FactoryArrayType factories = registrar.get_factories(); |
47 | |
48 | boost::python::dict model_metadata; |
49 | |
50 | for (size_t i = 0, e = factories.size(); i < e; ++i) |
51 | { |
52 | model_metadata[factories[i]->get_model()] = |
53 | dictionary_to_bpy_dict(factories[i]->get_model_metadata()); |
54 | } |
55 | |
56 | return model_metadata; |
57 | } |
58 | |
59 | template <typename FactoryRegistrar> |
60 | boost::python::dict get_entity_input_metadata() |
61 | { |
62 | FactoryRegistrar registrar; |
63 | const typename FactoryRegistrar::FactoryArrayType factories = registrar.get_factories(); |
64 | |
65 | boost::python::dict input_metadata; |
66 | |
67 | for (size_t i = 0, e = factories.size(); i < e; ++i) |
68 | { |
69 | input_metadata[factories[i]->get_model()] = |
70 | dictionary_array_to_bpy_dict(factories[i]->get_input_metadata(), "name" ); |
71 | } |
72 | |
73 | return input_metadata; |
74 | } |
75 | } |
76 | |
77 | #endif // !APPLESEED_PYTHON_METADATA_H |
78 | |