Exemple #1
0
ItemProperty *ItemProperty::Create(const String& name)
{
	int q = Factory().Find(name);
	if(q >= 0)
		return (*Factory()[q])();
	return NULL;
}
Exemple #2
0
bool CAddonMgr::GetAddons(const TYPE &type, VECADDONS &addons, bool enabled /* = true */)
{
  CSingleLock lock(m_critSection);
  addons.clear();
  if (!m_cp_context)
    return false;
  cp_status_t status;
  int num;
  std::string ext_point(TranslateType(type));
  cp_extension_t **exts = m_cpluff->get_extensions_info(m_cp_context, ext_point.c_str(), &status, &num);
  for(int i=0; i <num; i++)
  {
    const cp_extension_t *props = exts[i];
    if (IsAddonDisabled(props->plugin->identifier) != enabled)
    {
      AddonPtr addon(Factory(props));
      if (addon)
      {
        if (enabled)
        {
          // if the addon has a running instance, grab that
          AddonPtr runningAddon = addon->GetRunningInstance();
          if (runningAddon)
            addon = runningAddon;
        }
        addons.push_back(addon);
      }
    }
  }
  m_cpluff->release_info(m_cp_context, exts);
  return addons.size() > 0;
}
Exemple #3
0
wxDisplay::wxDisplay(unsigned n)
{
    wxASSERT_MSG( n < GetCount(),
                    wxT("An invalid index was passed to wxDisplay") );

    m_impl = Factory().CreateDisplay(n);
}
Exemple #4
0
CRunScript::CRunScript( CScript& Script, const char* szFormat, char* pStack )
: m_pStack( pStack ),m_ParamTypeLen(0),m_uBufSize(0)
{
	if( szFormat == NULL )
		return;

	CScriptDataMaker Factory( &Script, szFormat );

	do
	{
		CBaseType *pData = Factory.MakeNextData( m_uBufSize );
		Ast( !Factory.IsErr() );	//字符串格式错误
		if( pData!=NULL )
		{
			if( Factory.IsParam() )
			{
				m_vecParam.push_back( pData );	//左边的参数,在list的最后面
				m_ParamTypeLen += pData->GetLen();
			}
			else if( Factory.IsResult() )
			{
				m_vecResult.push_back( pData );
			}
		}
	}
	while( !Factory.IsEnd() );
}
Exemple #5
0
	// Pass real-time arguments to the real-time (dynamic not static) CMs
      HybridCMPolicy(bool static_cm, std::string dynamic_cm, void* t_args)
          : static_flag(static_cm), staticCM()
      {
          if (!static_flag){
		dynamicCM = Factory(dynamic_cm,t_args);
	  }
      }
ClangTidyOptions::OptionMap getCheckOptions(const ClangTidyOptions &Options) {
  clang::tidy::ClangTidyContext Context(
      llvm::make_unique<DefaultOptionsProvider>(ClangTidyGlobalOptions(),
                                                Options));
  ClangTidyASTConsumerFactory Factory(Context);
  return Factory.getCheckOptions();
}
Exemple #7
0
bool CAddonMgr::GetAddons(const TYPE &type, VECADDONS &addons, bool enabled /* = true */, bool bGetDisabledPVRAddons /* = true */)
{
  CStdString xbmcPath = CSpecialProtocol::TranslatePath("special://xbmc/addons");
  CSingleLock lock(m_critSection);
  addons.clear();
  cp_status_t status;
  int num;
  CStdString ext_point(TranslateType(type));
  cp_extension_t **exts = m_cpluff->get_extensions_info(m_cp_context, ext_point.c_str(), &status, &num);
  for(int i=0; i <num; i++)
  {
    const cp_extension_t *props = exts[i];
    bool bIsPVRAddon(TranslateType(props->ext_point_id) == ADDON_PVRDLL);

    if (((bGetDisabledPVRAddons && bIsPVRAddon) || m_database.IsAddonDisabled(props->plugin->identifier) != enabled))
    {
      if (bIsPVRAddon && g_PVRManager.IsStarted())
      {
        AddonPtr pvrAddon;
        if (g_PVRClients->GetClient(props->plugin->identifier, pvrAddon))
        {
          addons.push_back(pvrAddon);
          continue;
        }
      }

      AddonPtr addon(Factory(props));
      if (addon)
        addons.push_back(addon);
    }
  }
  m_cpluff->release_info(m_cp_context, exts);
  return addons.size() > 0;
}
Exemple #8
0
TEST(newFrontendActionFactory, CreatesFrontendActionFactoryFromFactoryType) {
  IndependentFrontendActionCreator Creator;
  std::unique_ptr<FrontendActionFactory> Factory(
      newFrontendActionFactory(&Creator));
  std::unique_ptr<FrontendAction> Action(Factory->create());
  EXPECT_TRUE(Action.get() != nullptr);
}
Exemple #9
0
TEST(newFrontendActionFactory, CreatesFrontendActionFactoryFromFactoryType) {
  IndependentFrontendActionCreator Creator;
  llvm::OwningPtr<FrontendActionFactory> Factory(
    newFrontendActionFactory(&Creator));
  llvm::OwningPtr<FrontendAction> Action(Factory->create());
  EXPECT_TRUE(Action.get() != NULL);
}
Exemple #10
0
bool CAddonMgr::GetAddons(const TYPE &type, VECADDONS &addons, bool enabled /* = true */)
{
  CSingleLock lock(m_critSection);
  addons.clear();
  cp_status_t status;
  int num;
  CStdString ext_point(TranslateType(type));
  cp_extension_t **exts = m_cpluff->get_extensions_info(m_cp_context, ext_point.c_str(), &status, &num);
  for(int i=0; i <num; i++)
  {
    const cp_extension_t *props = exts[i];
    if (m_database.IsAddonDisabled(props->plugin->identifier) != enabled)
    {
      // get a pointer to a running pvrclient if it's already started, or we won't be able to change settings
      if (TranslateType(props->ext_point_id) == ADDON_PVRDLL &&
          enabled &&
          g_PVRManager.IsStarted())
      {
        AddonPtr pvrAddon;
        if (g_PVRClients->GetClient(props->plugin->identifier, pvrAddon))
        {
          addons.push_back(pvrAddon);
          continue;
        }
      }

      AddonPtr addon(Factory(props));
      if (addon)
        addons.push_back(addon);
    }
  }
  m_cpluff->release_info(m_cp_context, exts);
  return addons.size() > 0;
}
Exemple #11
0
AddonPtr CAddonMgr::GetAddonFromDescriptor(const cp_plugin_info_t *info,
                                           const CStdString& type)
{
  if (!info)
    return AddonPtr();

  if (!info->extensions)
  { // no extensions, so we need only the dep information
    return AddonPtr(new CAddon(info));
  }

  // FIXME: If we want to support multiple extension points per addon, we'll need to extend this to not just take
  //        the first extension point (eg use the TYPE information we pass in)

  // grab a relevant extension point, ignoring our xbmc.addon.metadata extension point
  for (unsigned int i = 0; i < info->num_extensions; ++i)
  {
    if (0 != strcmp("xbmc.addon.metadata", info->extensions[i].ext_point_id) &&
        (type.empty() || 0 == strcmp(type.c_str(), info->extensions[i].ext_point_id)))
    { // note that Factory takes care of whether or not we have platform support
      return Factory(&info->extensions[i]);
    }
  }
  return AddonPtr();
}
bool Identifier::Validate(const std::string& input)
{
    if (input.empty()) { return false; }

    const auto id = Factory(input);

    return (0 < id->size());
}
Exemple #13
0
    DiploidGenome *
DiploidGenome::Factory(const Genome *referenceGenome, bool isMale)
{
    //
    // This is just the special case where we use the same reference genome for both parents.
    //
    return Factory(referenceGenome, referenceGenome, isMale);
}
Exemple #14
0
void set_control_alt_text(GG::Wnd* control, const std::string& alt_text)
{
    if (control->BrowseModes().empty())
        control->SetBrowseModeTime(100);
    if (!control->BrowseModes().front().wnd)
        control->SetBrowseInfoWnd(Factory().DefaultBrowseInfoWnd());
    control->SetBrowseText(alt_text);
    
}
// Imports a set of previously exported nodes into a graph
void FEdGraphUtilities::ImportNodesFromText(UEdGraph* DestinationGraph, const FString& TextToImport, /*out*/ TSet<UEdGraphNode*>& ImportedNodeSet)
{
	// Turn the text buffer into objects
	FGraphObjectTextFactory Factory(DestinationGraph);
	Factory.ProcessBuffer(DestinationGraph, RF_Transactional, TextToImport);

	// Fix up pin cross-links, etc...
	FEdGraphUtilities::PostProcessPastedNodes(Factory.SpawnedNodes);

	ImportedNodeSet.Append(Factory.SpawnedNodes);
}
  std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &Compiler,
                                                 StringRef File) override {
    // Insert the current diagnostics engine.
    Context->setDiagnosticsEngine(&Compiler.getDiagnostics());

    // Create the AST consumer.
    ClangTidyASTConsumerFactory Factory(*Context);
    std::vector<std::unique_ptr<ASTConsumer>> Vec;
    Vec.push_back(Factory.CreateASTConsumer(Compiler, File));

    return llvm::make_unique<WrapConsumer>(std::move(Context), std::move(Vec));
  }
ESock::CSubConnectionFlowBase& CRtpBaseFlow::CloneFlowL()
/**
Return the Flow corresponding to the MFlowBinderControl
*/
	{
	LOG( ESockLogExternal::Printf(KESockFlowTag,KRtpBaseFlowSubTag,_L8("CRtpBaseFlow %08x:\t CloneFlowL() "), this));

   	ASSERT(iProtocolIntf);
    TDefaultFlowFactoryQuery query (iProtocolIntf->ControlProviderId(), iSubConnectionProvider.RecipientId());
	ESock::CSubConnectionFlowBase& flow = static_cast<ESock::CSubConnectionFlowBase&>(*(Factory().CreateObjectL(query)));

	return flow;
	}	
Exemple #18
0
bool CAddonMgr::GetAddons(const TYPE &type, VECADDONS &addons, bool enabled /* = true */)
{
  CSingleLock lock(m_critSection);
  addons.clear();
  cp_status_t status;
  int num;
  CStdString ext_point(TranslateType(type));
  cp_extension_t **exts = m_cpluff->get_extensions_info(m_cp_context, ext_point.c_str(), &status, &num);
  for(int i=0; i <num; i++)
  {
    AddonPtr addon(Factory(exts[i]));
    if (addon && m_database.IsAddonDisabled(addon->ID()) != enabled)
      addons.push_back(addon);
  }
  m_cpluff->release_info(m_cp_context, exts);
  return addons.size() > 0;
}
Exemple #19
0
void Automator::addFactory(const std::shared_ptr<BaseActionFactory>& fac){
	if(fac.get() == nullptr) return;

	try {
		mFactory.push_back(Factory());
		mFactory.back().mFactory = fac;
		// Assign everyone to a bucket for random selection.
		const int			size = mFactory.size();
		float				min = 0;
		for(int k = 0; k < size; ++k) {
			Factory&		f = mFactory[k];
			f.mMin = min;
			f.mMax = float(k + 1) / float(size);
			min = f.mMax;
		}
	} catch(std::exception&) {
	}
}
// -----------------------------------------------------------------------------
// CMceComAudioCodec::DoMccEncodeRedundancyL
// -----------------------------------------------------------------------------
//    
void CMceComAudioCodec::DoMccEncodeRedundancyL( 
    CMccCodecInformation& aMccCodec,
    CMceSrvStream& aStream )
    {
    // If red codec is not anymore present in session, disable redundancy
    // from this codec.
    CMceComAudioCodec* searchCodec = Factory().CreateCodecLC( KMceSDPNameRed() );
    
    CMceComCodec* dtmfCodec = aStream.Data().FindCodecL( *searchCodec );
    if ( !dtmfCodec || !dtmfCodec->iIsNegotiated )
        {
        iRedPayloadType = KMcePayloadTypeUndefined;
        iRedCount = 0;
        }
        
    CleanupStack::PopAndDestroy( searchCodec );
    
    User::LeaveIfError( aMccCodec.SetRedundancyPT( iRedPayloadType ) );
	User::LeaveIfError( aMccCodec.SetRedCount( iRedCount ) );
    }
ClangTidyStats
runClangTidy(std::unique_ptr<ClangTidyOptionsProvider> OptionsProvider,
             const tooling::CompilationDatabase &Compilations,
             ArrayRef<std::string> InputFiles,
             std::vector<ClangTidyError> *Errors, ProfileData *Profile) {
  ClangTool Tool(Compilations, InputFiles);
  clang::tidy::ClangTidyContext Context(std::move(OptionsProvider));
  if (Profile)
    Context.setCheckProfileData(Profile);

  ClangTidyDiagnosticConsumer DiagConsumer(Context);

  Tool.setDiagnosticConsumer(&DiagConsumer);

  class ActionFactory : public FrontendActionFactory {
  public:
    ActionFactory(ClangTidyContext &Context) : ConsumerFactory(Context) {}
    FrontendAction *create() override { return new Action(&ConsumerFactory); }

  private:
    class Action : public ASTFrontendAction {
    public:
      Action(ClangTidyASTConsumerFactory *Factory) : Factory(Factory) {}
      std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &Compiler,
                                                     StringRef File) override {
        return Factory->CreateASTConsumer(Compiler, File);
      }

    private:
      ClangTidyASTConsumerFactory *Factory;
    };

    ClangTidyASTConsumerFactory ConsumerFactory;
  };

  ActionFactory Factory(Context);
  Tool.run(&Factory);
  *Errors = Context.getErrors();
  return Context.getStats();
}
// -----------------------------------------------------------------------------
// CMceComAudioCodec::DoMccEncodeComfortNoiseL
// -----------------------------------------------------------------------------
//
void CMceComAudioCodec::DoMccEncodeComfortNoiseL( 
    CMccCodecInformation& aMccCodec,
    CMceSrvStream& aStream )
    {
    // If CN codec is not anymore present in session, disable comfort noise
    // generation from this codec.
    CMceComAudioCodec* searchCodec = Factory().CreateCodecLC( KMceSDPNameCn() );
    
    CMceComCodec* cnCodec = aStream.Data().FindCodecL( *searchCodec );
    
    iComfortNoiseEnabled = cnCodec ? cnCodec->iIsNegotiated : EFalse;
    
    // KPayloadTypeUndefined is used if cn is disabled   
    TUint8 comforNoisePt = 
        iComfortNoiseEnabled ? cnCodec->iPayloadType : KPayloadTypeUndefined;
    
    // If cn is disabled, handle removing the codec here
    if ( !iComfortNoiseEnabled )
    	{
    	aStream.Data().RemoveCodecL( cnCodec );
    	if ( aStream.Data().BoundStream() )
            {
            CMceComCodec* boundCnCodec = 
            	aStream.Data().BoundStreamL().FindCodecL( *searchCodec );
            	
           	aStream.Data().BoundStreamL().RemoveCodecL( boundCnCodec );
            }
			
		// update keep alive payload type and data
	    aMccCodec.SetKeepAlivePT( 120 );
        aMccCodec.SetKeepAliveData( KNullDesC8 );
    	}
    	
    CleanupStack::PopAndDestroy( searchCodec );
    
    // All codecs do not necessarily support cn, ignore errors
    aMccCodec.SetComfortNoiseGeneration( comforNoisePt );
    }
Exemple #23
0
bool CAddonMgr::GetAddons(const TYPE &type, VECADDONS &addons, bool enabled /* = true */)
{
  CStdString xbmcPath = _P("special://xbmc/addons");
  CSingleLock lock(m_critSection);
  addons.clear();
  cp_status_t status;
  int num;
  CStdString ext_point(TranslateType(type));
  cp_extension_t **exts = m_cpluff->get_extensions_info(m_cp_context, ext_point.c_str(), &status, &num);
  for(int i=0; i <num; i++)
  {
    AddonPtr addon(Factory(exts[i]));
    if (addon && addon->Type() == ADDON_PVRDLL && addon->Path().Left(xbmcPath.size()).Equals(xbmcPath))
    {
      if (m_database.IsSystemPVRAddonEnabled(addon->ID()) != enabled)
        addon->Disable();
    }
    if (addon && m_database.IsAddonDisabled(addon->ID()) != enabled)
      addons.push_back(addon);
  }
  m_cpluff->release_info(m_cp_context, exts);
  return addons.size() > 0;
}
Exemple #24
0
AddonPtr CAddonMgr::GetAddonFromDescriptor(const cp_plugin_info_t *info,
                                           const std::string& type)
{
  if (!info)
    return AddonPtr();

  if (!info->extensions && type.empty())
  { // no extensions, so we need only the dep information
    return AddonPtr(new CAddon(info));
  }

  // grab a relevant extension point, ignoring our kodi.addon.metadata extension point
  for (unsigned int i = 0; i < info->num_extensions; ++i)
  {
    if (0 != strcmp("xbmc.addon.metadata" , info->extensions[i].ext_point_id) && //<! backword compatibilty
        0 != strcmp("kodi.addon.metadata" , info->extensions[i].ext_point_id) &&
        (type.empty() || 0 == strcmp(type.c_str(), info->extensions[i].ext_point_id)))
    { // note that Factory takes care of whether or not we have platform support
      return Factory(&info->extensions[i]);
    }
  }
  return AddonPtr();
}
Exemple #25
0
TEST(newFrontendActionFactory, CreatesFrontendActionFactoryFromType) {
  std::unique_ptr<FrontendActionFactory> Factory(
      newFrontendActionFactory<SyntaxOnlyAction>());
  std::unique_ptr<FrontendAction> Action(Factory->create());
  EXPECT_TRUE(Action.get() != nullptr);
}
Exemple #26
0
boost::shared_ptr<GG::Font> DefaultFont()
{ return Factory().DefaultFont(); }
Exemple #27
0
void ItemProperty::Register(const char *name, ItemProperty *(*cr)())
{
	ASSERT(Factory().Find(name) < 0);
	Factory().Add(name, cr);
}
Exemple #28
0
int Draw(int argc, char* argv[], int defenderYCoord[], int defenderXCoord[])
{
	
	Factory factory = Factory();
	Graph graph = Graph();
	
	

	for (int index = 1;index<5;index++) //danger level for each game square
	{
	
	for(int index2=0;index2<20;index2++) 
	{
		for(int index3=0;index3<20;index3++) 
		{
			
			graph.getSquare(index2,index3)->addDanger(int(27-getDistance(index2,index3,defenderXCoord[index],defenderYCoord[index])));
		}
	}
	}
	//extra danger to minimize colisions
	for(int index = 1;index<5;index++)
	{
		int tempX = defenderXCoord[index];
		int tempY = defenderYCoord[index];
		graph.getSquare(tempX,tempY)->addDanger(1000);

	}

	

	graph.pathFinder(defenderXCoord[0],defenderYCoord[0]); //AI pathing for whole gameboard, from any square to coordinates of defender base
	
	
	gameObjectArray[0] = factory.createObject("DefenderBase");
	gameObjectArray[0]->setXPos(defenderXCoord[0]);gameObjectArray[0]->setYPos(defenderYCoord[0]);
	for (int index = 1;index<5;index++)
	{
		gameObjectArray[index] = factory.createObject("Defender");
		gameObjectArray[index]->setXPos(defenderXCoord[index]);gameObjectArray[index]->setYPos(defenderYCoord[index]);
	}
	
	gameObjectArray[5] = factory.createObject("Enemy"); //just make 2 enemies 
	gameObjectArray[5]->setXPos(19);
	gameObjectArray[5]->setYPos(19);
	gameObjectArray[6] = factory.createObject("Enemy");
	gameObjectArray[6]->setXPos(0);
	gameObjectArray[6]->setYPos(0);
	
	
	
	//opengl stuff
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
	glutInitWindowSize(640,480);
	glutCreateWindow("C++ Defender");
	initGL(640,480);
	glutIdleFunc(update); 
	glutDisplayFunc(render);
	glutKeyboardFunc(keyboard);
	glutSpecialFunc(special);
	glutMouseFunc(mouse);
	glutMainLoop();
}
Exemple #29
0
TEST(newFrontendActionFactory, CreatesFrontendActionFactoryFromType) {
  llvm::OwningPtr<FrontendActionFactory> Factory(
    newFrontendActionFactory<SyntaxOnlyAction>());
  llvm::OwningPtr<FrontendAction> Action(Factory->create());
  EXPECT_TRUE(Action.get() != NULL);
}
Exemple #30
0
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  int priority =
    (ACE_Sched_Params::priority_min (ACE_SCHED_FIFO)
     + ACE_Sched_Params::priority_max (ACE_SCHED_FIFO)) / 2;
  priority = ACE_Sched_Params::next_priority (ACE_SCHED_FIFO,
                                                  priority);
  // Enable FIFO scheduling, e.g., RT scheduling class on Solaris.

  if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO,
                                              priority,
                                              ACE_SCOPE_PROCESS)) != 0)
    {
      if (ACE_OS::last_error () == EPERM)
        {
          ACE_DEBUG ((LM_DEBUG,
                      "server (%P|%t): user is not superuser, "
                      "test runs in time-shared class\n"));
        }
      else
        ACE_ERROR ((LM_ERROR,
                    "server (%P|%t): sched_params failed\n"));
    }

  try
    {
      CORBA::ORB_var orb =
        CORBA::ORB_init (argc, argv);

      CORBA::Object_var poa_object =
        orb->resolve_initial_references("RootPOA");

      if (CORBA::is_nil (poa_object.in ()))
        ACE_ERROR_RETURN ((LM_ERROR,
                           " (%P|%t) Unable to initialize the POA.\n"),
                          1);

      PortableServer::POA_var root_poa =
        PortableServer::POA::_narrow (poa_object.in ());

      PortableServer::POAManager_var poa_manager =
        root_poa->the_POAManager ();

      if (parse_args (argc, argv) != 0)
        return 1;

      Factory *factory_impl;
      ACE_NEW_RETURN (factory_impl,
                      Factory (orb.in ()),
                      1);
      PortableServer::ServantBase_var owner_transfer(factory_impl);

      Test::Factory_var factory =
        factory_impl->_this ();

      CORBA::String_var ior =
        orb->object_to_string (factory.in ());

      // If the ior_output_file exists, output the ior to it
      FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
      if (output_file == 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "Cannot open output file for writing IOR: %s",
                           ior_output_file),
                          1);
      ACE_OS::fprintf (output_file, "%s", ior.in ());
      ACE_OS::fclose (output_file);

      poa_manager->activate ();

      orb->run ();

      ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n"));

      root_poa->destroy (1, 1);

      orb->destroy ();
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Exception caught:");
      return 1;
    }

  return 0;
}