示例#1
0
    void Entresol::Construct(   const Physics::ManagerConstructionInfo& PhysicsInfo,
                                const String& SceneType,
                                const String& EngineDataPath,
                                const String& LogFileName,
                                const std::vector <ManagerBase*>& ManagerToBeAdded )

    {
        //Add default manager factories
        AddAllEngineDefaultManagerFactories();
        //Set some sane Defaults for some values
        this->ManualLoopBreak = 0;

        SetupOgre();
        SetupLogging(LogFileName);

        // Load the necessary plugins.
        SubSystemParticleFXPlugin = new Ogre::ParticleFXPlugin();
        Ogre::Root::getSingleton().installPlugin(SubSystemParticleFXPlugin);

        //add each manager that was passed in to the manager list
        for(std::vector<ManagerBase*>::const_iterator iter = ManagerToBeAdded.begin(); iter!= ManagerToBeAdded.end(); iter++)
            { this->AddManager(*iter); }

        //Dummy param list so we can use the auto-added manager types if needed
        NameValuePairList Params;
        //Create and add any managers that have not been taken care of yet.
        if(this->GetActorManager()==0)
            { this->AddManager(new ActorManager()); }
        if(this->GetAreaEffectManager()==0)
            { this->AddManager(new AreaEffectManager()); }
        if(this->GetResourceManager()==0)
            { this->AddManager(new ResourceManager(EngineDataPath)); }
        if(this->GetGraphicsManager()==0)
            { this->AddManager(new Graphics::GraphicsManager()); }
        if(this->GetEventManager()==0)
            { this->AddManager(new EventManager()); }
        if(this->GetInputManager()==0)
            { this->AddManager(new Input::InputManager()); }
        if(this->GetPhysicsManager()==0)
            { this->AddManager(new Physics::PhysicsManager(PhysicsInfo)); }
        if(this->GetSceneManager()==0)
            { this->AddManager(new SceneManager(SceneType)); }
        if(this->GetUIManager()==0)
            { this->AddManager(new UI::UIManager()); }
        if(this->GetMeshManager()==0)
            { this->AddManager(new MeshManager()); }
        if(this->GetCollisionShapeManager()==0)
            { this->AddManager(new Physics::CollisionShapeManager()); }
        if(this->GetCameraManager()==0)
            { this->AddManager(new CameraManager()); }
        #ifdef ENABLE_OALS_AUDIO_IMPLEMENTATION
        if(this->GetAudioManager()==0)
            { this->AddManager( this->CreateManager("OALSAudioManager",Params,false) ); }
        if(this->GetSoundScapeManager()==0)
            { this->AddManager( this->CreateManager("OALSSoundScapeManager",Params,false) ); }
        #endif //ENABLE_OALS_AUDIO_IMPLEMENTATION

        // This Tests various assumptions about the way the platform works, and will not act
        SanityChecks();
    }
示例#2
0
void DLLEXPORT HUD_Init( void )
{
	InitInput();
	gHUD.Init();
	Scheme_Init();
	
	SetupLogging (); // buz

	// buz: enable CrashRpt library
	LoadCrashRpt();
}
示例#3
0
int Trackobot::Run() {
  if( IsAlreadyRunning() )
    return 1;

  LOG( "Launch v%s on %s", VERSION, qt2cstr( QDate::currentDate().toString( Qt::ISODate ) ) );

  SetupUpdater();

  CreateUI();

  Initialize();

  SetupLogging();

  int exitCode = mApp.exec();

  // Tear down
  LOG( "Shutdown" );

  return exitCode;
}
GameClient::GameClient()
:GameClientBase(_T("Game Client")),
m_uiAudioManager(Audio::IAudioManager::Get())
{
   SetupLogging();
}
int main(int argc, char *argv[])
{
    int ExitCode = 0;

    std::string			creoStartCommand;
    std::string			proeIsisExtensionsDir;

    std::string			templateFile_PathAndFileName;
    std::stringstream	exceptionErrorStringStream;

    bool Logging_Set_Up = false;

    isis::ProgramInputArguments  programInputArguments;
    ::boost::filesystem::path    workingDir;

    try
    {
        // Parse Input Arguments
        programInputArguments.ParseInputArguments(argc, argv);

        // Setup Boost logging
        SetupLogging(programInputArguments.logFileName, programInputArguments.logVerbosity);

        

        Logging_Set_Up = true;

        isis::ThrowException_If_InvalidInputArguments(argc, argv, programInputArguments);

        // Must get the complete path to the working directory.  This is necessary because when
        // isis_ProDirectoryChange is called to change to a STEP directory, workingDir must be fully
        // defined so that isis_ProDirectoryChange can be called to return to the original directory.
        workingDir = isis::SetupWorkingDirectory(programInputArguments.workingDirectory);

		isis::GlobalModelData::Instance.instanceId = programInputArguments.instanceID;

        // Log CADCreoParametricCreateAssembly version information
        std::string programName_Version_TimeStamp;
        programName_Version_TimeStamp = "CADCreoParametricMetaLink " + std::string(ISIS_PRODUCT_VERSION_WITH_v_AND_DOTS);

        ///////////////////
        // Add Time Stamp
        ///////////////////

        programName_Version_TimeStamp += isis_CADCommon::GetDayMonthTimeYear();
        isis_LOG(lg, isis_FILE, isis_INFO) << programName_Version_TimeStamp;

        isis_LOG(lg, isis_FILE, isis_INFO) << "Notes: " << isis_EOL
                                     << "   1. The \"Component Instance ID\"s in this file equate to ComponentInstanceIDs in CyPhy."  << isis_EOL
                                     << "   2. To map \"Component Instance ID\"s in this file to AVM-IDs, see .\\log\\CyPhy2CAD.log." << isis_EOL;

        time_t time_start; /* calendar time */
        time_start=time(NULL); /* get current cal time */

        // Log input line and parameters
        std::ostringstream inputLine;
        for(int i = 0; i < argc; ++i)
        {
            inputLine << argv[i] << std::string(" ");
        }
        isis_LOG(lg, isis_FILE, isis_INFO) << "Command line: " << inputLine.str();

		isis_LOG(lg, isis_FILE, isis_DEBUG) << "Input arguments (parsed): " << isis_EOL << programInputArguments;

        if(workingDir.generic_string().size() >= PRO_PATH_SIZE)      // PRO_PATH_SIZE   260
        {
            std::stringstream errorString;
            errorString << "WORKING_DIR string too long.  Maximum allowed number of characters: "  << PRO_PATH_SIZE - 1 << " WORKING_DIR string: " << workingDir;
            throw isis::application_exception(errorString);
        }

		isis::SetCreoEnvirVariable_RetrieveSystemSettings(programInputArguments.graphicsModeOn,
                programInputArguments.synchronizeWithCyPhy,
                creoStartCommand,
                proeIsisExtensionsDir,
                templateFile_PathAndFileName);

        std::map<std::string, isis::CADComponentData> CADComponentData_map;
        isis::CADAssemblies CADComponentAssemblies;

		writeConfigProFile(workingDir, programInputArguments);

        /////////////////////////////
        /////// Start Pro/E /////////
        /////////////////////////////

        const char* proeIsisExt = std::getenv("PROE_ISIS_EXTENSIONS");
        char* creoStartChar = const_cast<char*>(creoStartCommand.c_str());

        ::boost::filesystem::current_path(workingDir);
        std::string textPath=std::string(proeIsisExt)+"plugins\\";
        isis::isis_ProEngineerStart(creoStartChar, const_cast<char*>(textPath.c_str()));

        ProTermFuncSet(ProTermAction);

        isis_LOG(lg, isis_FILE, isis_INFO) << "Creo-Parametric successfully started.";

        boost::asio::io_service ios;
        std::string delimiters(":");
        std::vector<std::string> parts;
        boost::split(parts, programInputArguments.syncConnectionString, boost::is_any_of(delimiters));
        std::string host = "127.0.0.1";  // localhost may be subject to firewall and DNS restrictions and not work
        std::string service = "15152";   // it looks like ISIS with a zero

        if(parts.size() > 1)
        {
            host = parts[0];
            service = parts[1];
            isis_LOG(lg, isis_FILE, isis_INFO) << "host: " << host << ", service: " << service;
        }
        else if(parts.size() > 0)
        {
            host = parts[0];
            isis_LOG(lg, isis_FILE, isis_INFO) << "host: " << host << ", service: " << service << "(default)";
        }
        else
        {
            isis_LOG(lg, isis_FILE, isis_INFO) << "host: " << host << "(default), service: " << service << "(default)";
        }

        SetupCreoPlugins();
        SetupCreoSelectPlugin();

        ProNotificationSet(PRO_PARAM_MODIFY_POST, (ProFunction)metaParameterModifyAction);

        isis::cad::CadFactoryAbstract::ptr cad_factory = isis::cad::creo::create();

        isis::MetaLinkAssemblyEditor::Pointer assembler_ptr(new isis::MetaLinkAssemblyEditor(cad_factory, programInputArguments, isis::GlobalModelData::Instance.CadComponentData));

        boost::mutex eventloop_mutex;

        if(programInputArguments.is_passiveMode())
        {
            isis::GlobalModelData::Instance.designId = programInputArguments.designID;
        }

		isis::MetaLinkHandler metalink_handler(assembler_ptr, ios, host, service, programInputArguments.instanceID, programInputArguments.designID, eventloop_mutex);  // pass design ID pass in as argument

        isis::GlobalModelData::Instance.metalink_handler_ptr = &metalink_handler;
        isis::GlobalModelData::Instance.metalinkAssemblyEditorPtr = assembler_ptr;

        metalink_handler.change_m_operator("CAD");

        bool inputFileProcessed = false;

        while(!terminateProcess)
        {
            ProEventProcess();
            if(programInputArguments.inputXmlFileName.size()!=0 && !inputFileProcessed)
            {
                metalink_handler.CreateAssembly(programInputArguments.inputXmlFileName);
                inputFileProcessed = true;
            }
            if(metalink_handler.m_eventQueue.size()>0)
            {
                boost::unique_lock< boost::mutex > guard(eventloop_mutex);
                isis::EditPointer edit = metalink_handler.m_eventQueue.front();
                metalink_handler.m_eventQueue.pop();
                bool result = metalink_handler.processEdit(edit);
                if(result)
                {
                    isis::EditPointer ack(new meta::Edit());
                    ack->set_guid(edit->guid());
                    for(int i = 0; i < edit->topic_size(); i++)
                    {
                        *(ack->add_topic()) = edit->topic(i);
                    }
                    metalink_handler.send(ack);
                }
            }
        }

        metalink_handler.interrupt();
        metalink_handler.disconnect();

        ProEngineerEnd();


    } // END Try
    catch(isis::application_exception& ex)
    {
        exceptionErrorStringStream  << "application error: " << ex.what();
        ExitCode = -1;
    }
    catch(std::exception& ex)
    {
        exceptionErrorStringStream << "general exception: " << ex.what();
        ExitCode = -2;
    }
    catch(...)
    {
        exceptionErrorStringStream << "unspecified throwable (...):  Please report the error to the help desk.";
        ExitCode = -3;
    }

    if(ExitCode != 0)
    {
        // Write to _FAILED.txt
        std::string failedTxtFileName = "_FAILED.txt";
        bool addLineFeed = false;
        if(isis::FileExists(failedTxtFileName.c_str()))
        {
            addLineFeed = true;
        }

        ofstream failedTxtFileStream;
        failedTxtFileStream.open(failedTxtFileName, ios::app);
        if(failedTxtFileStream.is_open())
        {
            if(addLineFeed)
            {
                failedTxtFileStream << std::endl;
            }
            failedTxtFileStream <<  isis_CADCommon::GetDayMonthTimeYear() << ", CADCreoParametricCreateAssembly.exe error code: " << ExitCode << ".  For additional information, scroll to the bottom of " << programInputArguments.logFileName;
            failedTxtFileStream.close();
        }

        if(Logging_Set_Up)
        {
            
            isis_LOG(lg, isis_FILE, isis_ERROR) << exceptionErrorStringStream.str();
        }
        else
        {
            std::cerr << std::endl << std::endl << exceptionErrorStringStream.str() << std::endl << std::endl;
        }

    }


    /*
    ::boost::filesystem::current_path(original_directory);

    // Cleanup - Delete the working dir after execution
    ::boost::system::error_code ec;
    if (isis::GlobalModelData::Instance.mode == isis::DESIGNEDIT)
    {
    	// Remove files one-by-one so if the directory removal fails still something is removed
    	::boost::filesystem::path deleteFile = workingDir / "*";
    	isis_LOG(lg, isis_FILE, isis_DEBUG) << workingDir / "*";
    	if (::boost::filesystem::exists(deleteFile) ) {
    		::boost::filesystem::remove_all(deleteFile, ec);
    		if (ec != 0)
    		{
    			isis_LOG(lg, isis_FILE, isis_ERROR) << "Failed to remove working directory, ec: " << ec;
    		}
    	}
    	deleteFile = workingDir;
    	isis_LOG(lg, isis_FILE, isis_DEBUG) << workingDir;
    	if (::boost::filesystem::exists(deleteFile) ) {
    		::boost::filesystem::remove_all(deleteFile, ec);
    		if (ec != 0)
    		{
    			isis_LOG(lg, isis_FILE, isis_ERROR) << "Failed to remove working directory, ec: " << ec;
    		}
    	}
    } else if (isis::GlobalModelData::Instance.mode == isis::COMPONENTEDIT)
    {
    	::boost::filesystem::path deleteFile = workingDir / "config.pro";
    	isis_LOG(lg, isis_FILE, isis_DEBUG) << workingDir / "config.pro";
    	if (::boost::filesystem::exists(deleteFile) ) {
    		::boost::filesystem::remove_all(deleteFile, ec);
    		if (ec != 0)
    		{
    			isis_LOG(lg, isis_FILE, isis_ERROR) << "Failed to remove working directory, ec: " << ec;
    		}
    	}
    	deleteFile = workingDir / "std.err";
    	isis_LOG(lg, isis_FILE, isis_DEBUG) << workingDir / "std.err";
    	if (::boost::filesystem::exists(deleteFile) ) {
    		::boost::filesystem::remove_all(deleteFile, ec);
    		if (ec != 0)
    		{
    			isis_LOG(lg, isis_FILE, isis_ERROR) << "Failed to remove working directory, ec: " << ec;
    		}
    	}
    	deleteFile = workingDir / "trail.txt.*";
    	isis_LOG(lg, isis_FILE, isis_DEBUG) << workingDir / "trail.txt.*";
    	if (::boost::filesystem::exists(deleteFile) ) {
    		::boost::filesystem::remove_all(deleteFile, ec);
    		if (ec != 0)
    		{
    			isis_LOG(lg, isis_FILE, isis_ERROR) << "Failed to remove working directory, ec: " << ec;
    		}
    	}
    }
    */
  

    exit(ExitCode);
}
示例#6
0
int main(int argc, char **argv)
{
  std::string ConfigFile = "simsearch_config.conf";
  int LogLevel = CRITICAL;
  std::string sLevel;
  bool daemon = false;
  std::string EncrIndexDirectory;
  std::string document_directory;
  int thread_pool_number = 0;

  const char* szInteractive = NULL;
  int interactive_mode = -1;

  int c;
  while ((c = getopt(argc, argv, "c:p:o:l:dhv")) != -1)
    {
      switch (c)
      {
        case 'c':
          ConfigFile = optarg;
          break;
        case 'o':
          if (!(Log::GetInstance().SetFileName(optarg)))
          {
            elog(CRITICAL, "Unable to set file '%s' as output file, using stderr\n", optarg);
          }
          break;
        case 'd':
          daemon = true;
          break;
        case 'h':
          Usage();
          exit(EXIT_FAILURE);
          break;
        case 'v':
          Version();
          exit(EXIT_SUCCESS);
          break;
        case 'l':
          sLevel = optarg;
          LogLevel = Log::GetInstance().StrToLevel(sLevel);
          if (LogLevel == -1)
          {
            elog(CRITICAL, "Unknown log level '%s', leaving at CRITICAL\n", sLevel.c_str());
            LogLevel = CRITICAL;
          }
          break;
        case '?':
        default:
          elog(CRITICAL, "Unable to parse command line arguments\n");
          break;
      }
  }

  // Setup logging
  Log::GetInstance().SetLevel(LogLevel);

  // Setup config reader
  boost::shared_ptr<Config> mConfig = boost::make_shared<Config>();
  if (!mConfig->Load(ConfigFile.c_str()))
  {
    elog(CRITICAL, "Unable to load config file '%s'.\n", ConfigFile.c_str());
  }
  else
  {
      if (SetupLogging(mConfig) == false)
      {
        elog(CRITICAL, "Unable to initialize logging.\n");
      }
  }

  if (daemon == true)
  {
    // TODO: create daemon method
  }

  // Get the interactive mode value
  szInteractive = mConfig->GetValue(CONFIG_INTERACTIVE_MODE);
  if (szInteractive == NULL)
  {
    elog(CRITICAL, "Unable to read interactive mode value in configuration file.\n");
    exit(EXIT_FAILURE);
  }
  else
  {
    std::string mode_string = szInteractive;
    interactive_mode = boost::lexical_cast<int>(mode_string);
  }

  const char* output = mConfig->GetValue(CONFIG_OUTPUT_DIRECTORY);
  if (output == NULL)
  {
	elog(CRITICAL, "Unable to read output directory option in configuration file.\n");
	exit(EXIT_FAILURE);
  }
  else
  {
    EncrIndexDirectory = output;
  }

  const char* thread_pool_char = mConfig->GetValue(CONFIG_THREAD_POOL_NUMBER);
  if (thread_pool_char == NULL)
  {
	elog(CRITICAL, "Unable to read thread number option in configuration file.\n");
	exit(EXIT_FAILURE);
  }
  else
  {
	std::string thread_pool_string = thread_pool_char;
	thread_pool_number = boost::lexical_cast<int>(thread_pool_string);
  }

  // Filemanager reader/writer
  boost::shared_ptr<FileManager> pFileManager = boost::make_shared<FileManager>();

  // LTC manager
  boost::shared_ptr<LTCManager> pLTCManager = boost::make_shared<LTCManager>();

  // Init
  if (pLTCManager->Init() == false)
  {
    elog(CRITICAL, "Unable to initialize LTC library.\n");
    exit(EXIT_FAILURE);
  }

  if (pLTCManager->GenerateKey() == false)
  {
    elog(CRITICAL, "Unable to generate keys for LTC library.\n");
    exit(EXIT_FAILURE);
  }

  // Init HE manager
  // TODO: check return values for Init and GenerateKeys
  boost::shared_ptr<HEManager> pHEManager = boost::make_shared<HEManager>();
  pHEManager->Init();

  // Setup Thread Pool
  boost::shared_ptr<ThreadPool> pPool = boost::make_shared<ThreadPool>();
  pPool->SetSize(thread_pool_number);
  elog(DEBUG, "Thread pool size is '%d'.\n", thread_pool_number);

  elog(DEBUG, "Initializing pool...\n");
  if (pPool->Init() == false)
  {
	elog(CRITICAL, "Could not initialize pool.\n");
	exit(EXIT_FAILURE);
  }

  // Setup Queue and QueueManager

  boost::shared_ptr<EventHandler> pEventHandler = boost::make_shared<EventHandler>();

  // Create queue
  boost::shared_ptr<EventQueue> pEventQueue = boost::make_shared<EventQueue>(pEventHandler);

  if (pEventQueue->Init(QUEUE_MAX_ELEMENTS) == false)
  {
    elog(CRITICAL, "Unable to create event queue with size '%d'.\n", QUEUE_MAX_ELEMENTS);
    return false;
  }

  // Launch event queue
  if (pEventQueue->Start() == false)
  {
    elog(CRITICAL, "Unable to start event queue.\n");
    return false;
  }

  // Check interactive mode value from configuration file
  if (interactive_mode < 0)
  {
    elog(CRITICAL, "Unable to setup interactive mode.\n");
    exit(EXIT_FAILURE);
  }
  else
  if (interactive_mode == 0)
  {
    elog(INFO, "Entering non-interactive mode.\n");

    {
      // Read directory from file, generate random words, search it and display the results
      const char* dir = mConfig->GetValue(CONFIG_DOCUMENT_DIRECTORY);
      if (dir == NULL)
      {
        elog(CRITICAL, "Unable to read document directory value in configuration file.\n");
        exit(EXIT_FAILURE);
      }

      // Start the simsearch
      std::string directory = dir;

      boost::scoped_ptr<IndexBuildEngine> oIndexBuilder(new IndexBuildEngine(directory,
                                                                           EncrIndexDirectory,
                                                                           pFileManager,
                                                                           pLTCManager,
                                                                           pHEManager,
                                                                           pPool,
                                                                           pEventQueue));

      if (oIndexBuilder == NULL)
      {
        std::cout << "Could not allocate memory for IndexBuilder engine.\n";
        exit(EXIT_FAILURE);
      }

      // Init IndexBuilder
      oIndexBuilder->Init();

      // Fire up the search service
      oIndexBuilder->Startup();
    }

    {
      boost::scoped_ptr<SearchEngine> oSearch(new SearchEngine(EncrIndexDirectory,
                                                             pFileManager,
                                                             pLTCManager,
                                                             pHEManager,
                                                             pPool,
                                                             pEventQueue));

      // Init search engine
      oSearch->Init();

      //std::string word_input = "ospf bgp mime xml iscsi";
      //std::string word_input = "certificate encryption authorization authentication framework";
    
      // Get the number of words to randomly generate in search query
      std::vector<int> query_random_size{ 5,10,15};

      // Iterate on each value in random vector
      for (const auto& num : query_random_size)
      {
        std::string word_input;
        // Generate random words and put result a string
        if (oSearch->GenRandomSearchQuery(num, word_input) == false)
	{ 
	  elog(ERROR, "Unable to generate random search query.\n");
	  continue;
	}
      
	elog(DEBUG, "Number of generated RANDOM words: '%d'.\n", num);

        // Execute search
        if (oSearch->SearchIndex(word_input) == false)
        {
          elog(ERROR, "Unable to execute search.\n");
        }
        else
        {
          oSearch->PrintResults();
        }
      }
    }
/*

    // Get the number of words to randomly generate in search query
    const char* word_rnd_number = mConfig->GetValue(CONFIG_WORD_RANDOM_NUMBER);
    if (word_rnd_number == NULL)
    {
      elog(CRITICAL, "Unable to read word random number value in configuration file.\n");
      exit(EXIT_FAILURE);
    }

    // Generate random words and put result a string
    std::string word_rnd_number_string = word_rnd_number;
    std::string random_words;
    ss.GenRandomSearchQuery(boost::lexical_cast<int>(word_rnd_number_string), random_words);

    // Search it!
    ss.SearchIndex(random_words);


    // Print retuls
    ss.PrintResults();
*/
  }
  else
  {
    elog(INFO, "Entering interactive mode.\n");

    int choice = 1;
    std::string choise_str;
    std::string directory, word_input;
    std::string random_counter;

    while (choice != 0)
    {
      std::cout<<"\n----------------------------------------------\n";
      std::cout<<"0. Exit the application.\n";
      std::cout<<"1. Import a directory with documents to create searchable index.\n";
      std::cout<<"2. Input a set of words to search the index.\n";
      std::cout<<"3. Randomly generate a set of words to search the index.\n";
      std::cout<<"----------------------------------------------\n";
      std::cout<<"Select : ";

      // TODO: remove adhoc code
      std::getline(std::cin, choise_str);
      std::istringstream string_stream(choise_str);
      string_stream >> choice;

      if (choice == 1)
      {
        std::cout << "Type your directory (full path) with documents: ";
        std::getline (std::cin, directory);
        std::cout << "Reading the content of " << directory << ".\n";

        boost::scoped_ptr<IndexBuildEngine> oIndexBuilder(new IndexBuildEngine(directory,
                                                                               EncrIndexDirectory,
                                                                               pFileManager,
                                                                               pLTCManager,
                                                                               pHEManager,
                                                                               pPool,
                                                                               pEventQueue));

        if (oIndexBuilder == NULL)
        {
          std::cout << "Could not allocate memory for IndexBuilder engine.\n";
          exit(EXIT_FAILURE);
        }

        // Init IndexBuilder
        oIndexBuilder->Init();

        // Fire up the search service
        oIndexBuilder->Startup();

        std::cout << "Done!\n";
      }
      else if (choice == 2)
      {
        word_input.clear();
        std::cout << "Enter the set of words: ";
        std::getline (std::cin, word_input);

        if (word_input.empty() == true)
        {
          std::cout << "Input is empty.\n";
        }
        else
        {
          std::cout << "Searching for keywords '" << word_input << "'.\n";
          boost::scoped_ptr<SearchEngine> oSearch(new SearchEngine(EncrIndexDirectory,
                                                                   pFileManager,
                                                                   pLTCManager,
                                                                   pHEManager,
                                                                   pPool,
                                                                   pEventQueue));

          // Init search engine
          oSearch->Init();

          // Execute search
          if (oSearch->SearchIndex(word_input) == false)
          {
            elog(ERROR, "Unable to execute search.\n");
          }
          else
          {
            oSearch->PrintResults();
          }
        }
      }
      else if (choice == 3)
      {
        std::cout << "This feature is under construction \n";
/*
        if (!ss)
        {

          std::cout << "Please import a directory with documents.\n";
        }
        else
        {
          word_input.clear();
          random_counter.clear();
          std::cout << "Please provide number of random words in the search query: ";
          std::getline (std::cin, random_counter);

          // Place random words in word_input
          ss->GenRandomSearchQuery(boost::lexical_cast<int>(random_counter), word_input);

          //std::cout << "Randomly generated query: '" << word_input << "'\n";

          // Search!
          ss->SearchIndex(word_input);

          // Print!
          ss->PrintResults();
        }
*/
      }

    }

  } // if-else

  elog(DEBUG, "Killing pool.\n");
  pPool->Kill();
  elog(DEBUG, "Done!\n");

  elog(DEBUG, "Killing queue.\n");
  pEventQueue->Kill();
  elog(DEBUG, "Done!\n");

  return EXIT_SUCCESS;
}
示例#7
0
BOOL CIWinSyncDlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();
	
	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	m_bLoggingEnabled = FALSE; // We have not obtained log details yet
	SetupLogging();

	//Populate the Debug Level Listbox
	CListBox* pDebugLevelList = NULL;
	pDebugLevelList = (CListBox*) GetDlgItem(IDC_LIST_LOGLEVEL);
	if (pDebugLevelList != NULL)
	{
		pDebugLevelList->AddString(LOGLEVEL_LISTBOX_DEBUG);
		pDebugLevelList->AddString(LOGLEVEL_LISTBOX_WARN);
		pDebugLevelList->AddString(LOGLEVEL_LISTBOX_ERROR);
	}
	//Load Application Settings from the registry
	ReadRegistrySettings();
	m_bSuppressDialogs = FALSE;
	m_bDisableSync = FALSE;
	PopulateSettingsDialog();
	
	if (m_bSyncPathSet)
	{
		ShowWindow(SW_SHOWMINIMIZED);
	}
	else
	{
		ShowWindow(SW_SHOWNORMAL);
	}
	
	m_bMinimizeToTray = FALSE;
	m_bCanShowFlyout = TRUE;

	if ( m_bSyncPathSet)
	{
		LOG(G2L_DEBUG) << "Application Is Started - Starting OfflineFiles Service";
		if ( !InitSyncClient() ) //Need to pass event details
		{
			PostQuitMessage(0); // Shutdown because the application did not initialise
			return TRUE;
		}
		//start The sync Timer
		m_puSyncTimer = SetTimer(SYNC_TIMER_ID, m_nSyncInterval, NULL);
		if(  m_puSyncTimer == 0)
		{
			LOG(G2L_WARNING) << "Failed To start the sync Timer";
			PostQuitMessage(0); // Shutdown because the application did not initialise
			return TRUE;
		}
		LOG(G2L_DEBUG) << "Application Is Started - Started OfflineFiles Service";
		PostMessage(WM_SYSCOMMAND, SC_MINIMIZE);
	}
	else
	{
		LOG(G2L_DEBUG) << "Application Is Started - Sync Folder Is Not set";
	}
	return TRUE;  // return TRUE  unless you set the focus to a control
}
int main( int argc, char *argv[] )
{
	::boost::filesystem::path original_directory = ::boost::filesystem::current_path();

	int ExitCode = 0;

	std::string			creoStartCommand;
	std::string			proeIsisExtensionsDir;

	std::string			templateFile_PathAndFileName;
	std::stringstream	exceptionErrorStringStream;
	bool				promptBeforeExiting;

	bool Pro_E_Running = false;
	bool Template_Copied = false;

	bool Logging_Set_Up = false;

	bool logFileOpen = false;

	isis::ProgramInputArguments  programInputArguments;
	::boost::filesystem::path    workingDir;

	try
	{
		bool regenerationSucceeded_ForAllAssemblies = true;

		// Parse Input Arguments
		isis::ParseInputArguments(argc, argv, programInputArguments);
		isis::ThrowExecption_If_InvalidInputArguments(argc, argv, programInputArguments);

		SetupLogging(programInputArguments.logFileName);

		// In case of exception we need to know if log4cpp is available
		Logging_Set_Up = true;

		log4cpp::Category& logcat_fileonly = log4cpp::Category::getInstance(LOGCAT_LOGFILEONLY);


		// Must get the complete path to the working directory.  This is necessary because when
		// isis_ProDirectoryChange is called to change to a STEP directory, workingDir must be fully
		// defined so that isis_ProDirectoryChange can be called to return to the original directory.
		workingDir = isis::SetupWorkingDirectory( programInputArguments.workingDirectory );

		//cADPartsLibDir = programInputArguments.auxiliaryCADDirectory;
		//xmlInputFile_PathAndFileName = programInputArguments.inputXmlFileName;
		promptBeforeExiting = programInputArguments.promptBeforeExiting;

		// Log CADCreoParametricCreateAssembly version information
		std::string programName_Version_TimeStamp;
		programName_Version_TimeStamp = "CADCreoParametricCreateAssembly " + isis::ASSEMBLE_PTC_VERSION + "      ";

		///////////////////
		// Add Time Stamp
		///////////////////

		programName_Version_TimeStamp += isis_CADCommon::GetDayMonthTimeYear();
		
		logcat_fileonly.infoStream() << programName_Version_TimeStamp;

		logcat_fileonly.infoStream() << "";
		logcat_fileonly.infoStream() << "Notes: " << log4cpp::eol
		  << "   1. The \"Component Instance ID\"s in this file equate to ComponentInstanceIDs in CyPhy."  << log4cpp::eol
		  << "   2. To map \"Component Instance ID\"s in this file to AVM-IDs, see .\\log\\CyPhy2CAD.log.";
		
		//return 0;

		time_t time_start; /* calendar time */
		time_start=time(NULL); /* get current cal time */

		// Log input line and parameters
		std::ostringstream inputLine;
		for ( int i = 0; i < argc; ++i) inputLine << argv[i] << std::string(" ");
		logcat_fileonly.infoStream() << "";
		logcat_fileonly.infoStream() 
			<< "************** Begin Input Line *****************" << log4cpp::eol 
		  << inputLine.str() << log4cpp::eol
	      << "************** End Input Line *****************" ;
		  


		if ( workingDir.generic_string().size() >= PRO_PATH_SIZE )  // PRO_PATH_SIZE   260
		{
			std::stringstream errorString;
			errorString << "WORKING_DIR string too long.  Maximum allowed number of characters: "  << PRO_PATH_SIZE - 1 << " WORKING_DIR string: " << workingDir;
					throw isis::application_exception(errorString);
		}
		logcat_fileonly.infoStream() << "";
		logcat_fileonly.infoStream() 
		  <<  log4cpp::eol << "************** Begin Directory Settings *****************"
		  <<  log4cpp::eol << "workingDir:                    "	<< workingDir
		  <<  log4cpp::eol << "inputXmlFileName:              "	<< programInputArguments.inputXmlFileName
		  <<  log4cpp::eol << "logFileName:                   "	<< programInputArguments.logFileName
		  <<  log4cpp::eol << "*************** End Directory Settings *****************";
		 
		bool graphicsModeOn = false;
		bool creoExceptInputFromThisProgramAndCreoUI = false;

		if (programInputArguments.graphicsModeOn) graphicsModeOn = true;
		if (programInputArguments.synchronizeWithCyPhy) creoExceptInputFromThisProgramAndCreoUI = true;

		isis::SetCreoEnvirVariable_RetrieveSystemSettings(	graphicsModeOn,
															creoExceptInputFromThisProgramAndCreoUI,
															creoStartCommand,
															proeIsisExtensionsDir,
															templateFile_PathAndFileName );

		std::map<std::string, isis::CADComponentData> CADComponentData_map;
		isis::CADAssemblies CADComponentAssemblies;


		   unsigned int UniqueNameIndex = 1;

		   isis::CreateAssemblyViaInputFile(	programInputArguments,
												proeIsisExtensionsDir,
												programInputArguments.inputXmlFileName,
												workingDir.generic_string(),
												programInputArguments.auxiliaryCADDirectory,
												programInputArguments.logFileName,
												templateFile_PathAndFileName,
												creoStartCommand,
												programName_Version_TimeStamp,
												UniqueNameIndex,
												Pro_E_Running,
												CADComponentAssemblies,
												CADComponentData_map);

		 


	} // END Try
    catch ( isis::application_exception& ex )
	{
		exceptionErrorStringStream  << std::endl << "application error: " << ex.what();
		ExitCode = -1;
	}
	catch ( std::exception& ex )
	{
		exceptionErrorStringStream << std::endl  << "general exception: " << ex.what();
		ExitCode = -2;
	}
	catch ( ... )
	{
		exceptionErrorStringStream << "unspecified throwable (...):  Please report the error to the help desk.";
		ExitCode = -3;
	}

	if ( ExitCode != 0 )
	{
		// Write to _FAILED.txt
		std::string failedTxtFileName = "_FAILED.txt";
		bool addLineFeed = false;
		if ( isis::FileExists( failedTxtFileName.c_str() )) addLineFeed = true;

		ofstream failedTxtFileStream;
		failedTxtFileStream.open (failedTxtFileName, ios::app );
		if ( failedTxtFileStream.is_open() )
		{
			if ( addLineFeed ) failedTxtFileStream << std::endl;
			failedTxtFileStream <<  isis_CADCommon::GetDayMonthTimeYear() << ", CADCreoParametricCreateAssembly.exe error code: " << ExitCode << ". Error was: " << exceptionErrorStringStream.str();
			failedTxtFileStream << std::endl;
			failedTxtFileStream.close();
		}

		if (Logging_Set_Up)
		{
			log4cpp::Category& logcat_consoleandfile = log4cpp::Category::getInstance(LOGCAT_CONSOLEANDLOGFILE);
			logcat_consoleandfile.errorStream() << exceptionErrorStringStream.str();
		}
		else
		{
			std::cerr <<  std::endl << std::endl << exceptionErrorStringStream.str() << std::endl << std::endl;
		}	
	}

	// Delete the copied template assembly file if it exists.
	// Note - Added "if ( Template_Copied )" because the function call was returning a message to the
	// console if the file did not exist.
	if ( Template_Copied )
	{
		::boost::filesystem::path deleteFile = workingDir / (isis::TEMPLATE_MODEL_NAME_METRIC + isis::TEMPLATE_MODEL_NAME_METRIC_SUFFIX);
		if (::boost::filesystem::exists(deleteFile) ) 
		{
		   ::boost::filesystem::remove(deleteFile);
		}
		// isis::IfFileExists_DeleteFile( deleteFile.generic_string() );
	}

	/////// Stop Pro/E /////////
	if (Pro_E_Running) ProEngineerEnd();

	if ( promptBeforeExiting )
	{
		printf("\nType Enter to exit.");
		getc(stdin);
	}

    ::boost::filesystem::current_path(original_directory);

	log4cpp::Category::shutdown();

	exit(ExitCode);
}
示例#9
0
    void Entresol::ConstructFromXML(const String& EngineDataPath, const Mezzanine::ArchiveType ArchType, const String& InitializerFile)
    {
        //Add default manager factories
        AddAllEngineDefaultManagerFactories();
        //Set some sane Defaults for some values.
        this->ManualLoopBreak = false;

        // Create Ogre.
        SetupOgre();

        // Load the necessary plugins.
        SubSystemParticleFXPlugin = new Ogre::ParticleFXPlugin();
        Ogre::Root::getSingleton().installPlugin(SubSystemParticleFXPlugin);

        // Set up the data we'll be populating.
        XML::Attribute CurrAttrib;
        String GUIInit, ResourceInit, PluginsInit, LogFileName;
        String PluginExtension, PluginPath;

        // Create or set the resource manager.
        /// @todo This currently forces our default resource manager to be constructed, which isn't in line with our factory/initiailzation design.
        /// This should be addressed somehow.
        if(ResourceManager::SingletonValid())
            { AddManager(ResourceManager::GetSingletonPtr()); }
        else
            { AddManager(new ResourceManager(EngineDataPath, ArchType)); }

        // Open and load the initializer doc.
        ResourceManager* ResourceMan = GetResourceManager();
        /// @todo Replace this stack allocated stream for one initialized from the Resource Manager, after the system is ready.
        Resource::FileStream InitStream(InitializerFile,EngineDataPath);
        XML::Document InitDoc;
        XML::ParseResult DocResult = InitDoc.Load(InitStream);
        if( DocResult.Status != XML::StatusOk )
        {
            StringStream ExceptionStream;
            ExceptionStream << "Failed to parse XML file \"" << InitializerFile << "\".";
            MEZZ_EXCEPTION(Exception::SYNTAX_ERROR_EXCEPTION_XML,ExceptionStream.str());
        }
        XML::Node InitRoot = InitDoc.GetChild("InitializerRoot");
        if( InitRoot.Empty() )
        {
            StringStream ExceptionStream;
            ExceptionStream << "Failed to find expected Root node in \"" << InitializerFile << "\".";
            MEZZ_EXCEPTION(Exception::SYNTAX_ERROR_EXCEPTION_XML,ExceptionStream.str());
        }

        // Get the world settings and set them.
        XML::Node WorldSettings = InitRoot.GetChild("WorldSettings");
        for( XML::NodeIterator SetIt = WorldSettings.begin() ; SetIt != WorldSettings.end() ; ++SetIt )
        {
            String SecName = (*SetIt).Name();
            if( "FrameSettings" == SecName )
            {
                CurrAttrib = (*SetIt).GetAttribute("TargetFrameRate");
                if(CurrAttrib.Empty())
                {
                    CurrAttrib = (*SetIt).GetAttribute("TargetFrameTime");
                    if(!CurrAttrib.Empty())
                        SetTargetFrameTimeMicroseconds(CurrAttrib.AsWhole());
                }else{
                    this->SetTargetFrameRate(CurrAttrib.AsWhole());
                }
            }
            else
            {
                MEZZ_EXCEPTION(Exception::SYNTAX_ERROR_EXCEPTION_XML,String("Unknown WorldSetting ")+SecName);
            }

        }

        SetupLogging(LogFileName);

        // Get the other initializer files we'll be using, since we'll need the plugins initializer.
        XML::Node InitFiles = InitRoot.GetChild("OtherInitializers");
        for( XML::NodeIterator InitIt = InitFiles.begin() ; InitIt != InitFiles.end() ; ++InitIt )
        {
            String InitFileName = (*InitIt).Name();
            if( "PluginInit" == InitFileName )
            {
                CurrAttrib = (*InitIt).GetAttribute("FileName");
                if(!CurrAttrib.Empty())
                    PluginsInit = CurrAttrib.AsString();
            }
            else if( "ResourceInit" == InitFileName )
            {
                CurrAttrib = (*InitIt).GetAttribute("FileName");
                if(!CurrAttrib.Empty())
                    ResourceInit = CurrAttrib.AsString();
            }
            else if( "GUIInit" == InitFileName )
            {
                CurrAttrib = (*InitIt).GetAttribute("FileName");
                if(!CurrAttrib.Empty())
                    GUIInit = CurrAttrib.AsString();
            }
        }

        // Load additional resource groups
        /*if(!ResourceInit.empty())
        {
            /// @todo Replace this stack allocated stream for one initialized from the Resource Manager, after the system is ready.
            Resource::FileStream ResourceStream(ResourceInit,EngineDataPath);
            XML::Document ResourceDoc;
            ResourceDoc.Load(ResourceStream);
            // Get an iterator to the first resource group node, and declare them all.
            XML::Node ResourceLocations = ResourceDoc.GetChild("ResourceLocations");
            for( XML::NodeIterator GroupIt = ResourceLocations.begin() ; GroupIt != ResourceLocations.end() ; ++GroupIt )
            {
                String GroupName, GroupType, GroupPath;
                bool GroupRecursive = false;
                // Get the group path
                CurrAttrib = (*GroupIt).GetAttribute("GroupPath");
                if(!CurrAttrib.Empty())
                    GroupPath = CurrAttrib.AsString();
                // Get the group type
                CurrAttrib = (*GroupIt).GetAttribute("GroupType");
                if(!CurrAttrib.Empty())
                    GroupType = CurrAttrib.AsString();
                // Get the group name
                CurrAttrib = (*GroupIt).GetAttribute("GroupName");
                if(!CurrAttrib.Empty())
                    GroupName = CurrAttrib.AsString();
                // Get whether this is recursive
                CurrAttrib = (*GroupIt).GetAttribute("Recursive");
                if(!CurrAttrib.Empty())
                    GroupRecursive = StringTool::ConvertToBool(CurrAttrib.AsString());
                // Finally create the resource location.
                ResourceMan->AddAssetLocation(GroupPath,GroupType,GroupName,GroupRecursive);
            }
            // Get what resource groups should be initialized.
            XML::Node InitGroups = ResourceDoc.GetChild("InitGroups");
            for( XML::NodeIterator InitIt = InitGroups.begin() ; InitIt != InitGroups.end() ; ++InitIt )
            {
                String GroupName;
                CurrAttrib = (*InitIt).GetAttribute("GroupName");
                if(!CurrAttrib.Empty())
                    GroupName = CurrAttrib.AsString();
                ResourceMan->InitAssetGroup(GroupName);
            }
        }//*/

        // Create the requested managers and set their necessary values.
        XML::Node Managers = InitRoot.GetChild("Managers");
        for( XML::NodeIterator ManIt = Managers.begin() ; ManIt != Managers.end() ; ++ManIt )
        {
            CreateManager( (*ManIt).Name(), (*ManIt) );
        }

        // Load additional resource groups
        if(!ResourceInit.empty())
        {
            /// @todo Replace this stack allocated stream for one initialized from the Resource Manager, after the system is ready.
            Resource::FileStream ResourceStream(ResourceInit,EngineDataPath);
            XML::Document ResourceDoc;
            ResourceDoc.Load(ResourceStream);
            // Get an iterator to the first resource group node, and declare them all.
            XML::Node ResourceLocations = ResourceDoc.GetChild("ResourceLocations");
            for( XML::NodeIterator GroupIt = ResourceLocations.begin() ; GroupIt != ResourceLocations.end() ; ++GroupIt )
            {
                String GroupName, GroupPath;
                ArchiveType GroupType;
                bool GroupRecursive = false;
                // Get the group path
                CurrAttrib = (*GroupIt).GetAttribute("GroupPath");
                if(!CurrAttrib.Empty())
                    GroupPath = CurrAttrib.AsString();
                // Get the group type
                CurrAttrib = (*GroupIt).GetAttribute("GroupType");
                if(!CurrAttrib.Empty())
                    GroupType = ResourceManager::GetArchiveTypeFromString(CurrAttrib.AsString());
                // Get the group name
                CurrAttrib = (*GroupIt).GetAttribute("GroupName");
                if(!CurrAttrib.Empty())
                    GroupName = CurrAttrib.AsString();
                // Get whether this is recursive
                CurrAttrib = (*GroupIt).GetAttribute("Recursive");
                if(!CurrAttrib.Empty())
                    GroupRecursive = StringTools::ConvertToBool(CurrAttrib.AsString());
                // Finally create the resource location.
                ResourceMan->AddAssetLocation(GroupPath,GroupType,GroupName,GroupRecursive);
            }
            // Get what resource groups should be initialized.
            XML::Node InitGroups = ResourceDoc.GetChild("InitGroups");
            for( XML::NodeIterator InitIt = InitGroups.begin() ; InitIt != InitGroups.end() ; ++InitIt )
            {
                String GroupName;
                CurrAttrib = (*InitIt).GetAttribute("GroupName");
                if(!CurrAttrib.Empty())
                    GroupName = CurrAttrib.AsString();
                ResourceMan->InitAssetGroup(GroupName);
            }
        }

        // Configure the UI
        if(!GUIInit.empty())
        {
            /// @todo This is currently not implemented.
        }

        SanityChecks();
    }