2013-06-04 17:38:43 +08:00
|
|
|
/****************************************************************************
|
2018-01-29 16:25:32 +08:00
|
|
|
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
2013-06-04 17:38:43 +08:00
|
|
|
|
2022-01-04 12:36:20 +08:00
|
|
|
https://adxeproject.github.io/
|
2013-06-04 17:38:43 +08:00
|
|
|
|
|
|
|
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
|
|
|
|
*/
|
2015-09-09 11:53:55 +08:00
|
|
|
ComponentContainer(Node* node);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2013-06-04 17:38:43 +08:00
|
|
|
public:
|
2013-09-13 13:52:42 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2015-09-18 11:48:43 +08:00
|
|
|
~ComponentContainer();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
/**
|
2015-03-28 14:28:16 +08:00
|
|
|
* @js getComponent
|
|
|
|
*/
|
2021-12-26 23:26:34 +08:00
|
|
|
Component* get(std::string_view name) const;
|
2015-09-18 11:48:43 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
bool add(Component* com);
|
2021-12-26 23:26:34 +08:00
|
|
|
bool remove(std::string_view name);
|
2021-12-25 10:04:45 +08:00
|
|
|
bool remove(Component* com);
|
2015-09-18 11:48:43 +08:00
|
|
|
void removeAll();
|
|
|
|
void visit(float delta);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-09-18 11:48:43 +08:00
|
|
|
void onEnter();
|
|
|
|
void onExit();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
bool isEmpty() const { return _componentMap.empty(); }
|
|
|
|
|
2013-06-04 17:38:43 +08:00
|
|
|
private:
|
2021-12-26 23:26:34 +08:00
|
|
|
hlookup::string_map<Component*> _componentMap;
|
2021-12-25 10:04:45 +08:00
|
|
|
Node* _owner;
|
|
|
|
|
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
|
2015-11-18 00:39:43 +08:00
|
|
|
#endif // __CC_FRAMEWORK_COMCONTAINER_H__
|