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


C++ Component类代码示例

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


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

示例1: searchByName

bool GUI::removeComponent (string name)
{
    Component *toDelete = searchByName (name, this->root);
    if (toDelete)
    {
        Component *temp = toDelete->getParent();
        for (unsigned int i = 0; i < temp->getChildren().size(); i++)
        {
            if (temp->getChildren()[i] == toDelete)
            {
                temp->getChildren().erase(temp->getChildren().begin() + i);
                subtractArea (temp, toDelete->getAreaUsage());
                return true;
            }
        }
    }
    else
    {
        return false;
    }
}
开发者ID:larcohex,项目名称:university,代码行数:21,代码来源:gui.cpp

示例2: main

int main(int argc, const char *argv[])
{
    Component* cpn = new Composite();
    cpn->add(new Leaf1);
    cpn->add(new Leaf2);

    Component* c = new Composite();
    c->add(new Leaf2);
    c->add(new Leaf2);

    cpn->add(c);
    cpn->draw();
    return 0;
}
开发者ID:usbuild,项目名称:designpatterns,代码行数:14,代码来源:main.cpp

示例3: pokeLoc

void pokeLoc(Layer& layer, int l, int x, int y, bool charge, char dir)
{
    Component* c = &layer.get(l)->get(x, y);
    if (c->getID() == "WIRE")
        invokeWire(layer, l, x, y, charge);
    else if (c->getID() == "LIGHT")
        invokeLight(layer, l, x, y, charge);
    else if (c->getID() == "VERT")
        invokeVert(layer, l, x, y, charge);
    else if (c->getID() == "NOT" && dir == 'l')
        invokeNot(layer, l, x, y, charge);
    else if ((dir == 'd' || dir == 'u') && isGate(c->getID()))
        invokeGate(layer, l, x, y, charge, dir);
}
开发者ID:person124,项目名称:CSI-240-Logic-Gates,代码行数:14,代码来源:execute.cpp

示例4: searchComponent

string ERModel::searchForeignKey( int foreignKeyEntityID )
{
	Component* foreignKeyEntity = searchComponent(foreignKeyEntityID);
	vector<Component*> attributeSet = searchSpecificTypeComponentSet(PARAMETER_ATTRIBUTE, foreignKeyEntity->getConnections());
	string isFKString;

	for(int i = 0; i < attributeSet.size(); i++)
	{
		if (static_cast<NodeAttribute*>(attributeSet[i])->getIsPrimaryKey())
			isFKString += attributeSet[i]->getText() + TEXT_COMMASPACE;
	}

	// 刪除最後一個", "並將格式放入string中
	if (isFKString != PARAMETER_NULL)
	{
		isFKString = isFKString.substr(PARAMETER_STRINGBEGIN, isFKString.size() - PARAMETER_ADJUSTSTRINGSIZE);
		isFKString = TEXT_GETERDIAGRAM_FK + isFKString + TEXT_GETERDIAGRAM_ENDKEY;
	}
	return isFKString;
}
开发者ID:jasons8021,项目名称:POSD_ERDiagram,代码行数:20,代码来源:ERModel.cpp

示例5: IsParent

void ASI::RemoveFromLayout(CRef& cref, CRef& layout)
{
    Component* pLayoutComponent = layout.GetInstance();
    if (pLayoutComponent != NULL)
    {
        int funcSet  = pLayoutComponent->GetFuncSet("{f742f223-bb7b-48f0-92a8-81702e14de16}");
        int emitter  = pLayoutComponent->GetEmitter("{b11a0db4-cb96-4bf6-9631-fd96f20ea6ab}");
        int receiver = pLayoutComponent->GetReceiver("{6a7ab00f-1ab4-4324-9eb4-e614bfca4a16}");

        if ((funcSet  != -1) &&
            (emitter  != -1) &&
            (receiver != -1))
        {
            Component* pComponent = cref.GetInstance();
            if (pComponent != NULL)
            {
                if (pComponent->m_pData->inLayout &&
                    IsParent(pLayoutComponent, pComponent))
                {
                    /*
                     * Tell the layout component to remove
                     * the item with the given CRef id.
                     */
                    DRef dref = NewData(BOI_STD_D(Int));
                    *dref.GetWriteInstance<int>() = cref.Id();
                    pLayoutComponent->CallFunc(funcSet, 2, dref, true);

                    DisconnectFromReceiver(pLayoutComponent, emitter, cref);
                    DisconnectFromReceiver(pComponent, BOI_STD_E(ParentBoundingBox), layout);

                    pComponent->m_pData->inLayout = false;

                    CRef invalidCRef;
                    pComponent->SetParent(invalidCRef);
                }

                cref.ReleaseInstance();
            }
        }

        layout.ReleaseInstance();
    }
}
开发者ID:romoadri21,项目名称:boi,代码行数:43,代码来源:ASI.cpp

示例6: createFileCreationOptionComboBox

static void createFileCreationOptionComboBox (Component& setupComp,
                                              OwnedArray<Component>& itemsCreated,
                                              const char** types)
{
    ComboBox* c = new ComboBox();
    itemsCreated.add (c);
    setupComp.addChildAndSetID (c, "filesToCreate");

    const char* fileOptions[] = { "Create a Main.cpp file",
                                  "Create a Main.cpp file and a basic window",
                                  "Don't create any files", 0 };

    c->addItemList (StringArray (fileOptions), 1);
    c->setSelectedId (1, false);

    Label* l = new Label (String::empty, "Files to Auto-Generate:");
    l->attachToComponent (c, true);
    itemsCreated.add (l);

    c->setBounds ("parent.width / 2 + 160, 10, parent.width - 10, top + 22");
}
开发者ID:lucem,项目名称:JUCE,代码行数:21,代码来源:jucer_NewProjectWizard.cpp

示例7: componentMovedOrResized

void Label::componentMovedOrResized (Component& component, bool /*wasMoved*/, bool /*wasResized*/)
{
    const Font f (getLookAndFeel().getLabelFont (*this));

    if (leftOfOwnerComp)
    {
        setSize (jmin (f.getStringWidth (textValue.toString()) + 8, component.getX()),
                 component.getHeight());

        setTopRightPosition (component.getX(), component.getY());
    }
    else
    {
        setSize (component.getWidth(),
                 8 + roundToInt (f.getHeight()));

        setTopLeftPosition (component.getX(), component.getY() - getHeight());
    }
}
开发者ID:gsenna,项目名称:cabbage,代码行数:19,代码来源:juce_Label.cpp

示例8: GetNumAttributes

Node* Node::CloneRecursive(Node* parent, SceneResolver& resolver, CreateMode mode)
{
    // Create clone node
    Node* cloneNode = parent->CreateChild(0, (mode == REPLICATED && id_ < FIRST_LOCAL_ID) ? REPLICATED : LOCAL);
    resolver.AddNode(id_, cloneNode);

    // Copy attributes
    unsigned numAttributes = GetNumAttributes();
    for (unsigned j = 0; j < numAttributes; ++j)
        cloneNode->SetAttribute(j, GetAttribute(j));

    // Clone components
    for (Vector<SharedPtr<Component> >::ConstIterator i = components_.Begin(); i != components_.End(); ++i)
    {
        Component* component = *i;
        Component* cloneComponent = cloneNode->CreateComponent(component->GetType(), (mode == REPLICATED && component->GetID() <
            FIRST_LOCAL_ID) ? REPLICATED : LOCAL);
        if (!cloneComponent)
        {
            LOGERROR("Could not clone component " + component->GetTypeName());
            continue;
        }
        resolver.AddComponent(component->GetID(), cloneComponent);

        numAttributes = component->GetNumAttributes();
        for (unsigned j = 0; j < numAttributes; ++j)
            cloneComponent->SetAttribute(j, component->GetAttribute(j));
    }

    // Clone child nodes recursively
    for (Vector<SharedPtr<Node> >::ConstIterator i = children_.Begin(); i != children_.End(); ++i)
    {
        Node* node = *i;
        node->CloneRecursive(cloneNode, resolver, mode);
    }

    return cloneNode;
}
开发者ID:eberan,项目名称:urho3d_old_mirror,代码行数:38,代码来源:Node.cpp

示例9: NewData

void ASI::AddToLayout(CRef& cref, CRef& layout)
{
    Component* pLayoutComponent = layout.GetInstance();
    if (pLayoutComponent != NULL)
    {
        int funcSet  = pLayoutComponent->GetFuncSet("{f742f223-bb7b-48f0-92a8-81702e14de16}");
        int emitter  = pLayoutComponent->GetEmitter("{b11a0db4-cb96-4bf6-9631-fd96f20ea6ab}");
        int receiver = pLayoutComponent->GetReceiver("{6a7ab00f-1ab4-4324-9eb4-e614bfca4a16}");

        if ((funcSet  != -1) &&
            (emitter  != -1) &&
            (receiver != -1))
        {
            Component* pComponent = cref.GetInstance();
            if (pComponent != NULL)
            {
                if ((!pComponent->m_pData->inLayout) &&
                    (pComponent != pLayoutComponent))
                {
                    pComponent->SetParent(layout);

                    /*
                     * Tell the layout component to add
                     * a new item with the given CRef id.
                     */
                    DRef dref = NewData(BOI_STD_D(Int));
                    *dref.GetWriteInstance<int>() = cref.Id();
                    pLayoutComponent->CallFunc(funcSet, 1, dref, true);

                    ConnectToReceiver(pLayoutComponent, emitter, cref, BOI_STD_R(SetPosition));
                    ConnectToReceiver(pComponent, BOI_STD_E(ParentBoundingBox), layout, receiver);

                    pComponent->m_pData->inLayout = true;
                }

                cref.ReleaseInstance();
            }
        }

        layout.ReleaseInstance();
    }
}
开发者ID:romoadri21,项目名称:boi,代码行数:42,代码来源:ASI.cpp

示例10: while

bool CompositionObj::hasChild(Component child)
{
    std::cout << this->getName() << "<->" << child->getName() << std::endl;
    Component c = child;
//    auto spec = std::dynamic_pointer_cast<SpecializedComponentObjBase>(c);
    //while ((std::shared_ptr<SpecializedComponentObjBase> spec = std::dynamic_pointer_cast<SpecializedComponentObjBase>(c)) && spec.get()) {
    SpecializedComponentBase spec;

    //TODO try this
    //for(auto spec = std::dynamic_pointer_cast<SpecializedComponentObjBase>(c); spec.get(); c=spec->getOrginal());
    while ((spec = std::dynamic_pointer_cast<SpecializedComponentObjBase>(c)) && spec.get()) {
        c = spec->getOrginal();
    }

    for (auto ch : getChildren()) {
        std::cout << "\t Child: " << ch.second->getName() << std::endl;
        if (ch.second == c || (ch.second == child)) {
            return true;
        }
    }
    return false;
}
开发者ID:Wushaowei001,项目名称:constrained_based_networks,代码行数:22,代码来源:Composition.cpp

示例11: call_optional_or_variant

        bool call_optional_or_variant(Component const& component, mpl::true_) const
        {
            // If Attribute is an optional, then create an attribute for the Component
            // with the type optional::value_type. If the expected attribute is unused type,
            // use it instead.
            typedef typename
                traits::attribute_of<Component, Context, Iterator>::type
            expected_type;

            typename mpl::if_<
                is_same<expected_type, unused_type>,
                unused_type,
                typename Attribute::value_type>::type
            val;

            if (component.parse(first, last, context, skipper, val))
            {
                traits::assign_to(val, attr);
                return true;
            }
            return false;
        }
开发者ID:CasparCG,项目名称:Client,代码行数:22,代码来源:alternative_function.hpp

示例12: Component

bool DataModel::addComponent(QString _id, QString _name, double _value, QString _unit, QString _des) {
    if(!isLoad) {
        logger.reportError(tr("Attempt to modify before load"));
        return false;
    }

    if(checkComponentId(_id)+1) {
        logger.reportError(tr("Component Id ")+_id+tr(" has existed"));
        return false;
    }
    Component *c = new Component();
    c->setId(_id); c->setName(_name); c->setValue(_value); c->setUnit(_unit); c->setDescription(_des);
    dat->addComponent(c);

    isModified = true;
    return true;
}
开发者ID:hoolheart,项目名称:ZtSensTolr,代码行数:17,代码来源:datamodel.cpp

示例13: neighbourPos

int  FormSegmentator::neighbourPos(const SquarePos &pos, int diagramNum) const
{
	int num = -1;
	for (int i = 0; i < mAllComponents.size(); i ++) {
		Component diagram = mAllComponents.at(i);
		if ((i != diagramNum && (num >= 0 &&
								 (pos.dist(diagram.at(0)) <= neighbourhoodRad ||
								  pos.dist(diagram.back()) <= neighbourhoodRad))) ||
				(pos.dist(diagram.at(0)) <= neighbourhoodRad &&
				 pos.dist(diagram.back()) <= neighbourhoodRad))
		{
			return -1;
		}
		if (diagramNum != i && (pos.dist(diagram.at(0)) <= neighbourhoodRad ||
								pos.dist(diagram.back()) <= neighbourhoodRad))
		{
			num = i;
		}
	}
	return num;
}
开发者ID:AlexeyKor,项目名称:tools,代码行数:21,代码来源:formsegmentator.cpp

示例14: ConfiguredComponent

 ConfiguredComponent(Component underlaying_component, std::map<std::string, Gecode::FloatVar> f, std::map<std::string, Gecode::BoolVar> b, std::map<std::string, Gecode::IntVar> i,
                     std::map<std::string, Gecode::IntVar> s, std::shared_ptr<std::map<std::string, int>> sh)
     : underlaying_name(underlaying_component->getName())
 {
     component = underlaying_component;
     // std::cout << "Debug for " << underlaying_component->getName() << std::endl;
     // string_name << component->toString() << std::endl;
     for (auto j : i) {
         // std::cout << "\t-" << j.first << j.second << std::endl;
         int_config.push_back(Config<int>{j.second.min(), j.second.max(), j.first});
     }
     for (auto j : f) {
         double_config.push_back(Config<double>{j.second.min(), j.second.max(), j.first});
     }
     for (auto j : b) {
         bool_config.push_back(Config<bool>{(bool)j.second.min(), (bool)j.second.max(), j.first});
     }
     for (auto e : s) {
         std::string config_value = "ERR (FATAL)";
         bool valid = false;
         if (e.second.assigned()) {
             auto id = e.second.val();
             for (auto v : *sh) {
                 if (v.second == id) {
                     config_value = v.first;
                     valid = true;
                     break;
                 }
             }
         } else {
             valid = true;
             config_value = "<unassigned>";
         }
         assert(valid);
         string_config.push_back({e.first, config_value});
     }
 }
开发者ID:Wushaowei001,项目名称:constrained_based_networks,代码行数:37,代码来源:InstanceSolution.hpp

示例15: TEST

TEST(EntityTests, OverridesDuplicateSpatials) {
    Entity entity;

    Component* componentA = new Component();
    componentA->setAttr("type", "spatial");
    componentA->setAttr("x", 1);
    entity.addComponent(componentA);

    Component* componentB = new Component();
    componentB->setAttr("type", "spatial");
    componentB->setAttr("x", 2);
    entity.addComponent(componentB);

    entity.prefabOverride();

    ASSERT_EQ(entity.components().count(), 1);
    ASSERT_EQ(entity.components().first()->attr("x").intValue(), 1);
}
开发者ID:nkostelnik,项目名称:WonderPants,代码行数:18,代码来源:EntityTests.cpp


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