看续续触发器笔记

来源:互联网 发布:caffe windows 教程 编辑:程序博客网 时间:2024/06/10 17:58

1.定义Parent类型: 

代码:
#define CONDITIONSERVER_BEGIN(TMSG) template<class TObject> \
 class CConditionServer<TMSG, TObject> : public CConditionServerBase<TObject> \
 { \
 public: \
  typedef CConditionServerBase<TObject> Parent; \

。。。。

 

笔记:

原来是要直接呼唤父类的名字,恩恩恩。。不能直呼父亲的名讳。。不错. class Player:public Object{}

unsigned int Player::getID()

{

       return Object::getID();//需要指明道姓;

}

 

2.利用模板特化,将实际的类隐藏起来,外部用枚举值去索引类型


template <EConditionMsg T = eConMsg_Max>
struct TConditionClass
{
};

#define DEFINECONDITIONCLASS(classname, msgname) \
 template <>\
 struct TConditionClass<msgname>\
 {\
  typedef classname ClassType;\
 };


//触发器执行条件基类
class CConditionBase_Attr
{
public:
 CConditionBase_Attr()
 {
  m_eNeedConMsg = eConMsg_Max;
  m_iEffectNum = -1;
 }

 EConditionMsg m_eNeedConMsg;  //需求的条件消息
 int    m_iEffectNum;  //生效次数 -1代表无限制

};
DEFINECONDITIONCLASS(CConditionBase_Attr, eConMsg_Max)

 

TConditionClass::eConMsg_Max::ClassType ---------就是被隐藏起来的CConditionBase_Attr

原创粉丝点击