当前位置: 首页>>代码示例>>C++>>正文


C++ ComponentPtr类代码示例

本文整理汇总了C++中ComponentPtr的典型用法代码示例。如果您正苦于以下问题:C++ ComponentPtr类的具体用法?C++ ComponentPtr怎么用?C++ ComponentPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ComponentPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: addComponent

bool Entity::addComponent( const ComponentPtr& component )
{
	if( !component ) return false;

	Class* type = component->getType();

    if( componentsMap.Find(type) != componentsMap.End() )
	{
        LogWarn( "Component '%s' already exists in '%s'", type->name, name.CString() );
		return false;
	}

	componentsMap[type] = component;
	component->setEntity(this);

	onComponentAdded(component);
	sendEvents();

	if( IsGroup(parent) )
	{
		Group* group = (Group*) parent;
		group->onEntityComponentAdded(component);
	}

    components.Push(component);

	return true;
}
开发者ID:FloodProject,项目名称:flood,代码行数:28,代码来源:Entity.cpp

示例2: ValidateComponent

bool ComponentCollection::ValidateComponent( const ComponentPtr &component, tstring& error ) const
{
    HELIUM_ASSERT( component->GetSlot() != Reflect::ReservedTypes::Invalid );

    // Check for duplicates.
    if ( ContainsComponent( component->GetSlot() ) )
    {
        error = tstring( TXT( "The component '" ) )+ component->GetClass()->m_UIName + TXT( "' is a duplicate (a component already occupies that slot in the collection)." );
        return false;
    }

    // Check to make sure this type of collection accepts this type of component.
    if ( !ValidateCompatible( component, error ) )
    {
        return false;
    }

    // Check to make sure that each component already within the collection is valid with the new one.
    M_Component::const_iterator itr = m_Components.begin();
    M_Component::const_iterator end = m_Components.end();
    for ( ; itr != end; ++itr )
    {
        // Check both directions so that the validation rule only has to be implemented in one place.
        if ( !itr->second->ValidateSibling( component, error ) || !component->ValidateSibling( itr->second.Ptr(), error ) )
        {
            return false;
        }
    }

    return true;
}
开发者ID:andyburke,项目名称:Replicant,代码行数:31,代码来源:ComponentCollection.cpp

示例3: ProcessComponent

	void ElementGroup::ProcessComponent(const ComponentPtr& component, bool removable)
	{
		bool added = AddInspector(component, component->GetType(), removable);

		// If there wasn't a specific inspector for the given type, try adding interface inspectors
		if (!added)
		{
			// Make sure the transform inspector is at the top
			const auto& actualInterfaces = component->GetInterfaces();
			auto entry = actualInterfaces.find("ITransform");
			if (entry == actualInterfaces.end())
			{
				for (auto it = actualInterfaces.begin(), end = actualInterfaces.end(); it != end; ++it)
					added |= AddInspector(component, *it, removable);
			}
			else
			{
				AddInspector(component, "ITransform", false);

				std::set<std::string> interfacesMinusTransform = actualInterfaces;
				interfacesMinusTransform.erase("ITransform");
				for (auto it = interfacesMinusTransform.begin(), end = interfacesMinusTransform.end(); it != end; ++it)
					added |= AddInspector(component, *it, removable);
			}
		}
		if (!added)
			SendToConsole("No inspector for component type: " + component->GetType());
	}
开发者ID:Kezeali,项目名称:Fusion,代码行数:28,代码来源:FusionElementInspectorGroup.cpp

示例4: void

ComponentCollection::ComponentCollection( const ComponentPtr& component )
{
    HELIUM_ASSERT( component->GetSlot() != Reflect::ReservedTypes::Invalid );

    m_Components.insert( M_Component::value_type( component->GetSlot(), component ) );
    component->AddChangedListener( ElementChangeSignature::Delegate::Create<ComponentCollection, void (ComponentCollection::*)( const Reflect::ElementChangeArgs& )> ( this, &ComponentCollection::ComponentChanged ) );
    m_Modified = true;
}
开发者ID:andyburke,项目名称:Replicant,代码行数:8,代码来源:ComponentCollection.cpp

示例5: void

ComponentCollection::ComponentCollection( const ComponentPtr& component )
{
    HELIUM_ASSERT( component->GetSlot() != NULL );

    m_Components.insert( M_Component::value_type( component->GetSlot(), component ) );
    component->e_Changed.Add( ObjectChangeSignature::Delegate::Create<ComponentCollection, void (ComponentCollection::*)( const Reflect::ObjectChangeArgs& )> ( this, &ComponentCollection::ComponentChanged ) );
    m_Modified = true;
}
开发者ID:kevindqc,项目名称:Helium,代码行数:8,代码来源:ComponentCollection.cpp

示例6: layout

gluit::Size GridTransformerRendererLayout::layout(ComponentPtr component)
{
	GridTransformerRenderer::Ptr renderer = boost::static_pointer_cast<GridTransformerRenderer>(component);

	const Rectangle& bounds = renderer->inputBounds;

	return gluit::Size::fromDouble(bounds.getWidth(), bounds.getHeight()).shrinkToFitIn(
		component->getMaximumSize().shrink(component->getInsets())).grow(component->getInsets());
}
开发者ID:simonlmn,项目名称:actracktive,代码行数:9,代码来源:GridTransformerUI.cpp

示例7: AddComponent

bool ComponentGroup::AddComponent(ComponentPtr comp)
{
    PROFILE(ComponentGroup_AddComponent);
    //Check if the component have already added to component group or it's name or type are different for the component group.
    if(ContainsComponent(comp) || comp->Name() != name_ || comp->TypeName() != typeName_) 
        return false;
    components_.push_back(ComponentWeakPtr(comp));
    editor_->AddNewComponent(comp);
    return true;
}
开发者ID:katik,项目名称:naali,代码行数:10,代码来源:ComponentGroup.cpp

示例8: ComponentPtr

ComponentPtr ComponentManager::CreateComponent(const QString &type_name, const QString &name)
{
    ComponentFactoryMap::const_iterator iter = factories_.find(type_name);
    if (iter == factories_.end())
        return ComponentPtr();

    ComponentPtr component = (*iter->second.get())();
    component->SetName(name);
    return component;
}
开发者ID:A-K,项目名称:naali,代码行数:10,代码来源:ComponentManager.cpp

示例9: QTreeWidgetItem

ComponentItem::ComponentItem(const ComponentPtr &comp, EntityItem *parent) :
    QTreeWidgetItem(parent),
    parentItem(parent),
    ptr(comp),
    typeId(comp->TypeId()),
    typeName(comp->TypeName()),
    name(comp->Name())
{
    SetText(comp.get());
}
开发者ID:Pouique,项目名称:naali,代码行数:10,代码来源:SceneTreeWidgetItems.cpp

示例10: AddComponent

void Entity::AddComponent(component_id_t id, const ComponentPtr &component, AttributeChange::Type change)
{
    // Must exist and be free
    if (component && component->ParentEntity() == 0)
    {
        if (!id)
        {
            bool authority = true;
            if (scene_)
                authority = scene_->IsAuthority();
            // Loop until we find a free ID
            for (;;)
            {
                if (authority)
                    id = component->IsReplicated() ? idGenerator_.AllocateReplicated() : idGenerator_.AllocateLocal();
                else
                    id = component->IsReplicated() ? idGenerator_.AllocateUnacked() : idGenerator_.AllocateLocal();
                if (components_.find(id) == components_.end())
                    break;
            }
        }
        else
        {
            component->SetReplicated(id < UniqueIdGenerator::FIRST_LOCAL_ID);
            // If component ID is specified manually, but it already exists, it is an error. Do not add the component in that case.
            if (components_.find(id) != components_.end())
            {
                LogError("Can not add component: a component with id " + QString::number(id) + " already exists in entity " + ToString());
                return;
            }
            // Whenever a manual replicated ID is assigned, reset the ID generator to the highest value to avoid unnecessary free ID probing in the future
            if (id < UniqueIdGenerator::FIRST_LOCAL_ID)
                idGenerator_.ResetReplicatedId(std::max(id, idGenerator_.id));
        }
        
        QString componentTypeName = component->TypeName();
        componentTypeName.replace(0, 3, "");
        componentTypeName = componentTypeName.toLower();
        // We already have 'name' property in Entity, so ignore "EC_Name" ("name") here.
        if (componentTypeName != "name" && !property(componentTypeName.toStdString().c_str()).isValid())
        {
            QVariant var = QVariant::fromValue<QObject*>(component.get());
            setProperty(componentTypeName.toStdString().c_str(), var);
        }
        
        component->SetNewId(id);
        component->SetParentEntity(this);
        components_[id] = component;
        
        if (change != AttributeChange::Disconnected)
            emit ComponentAdded(component.get(), change == AttributeChange::Default ? component->UpdateMode() : change);
        if (scene_)
            scene_->EmitComponentAdded(this, component.get(), change);
    }
}
开发者ID:katik,项目名称:naali,代码行数:55,代码来源:Entity.cpp

示例11: ValidateCompatible

bool ComponentCollection::ValidateCompatible( const ComponentPtr& component, tstring& error ) const
{
    HELIUM_ASSERT( component->GetSlot() != Reflect::ReservedTypes::Invalid );

    if ( component->GetComponentBehavior() == ComponentBehaviors::Exclusive )
    {
        error = component->GetClass()->m_UIName + TXT( " cannot be added to a(n) " ) + GetClass()->m_UIName + TXT( " because it is an exclusive component." );
        return false;
    }

    return true;
}
开发者ID:andyburke,项目名称:Replicant,代码行数:12,代码来源:ComponentCollection.cpp

示例12: ContainsAttribute

bool ComponentGroup::ContainsAttribute(const QString &name) const
{
    if(components_.empty())
        return false;

    for(uint i = 0; i < components_.size(); i++)
    {
        ComponentPtr comp = components_[i].lock();
        if(comp && comp->GetAttribute(name))
            return true;
    }
    return false;
}
开发者ID:katik,项目名称:naali,代码行数:13,代码来源:ComponentGroup.cpp

示例13: assert

ComponentGroup::ComponentGroup(ComponentPtr component, ECComponentEditor *editor, bool isDynamic):
    editor_(editor),
    isDynamic_(isDynamic)
{
    assert(component);
    // No point to add component to editor cause it's already added in ECBrowser's AddNewComponentToGroup mehtod.
    if(component)
    {
        components_.push_back(ComponentWeakPtr(component));
        name_ = component->Name();
        typeName_ = component->TypeName();
    }
}
开发者ID:katik,项目名称:naali,代码行数:13,代码来源:ComponentGroup.cpp

示例14: ValidateCompatible

bool ComponentCollection::ValidateCompatible( const ComponentPtr& component, std::string& error ) const
{
    HELIUM_ASSERT( component->GetSlot() != NULL );

    if ( component->GetComponentBehavior() == ComponentBehaviors::Exclusive )
    {
        error = *component->GetMetaClass()->m_Name;
        error += TXT( " cannot be added to a(n) " );
        error += *GetMetaClass()->m_Name;
        error += TXT( " because it is an exclusive component." );
        return false;
    }

    return true;
}
开发者ID:kevindqc,项目名称:Helium,代码行数:15,代码来源:ComponentCollection.cpp

示例15: RemoveComponent

void Entity::RemoveComponent(const ComponentPtr &component, AttributeChange::Type change)
{
    if (component)
    {
        ComponentMap::iterator iter = components_.find(component->Id());
        if (iter != components_.end())
        {
            RemoveComponent(iter, change);
        }
        else
        {
            LogWarning("Failed to remove component: " + component->TypeName() + " from entity: " + QString::number(Id()));
        }
    }
}
开发者ID:katik,项目名称:naali,代码行数:15,代码来源:Entity.cpp


注:本文中的ComponentPtr类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。