wzcomponent.hxx

来自「有限元学习研究用源代码(老外的),供科研人员参考」· HXX 代码 · 共 34 行

HXX
34
字号
#ifndef WZCOMPONENT
#define WZCOMPONENT

#include "wz.hxx"

class wzComponentClass{
public:
	virtual void readAccess();
	virtual void writeAccess();
};

class wzComponentData{
	wzComponentClass& c;
public:
	void readAccess()  const {c.readAccess();}
	void writeAccess() const {c.writeAccess();}
	wzComponentData(wzComponentClass& cc):c(cc){;}
};

template<class T> class wzComponent{
	wzComponentData d;
protected:
friend class wzComponentClass;
public:
  T value;
  long int offset() const {return ((long int)(&value))-((long int)&d);}
  operator T() const {d.readAccess(); return value;}
  const T& operator=(const T& t)
  {value = t; d.writeAccess(); return t;}
  wzComponent(wzComponentClass& cc,T t):d(cc), value(t){;}
};

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?