ContainerPtr ContainerProvider::getContainer(const std::string& name) const { auto i = _containers.find(name); if (i == _containers.end()) return ContainerPtr(); return i->second; }
void Game::processOpenContainer(int containerId, const ItemPtr& containerItem, const std::string& name, int capacity, bool hasParent, const std::vector<ItemPtr>& items) { ContainerPtr previousContainer = getContainer(containerId); ContainerPtr container = ContainerPtr(new Container(containerId, capacity, name, containerItem, hasParent)); m_containers[containerId] = container; container->onAddItems(items); container->onOpen(previousContainer); if(previousContainer) previousContainer->onClose(); }
void Game::processOpenContainer(int containerId, const ItemPtr& containerItem, const std::string& name, int capacity, bool hasParent, const std::vector<ItemPtr>& items, bool isUnlocked, bool hasPages, int containerSize, int firstIndex) { ContainerPtr previousContainer = getContainer(containerId); ContainerPtr container = ContainerPtr(new Container(containerId, capacity, name, containerItem, hasParent, isUnlocked, hasPages, containerSize, firstIndex)); m_containers[containerId] = container; container->onAddItems(items); // we might want to close a container here enableBotCall(); container->onOpen(previousContainer); disableBotCall(); if(previousContainer) previousContainer->onClose(); }
future<ContainerPtr> ContentModuleManager::LoadContentAtPath(const string& path, launch policy) { std::unique_lock<std::mutex>(_mutex); if (_known_modules.empty()) { // special case for when we don't have any Content Modules to rely on for an initialized result return make_ready_future<ContainerPtr>(ContainerPtr(nullptr)); } future<ContainerPtr> result; bool found = false; for (auto& item : _known_modules) { auto modulePtr = item.second; result = modulePtr->ProcessFile(path, policy); // check the state of the future -- has it already been set? future_status status = result.wait_for(std::chrono::system_clock::duration(0)); /* Following 'if-else' clauses which have 'result.then' make a malfunction while Content Module processing for DRM implementation. But there is no problem to handle both plain and encrypted resources with next clauses which are detouring result.then */ /* // if it's ready, the call to get() will never block if (status == future_status::ready) { // unpack the future ContainerPtr container = result.get(); if (bool(container)) { // we have a valid container already result = make_ready_future(container); result = result.then([modulePtr](future<ContainerPtr> fut) { ContainerPtr ptr = fut.get(); modulePtr->RegisterContentFilters(); return ptr; }); break; } else { continue; // no container, so try the next module } } else { // it must be 'timeout' or 'deferred', which means the module is attempting to process the file // we take this to mean that we stop looking and return the result result = result.then([modulePtr](future<ContainerPtr> fut) { ContainerPtr ptr = fut.get(); modulePtr->RegisterContentFilters(); return ptr; }); break; } */ if (status == future_status::ready) { ContainerPtr container = result.get(); if (bool(container)) { modulePtr->RegisterContentFilters(); found = true; break; } else { continue; } } else { modulePtr->RegisterContentFilters(); found = true; break; } } if ( !found && result.__future_ == nullptr ) { throw std::invalid_argument("Unsupported DRM EPUB"); } return result; }
void CEndDevice::AddDataChannel(const std::string &_sDataChannel) { mapDataContainer.insert(std::pair<std::string,ContainerPtr>(_sDataChannel,ContainerPtr(new std::vector<EDDATA>))); std::cout << "adding channel " << _sDataChannel << std::endl; }