本文整理汇总了C++中Composition::getSelfInstance方法的典型用法代码示例。如果您正苦于以下问题:C++ Composition::getSelfInstance方法的具体用法?C++ Composition::getSelfInstance怎么用?C++ Composition::getSelfInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Composition
的用法示例。
在下文中一共展示了Composition::getSelfInstance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: has_instance_with_his_parent_component
void CompositionTest::has_instance_with_his_parent_component()
{
ICompositionInstance *compInstance = new CompositionInstanceMock();
Composition *composition = new Composition(compInstance);
CPPUNIT_ASSERT_EQUAL(compInstance, composition->getSelfInstance());
CompositionFactory::dispose(composition);
}
示例2: delete_selfInstance_port_removes_dependant_connections
void CompositionTest::delete_selfInstance_port_removes_dependant_connections()
{
Component *comp1 = ComponentFactory::produce("comp1", {"in"}, {"out"});
Composition *composition = new Composition(new CompositionInstance(comp1));
comp1->setImplementation(composition);
const auto inst = composition->getSelfInstance();
auto portIn = inst->getPorts()[0];
auto portOut = inst->getPorts()[1];
auto connection = ConnectionFactory::produce(portIn, portOut);
composition->getConnections().add(connection);
ComponentPort *port = comp1->getPorts()[0];
CPPUNIT_ASSERT_EQUAL(size_t(1), composition->getConnections().size());
comp1->getPorts().remove(port);
CPPUNIT_ASSERT_EQUAL(size_t(0), composition->getConnections().size());
ComponentFactory::dispose(comp1);
}