mantaflow  0.10
A framework for fluid simulation
pclass.h
Go to the documentation of this file.
1 
2 /******************************************************************************
3  *
4  * MantaFlow fluid solver framework
5  * Copyright 2011-2014 Tobias Pfaff, Nils Thuerey
6  *
7  * This program is free software, distributed under the terms of the
8  * GNU General Public License (GPL)
9  * http://www.gnu.org/licenses
10  *
11  * Base class for all Python-exposed classes
12  *
13  ******************************************************************************/
14 
15 // -----------------------------------------------------------------
16 // NOTE:
17 // Do not include this file in user code, include "manta.h" instead
18 // -----------------------------------------------------------------
19 
20 #ifdef _MANTA_H
21 #ifndef _PTYPE_H
22 #define _PTYPE_H
23 
24 #include <string>
25 #include <vector>
26 #include <map>
27 
28 class QMutex;
29 
30 namespace Manta {
31 struct PbClassData;
32 class FluidSolver;
33 class PbArgs;
34 
35 struct PbType {
36  std::string S;
37  std::string str() const;
38 };
39 struct PbTypeVec {
40  std::vector<PbType> T;
41  std::string str() const;
42 };
43 
45 class PbClass {
46 public:
47  PbClass(FluidSolver* parent, const std::string& name="", PyObject* obj=NULL);
48  PbClass(const PbClass& a);
49  virtual ~PbClass();
50 
51  // basic property setter/getters
52  void setName(const std::string& name) { mName = name; }
53  std::string getName() const { return mName; }
54  PyObject* getPyObject() const { return mPyObject; }
55  void registerObject(PyObject* obj, PbArgs* args);
56  FluidSolver* getParent() const { return mParent; }
57  void setParent(FluidSolver* v) { mParent = v; }
58  void checkParent();
59 
60  // hidden flag for GUI, debug output
61  inline bool isHidden() { return mHidden; }
62  inline void setHidden(bool v) { mHidden = v; }
63 
64  void lock();
65  void unlock();
66  bool tryLock();
67 
68  // PbClass instance registry
69  static int getNumInstances();
70  static PbClass* getInstance(int index);
71  static void renameObjects();
72 
73  // converters
74  static bool isNullRef(PyObject* o);
75  static PbClass* createPyObject(const std::string& classname, const std::string& name, PbArgs& args, PbClass *parent);
76  inline bool canConvertTo(const std::string& classname) { return Pb::canConvert(mPyObject, classname); }
77 
78 protected:
79  QMutex* mMutex;
80  FluidSolver* mParent;
81  PyObject* mPyObject;
82  std::string mName;
83  bool mHidden;
84 
85  static std::vector<PbClass*> mInstances;
86 };
87 
89 
90 void pbFinalizePlugin(FluidSolver* parent, const std::string& name, bool doTime=true);
91 void pbPreparePlugin(FluidSolver* parent, const std::string& name, bool doTime=true);
92 void pbSetError(const std::string& fn, const std::string& ex);
93 
95 
96 } // namespace
97 
98 #endif
99 #endif
100 
101 
Definition: commonkernels.h:22
Definition: pclass.cpp:24