Mitsuba Renderer  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
util.h
Go to the documentation of this file.
1 /*
2  This file is part of Mitsuba, a physically based rendering system.
3 
4  Copyright (c) 2007-2014 by Wenzel Jakob and others.
5 
6  Mitsuba is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License Version 3
8  as published by the Free Software Foundation.
9 
10  Mitsuba is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #pragma once
20 #if !defined(__MITSUBA_RENDER_UTIL_H_)
21 #define __MITSUBA_RENDER_UTIL_H_
22 
23 #include <mitsuba/render/scene.h>
24 
26 
27 /** \brief Abstract utility class -- can be used to implement
28  * loadable utility plugins that perform various actions. They
29  * can be started using the 'mtsutil' launcher.
30  * \ingroup librender
31  */
33 public:
34  /**
35  * Run the utility. The supplied <tt>argc</tt>
36  * and <tt>argv</tt> parameters contain any
37  * extra arguments passed to mtsutil. The value
38  * returned here will be used as the return value of the
39  * 'mtsutil' process.
40  */
41  virtual int run(int argc, char **argv) = 0;
42 
44 protected:
45  typedef std::map<std::string, std::string, SimpleStringOrdering> ParameterMap;
46 
47  /// Virtual destructor
48  virtual ~Utility() { }
49 
50  /// Load a scene from an external file
51  ref<Scene> loadScene(const fs::path &fname,
52  const ParameterMap &params= ParameterMap());
53 
54  /// Load a scene from a string
55  ref<Scene> loadSceneFromString(const std::string &content,
56  const ParameterMap &params= ParameterMap());
57 };
58 
59 #define MTS_DECLARE_UTILITY() \
60  MTS_DECLARE_CLASS()
61 
62 #define MTS_EXPORT_UTILITY(name, descr) \
63  MTS_IMPLEMENT_CLASS(name, false, Utility) \
64  extern "C" { \
65  void MTS_EXPORT *CreateUtility() { \
66  return new name(); \
67  } \
68  const char MTS_EXPORT *GetDescription() { \
69  return descr; \
70  } \
71  }
72 
74 
75 #endif /* __MITSUBA_RENDER_UTIL_H_ */
Abstract utility class – can be used to implement loadable utility plugins that perform various actio...
Definition: util.h:32
#define MTS_NAMESPACE_BEGIN
Definition: platform.h:137
#define MTS_DECLARE_CLASS()
This macro must be used in the initial definition in classes that derive from Object.
Definition: class.h:158
Reference counting helper.
Definition: ref.h:40
Simple functor for sorting string parameters by length and content.
Definition: util.h:82
Parent of all Mitsuba classes.
Definition: object.h:38
#define MTS_EXPORT_RENDER
Definition: platform.h:109
#define MTS_NAMESPACE_END
Definition: platform.h:138
std::map< std::string, std::string, SimpleStringOrdering > ParameterMap
Definition: util.h:45