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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
/******************************************************************************
*
* MantaFlow fluid solver framework
* Copyright 2011-2014 Tobias Pfaff, Nils Thuerey
*
* This program is free software, distributed under the terms of the
* Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Base class for all Python-exposed classes
*
******************************************************************************/
// -----------------------------------------------------------------
// NOTE:
// Do not include this file in user code, include "manta.h" instead
// -----------------------------------------------------------------
#ifdef _MANTA_H
# ifndef _PTYPE_H
# define _PTYPE_H
# include <string>
# include <vector>
# include <map>
class QMutex;
namespace Manta {
struct PbClassData;
class FluidSolver;
class PbArgs;
struct PbType {
std::string S;
std::string str() const;
};
struct PbTypeVec {
std::vector<PbType> T;
std::string str() const;
};
//! Base class for all classes exposed to Python
class PbClass {
public:
PbClass(FluidSolver *parent, const std::string &name = "", PyObject *obj = NULL);
PbClass(const PbClass &a);
virtual ~PbClass();
// basic property setter/getters
void setName(const std::string &name)
{
mName = name;
}
std::string getName() const
{
return mName;
}
PyObject *getPyObject() const
{
return mPyObject;
}
void registerObject(PyObject *obj, PbArgs *args);
FluidSolver *getParent() const
{
return mParent;
}
void setParent(FluidSolver *v)
{
mParent = v;
}
void checkParent();
// hidden flag for GUI, debug output
inline bool isHidden()
{
return mHidden;
}
inline void setHidden(bool v)
{
mHidden = v;
}
void lock();
void unlock();
bool tryLock();
// PbClass instance registry
static int getNumInstances();
static PbClass *getInstance(int index);
static void renameObjects();
// converters
static bool isNullRef(PyObject *o);
static bool isNoneRef(PyObject *o);
static PbClass *createPyObject(const std::string &classname,
const std::string &name,
PbArgs &args,
PbClass *parent);
inline bool canConvertTo(const std::string &classname)
{
return Pb::canConvert(mPyObject, classname);
}
protected:
QMutex *mMutex;
FluidSolver *mParent;
PyObject *mPyObject;
std::string mName;
bool mHidden;
static std::vector<PbClass *> mInstances;
};
//!\cond Register
void pbFinalizePlugin(FluidSolver *parent, const std::string &name, bool doTime = true);
void pbPreparePlugin(FluidSolver *parent, const std::string &name, bool doTime = true);
void pbSetError(const std::string &fn, const std::string &ex);
//!\endcond
} // namespace Manta
# endif
#endif
|