2013-06-04 17:38:43 +08:00
|
|
|
/****************************************************************************
|
2015-03-24 20:23:51 +08:00
|
|
|
Copyright (c) 2013-2015 Chukong Technologies Inc.
|
2013-06-04 17:38:43 +08:00
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __CC_FRAMEWORK_COMCONTAINER_H__
|
|
|
|
#define __CC_FRAMEWORK_COMCONTAINER_H__
|
|
|
|
|
2015-03-24 20:23:51 +08:00
|
|
|
/// @cond DO_NOT_SHOW
|
|
|
|
|
2014-04-27 01:35:57 +08:00
|
|
|
#include "base/CCMap.h"
|
2013-12-20 10:41:29 +08:00
|
|
|
#include <string>
|
2013-06-04 17:38:43 +08:00
|
|
|
|
|
|
|
NS_CC_BEGIN
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
class Component;
|
|
|
|
class Node;
|
2013-06-04 17:38:43 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL ComponentContainer
|
2013-06-04 17:38:43 +08:00
|
|
|
{
|
|
|
|
protected:
|
2013-09-13 16:46:31 +08:00
|
|
|
/**
|
|
|
|
* @js ctor
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
ComponentContainer(Node *pNode);
|
2013-06-04 17:38:43 +08:00
|
|
|
|
|
|
|
public:
|
2013-09-13 13:52:42 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
virtual ~ComponentContainer(void);
|
2013-12-24 10:51:47 +08:00
|
|
|
virtual Component* get(const std::string& name) const;
|
2013-12-18 18:51:36 +08:00
|
|
|
virtual bool add(Component *com);
|
2013-12-24 10:51:47 +08:00
|
|
|
virtual bool remove(const std::string& name);
|
2014-07-21 17:45:56 +08:00
|
|
|
virtual bool remove(Component *com);
|
2013-06-04 17:38:43 +08:00
|
|
|
virtual void removeAll();
|
2013-12-18 18:51:36 +08:00
|
|
|
virtual void visit(float delta);
|
2013-06-04 17:38:43 +08:00
|
|
|
public:
|
2013-06-05 15:05:49 +08:00
|
|
|
bool isEmpty() const;
|
2013-06-04 17:38:43 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
void alloc(void);
|
|
|
|
|
|
|
|
private:
|
2013-12-11 17:15:27 +08:00
|
|
|
Map<std::string, Component*>* _components;
|
2013-06-20 14:13:12 +08:00
|
|
|
Node *_owner;
|
2013-06-04 17:38:43 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
friend class Node;
|
2013-06-04 17:38:43 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
NS_CC_END
|
|
|
|
|
2015-03-24 20:23:51 +08:00
|
|
|
/// @endcond
|
2013-06-04 17:38:43 +08:00
|
|
|
#endif // __FUNDATION__CCCOMPONENT_H__
|