本文整理汇总了C++中shared_ptr::AllocateCache方法的典型用法代码示例。如果您正苦于以下问题:C++ shared_ptr::AllocateCache方法的具体用法?C++ shared_ptr::AllocateCache怎么用?C++ shared_ptr::AllocateCache使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shared_ptr
的用法示例。
在下文中一共展示了shared_ptr::AllocateCache方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetUp
void SetUp()
{
Mqtt = make_shared<MockMQTTClient>();
ModbusBackend = make_shared<TFakeModbusBackend>();
ModbusServer = make_shared<TModbusServer>(ModbusBackend);
ModbusBackend->AllocateCache(0, 100, 100, 100, 100);
PMQTTConverter conv1 = make_shared<TMQTTIntConverter>(TMQTTIntConverter::SIGNED, 1.0, 2);
observers[0] = make_shared<TGatewayObserver>("/devices/device1/controls/topic1", conv1, Mqtt);
ModbusServer->Observe(observers[0], TStoreType::HOLDING_REGISTER, TModbusAddressRange(0, 1));
Mqtt->Observe(observers[0]);
observers[1] = make_shared<TGatewayObserver>("/devices/device1/controls/topic2", conv1, Mqtt);
ModbusServer->Observe(observers[1], TStoreType::HOLDING_REGISTER, TModbusAddressRange(1, 1));
Mqtt->Observe(observers[1]);
// test a coil to write on "#/on"
PMQTTConverter coil_conv = make_shared<TMQTTDiscrConverter>();
observers[2] = make_shared<TGatewayObserver>("/devices/device1/controls/coil1", coil_conv, Mqtt);
ModbusServer->Observe(observers[2], TStoreType::COIL, TModbusAddressRange(0, 1));
Mqtt->Observe(observers[2]);
observers[3] = make_shared<TGatewayObserver>("/devices/device1/controls/coil2", coil_conv, Mqtt);
ModbusServer->Observe(observers[3], TStoreType::COIL, TModbusAddressRange(1, 1));
Mqtt->Observe(observers[3]);
observers[4] = make_shared<TGatewayObserver>("/devices/device1/controls/coil3", coil_conv, Mqtt);
ModbusServer->Observe(observers[4], TStoreType::COIL, TModbusAddressRange(2, 1));
Mqtt->Observe(observers[4]);
ModbusServer->AllocateCache();
}