示例#1
0
static std::vector<std::shared_ptr<CoreContext>> create(void) {
  // Create a bunch of subcontexts from here
  std::vector<std::shared_ptr<CoreContext>> contexts(n);
  for (size_t i = n; i--;)
    contexts[i] = AutoCreateContext();
  return contexts;
}
示例#2
0
void MythFEXML::GetActionListTest(HTTPRequest *pRequest)
{
    InitActions();

    pRequest->m_eResponseType = ResponseTypeHTML;
    pRequest->m_mapRespHeaders[ "Cache-Control" ] = "no-cache=\"Ext\", max-age = 5000";

    QTextStream stream( &pRequest->m_response );

    stream <<
        "<html>\n" << PROCESS_ACTION <<
        "  <body>\n" << HIDDEN_IFRAME;

    QHashIterator<QString,QStringList> contexts(m_actionDescriptions);
    while (contexts.hasNext())
    {
        contexts.next();
        QStringList actions = contexts.value();
        foreach (QString action, actions)
        {
            QStringList split = action.split(",");
            if (split.size() == 2)
            {
                stream <<
                    QString("    <div>%1&nbsp;<input type=\"button\" value=\"%2\" onClick=\"postaction('%2');\"></input>&nbsp;%3</div>\n")
                        .arg(contexts.key()).arg(split[0]).arg(split[1]);
            }
        }
    }
示例#3
0
WebContext::~WebContext()
{
    ASSERT(contexts().find(this) != notFound);
    contexts().remove(contexts().find(this));

    removeLanguageChangeObserver(this);

    m_messageReceiverMap.invalidate();

    WebContextSupplementMap::const_iterator it = m_supplements.begin();
    WebContextSupplementMap::const_iterator end = m_supplements.end();
    for (; it != end; ++it) {
        it->value->contextDestroyed();
        it->value->clearContext();
    }

    m_iconDatabase->invalidate();
    m_iconDatabase->clearContext();
    
#if ENABLE(NETSCAPE_PLUGIN_API)
    m_pluginSiteDataManager->invalidate();
    m_pluginSiteDataManager->clearContext();
#endif

    invalidateCallbackMap(m_dictionaryCallbacks);

    platformInvalidateContext();

#if ENABLE(NETSCAPE_PLUGIN_API)
    m_pluginInfoStore.setClient(0);
#endif

#ifndef NDEBUG
    webContextCounter.decrement();
#endif
}
示例#4
0
ThreadPool::ThreadPool(size_t size)
	: stop(false)
{
	threads.resize(size);
	std::vector<SDL_GLContext> contexts(size + 1);
	for(size_t i = 0; i < contexts.size(); i++)
	{
		contexts[i] = SDL_GL_CreateContext(window);
		assert(contexts[i] != nullptr);
	}
	for(size_t i = 0; i < threads.size(); i++)
	{
		threads[i] = std::thread(Worker(i, *this, contexts[i]));
	}
}
示例#5
0
void TextLanguage::clearCustomDefs()
{
	for (auto i = functions_.begin(); i != functions_.end();)
	{
		i->clearCustomContexts();

		// Remove function if only contexts were custom
		if (i->contexts().empty())
			i = functions_.erase(i);
		else
			++i;
	}

	for (auto a = 0; a < 4; a++)
		word_lists_custom_[a].list.clear();
}
示例#6
0
indri::server::QueryServerResponse* indri::server::LocalQueryServer::runQuery( std::vector<indri::lang::Node*>& roots, int resultsRequested, bool optimize ) {

  indri::lang::TreePrinterWalker printer;

  // use UnnecessaryNodeRemover to get rid of window nodes, ExtentAnd nodes and ExtentOr nodes
  // that only have one child and LengthPrior nodes where the exponent is zero
  indri::lang::ApplyCopiers<indri::lang::UnnecessaryNodeRemoverCopier> unnecessary( roots );

  // run the contextsimplecountcollectorcopier to gather easy stats
  indri::lang::ApplyCopiers<indri::lang::ContextSimpleCountCollectorCopier> contexts( unnecessary.roots(), _repository );

  // use frequency-only nodes where appropriate
  indri::lang::ApplyCopiers<indri::lang::FrequencyListCopier> frequency( contexts.roots(), _cache );

  // fold together any nested weight nodes
  indri::lang::ApplyCopiers<indri::lang::WeightFoldingCopier> weight( frequency.roots() );

  // make all this into a dag
  indri::lang::ApplySingleCopier<indri::lang::DagCopier> dag( weight.roots(), _repository );

  std::vector<indri::lang::Node*>& networkRoots = dag.roots();
  // turn off optimization if called with optimize == false
  // turn off optimization if called the Parameter optimize == false
  if( !optimize || !_optimizeParameter ) {
    // we may be asked not to perform optimizations that might
    // drastically change the structure of the tree; for instance,
    // annotation queries may ask for this
    networkRoots = contexts.roots();
  }
  /*
    indri::lang::TreePrinterWalker printer;
    indri::lang::ApplyWalker<indri::lang::TreePrinterWalker> printTree(networkRoots, &printer);
  */

  // build an inference network
  indri::infnet::InferenceNetworkBuilder builder( _repository, _cache, resultsRequested, _maxWildcardMatchesPerTerm );
  indri::lang::ApplyWalker<indri::infnet::InferenceNetworkBuilder> buildWalker( networkRoots, &builder );

  indri::infnet::InferenceNetwork* network = builder.getNetwork();
  indri::infnet::InferenceNetwork::MAllResults result;
  result = network->evaluate();

  return new indri::server::LocalQueryServerResponse( result );
}
示例#7
0
std::string Stencil::page(void) const {
	// Get base document
	Html::Document doc = Component_page_doc<Stencil>(*this);
	Html::Node head = doc.find("head");
	Html::Node body = doc.find("body");

	// Extra metadata
	head.append("meta",{
		{"itemprop","contexts"},
		{"content",join(contexts(),",")}
	});

	// Add stencil content to the main element and give #content id
	auto main = body.select("main");
	main.attr("id","content");
	main.append(*this);

	return doc.dump(false);
}
示例#8
0
DTC::FrontendActionList* Frontend::GetActionList(const QString &Context)
{
    DTC::FrontendActionList *list = new DTC::FrontendActionList();

    InitialiseActions();

    QHashIterator<QString,QStringList> contexts(gActionDescriptions);
    while (contexts.hasNext())
    {
        contexts.next();
        if (!Context.isEmpty() && contexts.key() != Context)
            continue;

        // TODO can we keep the context data with QMap<QString, QStringList>?
        QStringList actions = contexts.value();
        foreach (QString action, actions)
        {
            QStringList split = action.split(",");
            if (split.size() == 2)
                list->ActionList().insert(split[0], split[1]);
        }
    }
示例#9
0
WebContext::WebContext(WebContextConfiguration configuration)
    : m_processModel(ProcessModelSharedSecondaryProcess)
    , m_webProcessCountLimit(UINT_MAX)
    , m_haveInitialEmptyProcess(false)
    , m_processWithPageCache(0)
    , m_defaultPageGroup(WebPageGroup::createNonNull())
    , m_injectedBundlePath(configuration.injectedBundlePath)
    , m_downloadClient(std::make_unique<API::DownloadClient>())
    , m_historyClient(std::make_unique<API::HistoryClient>())
    , m_visitedLinkProvider(VisitedLinkProvider::create())
    , m_visitedLinksPopulated(false)
    , m_plugInAutoStartProvider(this)
    , m_alwaysUsesComplexTextCodePath(false)
    , m_shouldUseFontSmoothing(true)
    , m_cacheModel(CacheModelDocumentViewer)
    , m_memorySamplerEnabled(false)
    , m_memorySamplerInterval(1400.0)
    , m_storageManager(StorageManager::create(configuration.localStorageDirectory))
#if USE(SOUP)
    , m_initialHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicyOnlyFromMainDocumentDomain)
#endif
    , m_shouldUseTestingNetworkSession(false)
    , m_processTerminationEnabled(true)
#if ENABLE(NETWORK_PROCESS)
    , m_usesNetworkProcess(false)
#endif
#if USE(SOUP)
    , m_ignoreTLSErrors(true)
#endif
    , m_memoryCacheDisabled(false)
{
    platformInitialize();

    addMessageReceiver(Messages::WebContext::messageReceiverName(), *this);
    addMessageReceiver(WebContextLegacyMessages::messageReceiverName(), *this);

    // NOTE: These sub-objects must be initialized after m_messageReceiverMap..
    m_iconDatabase = WebIconDatabase::create(this);
#if ENABLE(NETSCAPE_PLUGIN_API)
    m_pluginSiteDataManager = WebPluginSiteDataManager::create(this);
#endif // ENABLE(NETSCAPE_PLUGIN_API)

    addSupplement<WebApplicationCacheManagerProxy>();
    addSupplement<WebCookieManagerProxy>();
    addSupplement<WebGeolocationManagerProxy>();
    addSupplement<WebKeyValueStorageManager>();
    addSupplement<WebMediaCacheManagerProxy>();
    addSupplement<WebNotificationManagerProxy>();
    addSupplement<WebResourceCacheManagerProxy>();
#if ENABLE(SQL_DATABASE)
    addSupplement<WebDatabaseManagerProxy>();
#endif
#if USE(SOUP)
#if ENABLE(CUSTOM_PROTOCOLS)
    addSupplement<WebSoupCustomProtocolRequestManager>();
#else
    addSupplement<WebSoupRequestManagerProxy>();
#endif
#endif
#if ENABLE(BATTERY_STATUS)
    addSupplement<WebBatteryManagerProxy>();
#endif

    contexts().append(this);

    addLanguageChangeObserver(this, languageChanged);

#if !LOG_DISABLED
    WebCore::initializeLoggingChannelsIfNecessary();
    WebKit::initializeLogChannelsIfNecessary();
#endif // !LOG_DISABLED

#if ENABLE(NETSCAPE_PLUGIN_API)
    m_pluginInfoStore.setClient(this);
#endif

#ifndef NDEBUG
    webContextCounter.increment();
#endif
}
示例#10
0
const Vector<WebContext*>& WebContext::allContexts()
{
    return contexts();
}