component/CCComponentContainer(接口容器)

来源:互联网 发布:明星开的淘宝店 编辑:程序博客网 时间:2024/05/01 18:41


#ifndef __CC_FRAMEWORK_COMCONTAINER_H__

#define __CC_FRAMEWORK_COMCONTAINER_H__


#include "cocoa/CCDictionary.h"


NS_CC_BEGIN


class CCComponent;

class CCNode;


class CC_DLL CCComponentContainer

{

protected:

    CCComponentContainer(CCNode *pNode);

    

public:

    virtual ~CCComponentContainer(void);

//根据名字 得到  增加 移除  component

    virtual CCComponent* get(const char *pName) const;

    virtual bool add(CCComponent *pCom);

    virtual bool remove(const char *pName);

//移除所有

    virtual void removeAll();

    virtual void visit(float fDelta);

public:

    bool isEmpty() const;

    

private:

    void alloc(void);//分配

void CCComponentContainer::alloc(void)

{

    m_pComponents = CCDictionary::create();

    m_pComponents->retain();

}


    

private:

    CCDictionary *m_pComponents;        ///< Dictionary of components

    CCNode *m_pOwner;

    

    friend class CCNode; 

//当希望一个类可以存取另一个类的私有成员时,可以将该类声明为另一类的友元类。 (1) 友元关系不能被继承。

//所以 ccnode 可以访问以上两个私有成员

};


NS_CC_END


#endif  // __FUNDATION__CCCOMPONENT_H__


0 0
原创粉丝点击