You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

119 lines
5.5 KiB
C++

#ifndef _FITKCFDPostMacros_H_
#define _FITKCFDPostMacros_H_
/**
* @brief (...)set get
*/
#define AddProperty(AType, AVariable, ...) private: AType _##AVariable{##__VA_ARGS__}; \
public: \
virtual void set##AVariable(AType V) {_##AVariable = V;} \
virtual AType get##AVariable() const {return _##AVariable;}
/**
* @brief (...)set
*/
#define AddPropertyWriteOnly(AType, AVariable, ...) private: AType _##AVariable{##__VA_ARGS__}; \
public: \
virtual void set##AVariable(AType V) {_##AVariable = V;}
/**
* @brief (...)get
*/
#define AddPropertyReadOnly(AType, AVariable, ...) private: AType _##AVariable{##__VA_ARGS__}; \
public: \
virtual AType get##AVariable() const {return _##AVariable;}
/**
* @brief (...)set get, get
*/
#define AddPropertyGetOverride(AType, AVariable, ...) private: AType _##AVariable{##__VA_ARGS__}; \
public: \
virtual void set##AVariable(AType V) {_##AVariable = V;}\
virtual AType get##AVariable();
/**
* @brief (...)set get, set
*/
#define AddPropertySetOverride(AType, AVariable, ...) private: AType _##AVariable{##__VA_ARGS__}; \
public: \
virtual void set##AVariable(AType V);\
virtual AType get##AVariable() {return _##AVariable;}
/**
* @brief (...)set get, get set
*/
#define AddComplexProperty(AType, AVariable, ...) private: AType _##AVariable{##__VA_ARGS__}; \
public: \
virtual void set##AVariable(AType V) ; \
virtual AType get##AVariable();
/**
* @brief (...访)
*/
#define AddPtrListProperty(AType, AVariable, ...) private: ##__VA_ARGS__ QList<AType*> _##AVariable{}; \
public: \
int get##AVariable##Count(){return _##AVariable.size();} \
void append##AVariable(AType* v){_##AVariable.append(v);} \
AType* get##AVariable##At(int index) \
{if(index<0 || index >= _##AVariable.size()) return nullptr;\
return _##AVariable.at(index); }
/**
* @brief (...访)
*/
#define AddListProperty(AType, AVariable, ...) private: ##__VA_ARGS__ QList<AType> _##AVariable{}; \
public: \
virtual int get##AVariable##Count(){return _##AVariable.size();} \
virtual void append##AVariable(AType v){if(!_##AVariable.contains(v)) _##AVariable.append(v);} \
virtual AType get##AVariable##At(int index) \
{if(index<0 || index >= _##AVariable.size()) return AType();\
return _##AVariable.at(index); }\
virtual void clear##AVariable(){_##AVariable.clear();}
/**
* @brief
*/
#define DeleteItem(item) if(item!=nullptr){delete item; item = nullptr;}
/**
* @brief ID
*/
#define AutoDistributeID public: int getID() {return _id;} \
static int getMaxID() {return MaxID;} \
protected: int _id{ 0 }; \
void setID(int id) {_id = id;} \
private: static int MaxID;
/**
* @brief VTK, Type Vtk Variable
*/
#define DeclarVTKSmartPtr(Type,Variable) vtkSmartPointer<Type> Variable{nullptr};
/**
* @brief VTK, Variable Type Vtk Variable
*/
#define CreateVTKSmartPtr(Type,Variable) Variable = vtkSmartPointer<Type>::New();
/**
* @brief VTK, Type Vtk Variable
*/
#define DecCreVTKSmartPtr(Type,Variable) vtkSmartPointer<Type> Variable = vtkSmartPointer<Type>::New();
/**
* @brief VTK, Type Vtk Variable
*/
#define DecCreVTKPtr(Type,Variable) Type* Variable = Type::New();
/**
*QString char*
*/
#define QString2Char(QSTRING, CCHAR) QByteArray ba = QSTRING.toLatin1(); \
char* CCHAR = ba.data();
/**
*char* QString
*/
#define Char2QString(CCHAR, QSTRING) QString QSTRING = QString::fromLocal8Bit(CCHAR);
#endif