File: FileGenerator.hpp

package info (click to toggle)
yade 2026.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 34,448 kB
  • sloc: cpp: 97,645; python: 52,173; sh: 677; makefile: 162
file content (46 lines) | stat: -rw-r--r-- 1,566 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*************************************************************************
*  Copyright (C) 2004 by Olivier Galizzi                                 *
*  olivier.galizzi@imag.fr                                               *
*                                                                        *
*  This program is free software; it is licensed under the terms of the  *
*  GNU General Public License v2 or later. See file LICENSE for details. *
*************************************************************************/

#pragma once

#include <lib/base/Logging.hpp>
#include <lib/serialization/Serializable.hpp>

#include "Scene.hpp"
#include "ThreadWorker.hpp"

namespace yade { // Cannot have #include directive inside.

class FileGenerator : public Serializable {
protected:
	shared_ptr<Scene> scene;

public:
	bool generateAndSave(const string& outFile, string& message);

protected:
	//! Returns whether the generation was successful; message for user is in FileGenerator::message
	virtual bool generate(std::string& msg);

	void pyGenerate(const string& out);
	void pyLoad();

	// clang-format off
	YADE_CLASS_BASE_DOC_ATTRS_CTOR_PY(FileGenerator,Serializable,"Base class for scene generators, preprocessors.",
		/*attrs*/,
		/*ctor*/
		,
		.def("generate",&FileGenerator::pyGenerate,(boost::python::arg("out")),"Generate scene, save to given file")
		.def("load",&FileGenerator::pyLoad,"Generate scene, save to temporary file and load immediately");
	);
	// clang-format on
	DECLARE_LOGGER;
};
REGISTER_SERIALIZABLE(FileGenerator);

} // namespace yade