本文整理汇总了C++中THROW_ARGOSEXCEPTION函数的典型用法代码示例。如果您正苦于以下问题:C++ THROW_ARGOSEXCEPTION函数的具体用法?C++ THROW_ARGOSEXCEPTION怎么用?C++ THROW_ARGOSEXCEPTION使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了THROW_ARGOSEXCEPTION函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: buzzvm_new
void CBuzzController::SetBytecode(const std::string& str_fname) {
/* Reset the BuzzVM */
if(m_tBuzzVM) buzzvm_destroy(&m_tBuzzVM);
m_tBuzzVM = buzzvm_new(m_unRobotId);
/* Save the bytecode filename */
m_strBytecodeFName = str_fname;
/* Load the bytecode */
std::ifstream cBCodeFile(str_fname.c_str(), std::ios::binary | std::ios::ate);
if(cBCodeFile.fail()) {
THROW_ARGOSEXCEPTION("Can't open file \"" << str_fname << "\": " << strerror(errno));
}
std::ifstream::pos_type unFileSize = cBCodeFile.tellg();
m_cBytecode.Clear();
m_cBytecode.Resize(unFileSize);
cBCodeFile.seekg(0, std::ios::beg);
cBCodeFile.read(reinterpret_cast<char*>(m_cBytecode.ToCArray()), unFileSize);
/* Load the script */
buzzvm_set_bcode(m_tBuzzVM, m_cBytecode.ToCArray(), m_cBytecode.Size());
if(buzzvm_set_bcode(m_tBuzzVM, m_cBytecode.ToCArray(), m_cBytecode.Size()) != BUZZVM_STATE_READY) {
THROW_ARGOSEXCEPTION("Error loading Buzz script \"" << str_fname << "\": " << buzzvm_strerror(m_tBuzzVM));
}
/* Register basic function */
if(RegisterFunctions() != BUZZVM_STATE_READY) {
THROW_ARGOSEXCEPTION("Error while registering functions");
}
/* Execute the global part of the script */
buzzvm_execute_script(m_tBuzzVM);
/* Call the Init() function */
buzzvm_function_call(m_tBuzzVM, "init", 0);
}
示例2: GetColorAtPoint
virtual CColor GetColorAtPoint(Real f_x,
Real f_y) {
/* Compute coordinates on the image */
UInt32 x = (f_x + m_cHalfArenaSize.GetX()) * m_fArenaToImageCoordinateXFactor;
UInt32 y = (f_y + m_cHalfArenaSize.GetY()) * m_fArenaToImageCoordinateYFactor;
/* Check the bit depth */
if(m_cImage.getBitsPerPixel() <= 8) {
RGBQUAD* ptColorPalette;
BYTE tPixelIndex;
/* 1, 4 or 8 bits per pixel */
if(! m_cImage.getPixelIndex(x, y, &tPixelIndex)) {
THROW_ARGOSEXCEPTION("Unable to access image pixel at (" << x << "," << y <<
"). Image size (" << m_cImage.getWidth() << "," <<
m_cImage.getHeight() << ")");
}
ptColorPalette = m_cImage.getPalette();
return CColor(ptColorPalette[tPixelIndex].rgbRed,
ptColorPalette[tPixelIndex].rgbGreen,
ptColorPalette[tPixelIndex].rgbBlue);
}
else {
/* 16, 24 or 32 bits per pixel */
RGBQUAD tColorPixel;
if(! m_cImage.getPixelColor(x, y, &tColorPixel)) {
THROW_ARGOSEXCEPTION("Unable to access image pixel at (" << x << "," << y <<
"). Image size (" << m_cImage.getWidth() << "," <<
m_cImage.getHeight() << ")");
}
return CColor(tColorPixel.rgbRed,
tColorPixel.rgbGreen,
tColorPixel.rgbBlue);
}
}
示例3: pthread_mutex_init
void CSpaceMultiThreadBalanceLength::Init(TConfigurationNode& t_tree) {
/* Initialize the space */
CSpace::Init(t_tree);
/* Initialize thread related structures */
int nErrors;
/* Init mutexes */
if((nErrors = pthread_mutex_init(&m_tStartSenseControlPhaseMutex, NULL)) ||
(nErrors = pthread_mutex_init(&m_tStartActPhaseMutex, NULL)) ||
(nErrors = pthread_mutex_init(&m_tStartPhysicsPhaseMutex, NULL)) ||
(nErrors = pthread_mutex_init(&m_tStartMediaPhaseMutex, NULL)) ||
(nErrors = pthread_mutex_init(&m_tFetchTaskMutex, NULL))) {
THROW_ARGOSEXCEPTION("Error creating thread mutexes " << ::strerror(nErrors));
}
/* Init conditionals */
if((nErrors = pthread_cond_init(&m_tStartSenseControlPhaseCond, NULL)) ||
(nErrors = pthread_cond_init(&m_tStartActPhaseCond, NULL)) ||
(nErrors = pthread_cond_init(&m_tStartPhysicsPhaseCond, NULL)) ||
(nErrors = pthread_cond_init(&m_tStartMediaPhaseCond, NULL)) ||
(nErrors = pthread_cond_init(&m_tFetchTaskCond, NULL))) {
THROW_ARGOSEXCEPTION("Error creating thread conditionals " << ::strerror(nErrors));
}
/* Reset the idle thread count */
m_unSenseControlPhaseIdleCounter = CSimulator::GetInstance().GetNumThreads();
m_unActPhaseIdleCounter = CSimulator::GetInstance().GetNumThreads();
m_unPhysicsPhaseIdleCounter = CSimulator::GetInstance().GetNumThreads();
m_unMediaPhaseIdleCounter = CSimulator::GetInstance().GetNumThreads();
/* Start threads */
StartThreads();
}
示例4: THROW_ARGOSEXCEPTION
void CARGoSCommandLineArgParser::Parse(SInt32 n_argc,
char** ppch_argv) {
CCommandLineArgParser::Parse(n_argc, ppch_argv);
/* Configure LOG/LOGERR coloring */
if(m_bNonColoredLog) {
LOG.DisableColoredOutput();
LOGERR.DisableColoredOutput();
}
/* Check whether LOG and LOGERR should go to files */
if(m_strLogFileName != "") {
LOG.DisableColoredOutput();
m_cLogFile.open(m_strLogFileName.c_str(), std::ios::trunc | std::ios::out);
if(m_cLogFile.fail()) {
THROW_ARGOSEXCEPTION("Error opening file \"" << m_strLogFileName << "\"");
}
m_pcInitLogStream = LOG.GetStream().rdbuf();
LOG.GetStream().rdbuf(m_cLogFile.rdbuf());
}
if(m_strLogErrFileName != "") {
LOGERR.DisableColoredOutput();
m_cLogErrFile.open(m_strLogErrFileName.c_str(), std::ios::trunc | std::ios::out);
if(m_cLogErrFile.fail()) {
THROW_ARGOSEXCEPTION("Error opening file \"" << m_strLogErrFileName << "\"");
}
m_pcInitLogErrStream = LOGERR.GetStream().rdbuf();
LOGERR.GetStream().rdbuf(m_cLogErrFile.rdbuf());
}
/* Check that either -h, -c or -q was passed (strictly one of them) */
if(m_strExperimentConfigFile == "" &&
m_strQuery == "" &&
! m_bHelpWanted) {
THROW_ARGOSEXCEPTION("No --help, --config-file or --query options specified.");
}
if((m_strExperimentConfigFile != "" && m_strQuery != "") ||
(m_strExperimentConfigFile != "" && m_bHelpWanted) ||
(m_strQuery != "" && m_bHelpWanted)) {
THROW_ARGOSEXCEPTION("Options --help, --config-file and --query are mutually exclusive.");
}
if(m_strExperimentConfigFile != "") {
m_eAction = ACTION_RUN_EXPERIMENT;
}
if(m_strQuery != "") {
m_eAction = ACTION_QUERY;
}
if(m_bHelpWanted) {
m_eAction = ACTION_SHOW_HELP;
}
}
示例5: GetNodeAttribute
void CEntity::Init(TConfigurationNode& t_tree) {
try {
/*
* Set the id of the entity from XML or type description
*/
/* Was an id specified explicitly? */
if(NodeAttributeExists(t_tree, "id")) {
/* Yes, use that */
GetNodeAttribute(t_tree, "id", m_strId);
}
else {
/* No, derive it from the parent */
if(m_pcParent != NULL) {
UInt32 unIdCount = 0;
while(GetParent().HasComponent(GetTypeDescription() +
"[" + GetTypeDescription() +
"_" + ToString(unIdCount) +
"]")) {
++unIdCount;
}
m_strId = GetTypeDescription() + "_" + ToString(unIdCount);
}
else {
THROW_ARGOSEXCEPTION("Root entities must provide the identifier tag");
}
}
}
catch(CARGoSException& ex) {
THROW_ARGOSEXCEPTION_NESTED("Failed to initialize an entity.", ex);
}
}
示例6: THROW_ARGOSEXCEPTION
void CSimulator::InitMedia(TConfigurationNode& t_tree) {
try {
/* Cycle through the media */
TConfigurationNodeIterator itMedia;
for(itMedia = itMedia.begin(&t_tree);
itMedia != itMedia.end();
++itMedia) {
/* Create the medium */
CMedium* pcMedium = CFactory<CMedium>::New(itMedia->Value());
try {
/* Initialize the medium */
pcMedium->Init(*itMedia);
/* Check that an medium with that ID does not exist yet */
if(m_mapMedia.find(pcMedium->GetId()) == m_mapMedia.end()) {
/* Add it to the lists */
m_mapMedia[pcMedium->GetId()] = pcMedium;
m_vecMedia.push_back(pcMedium);
}
else {
/* Duplicate id -> error */
THROW_ARGOSEXCEPTION("A medium with id \"" << pcMedium->GetId() << "\" exists already. The ids must be unique!");
}
}
catch(CARGoSException& ex) {
/* Error while executing medium init, destroy what done to prevent memory leaks */
pcMedium->Destroy();
delete pcMedium;
THROW_ARGOSEXCEPTION_NESTED("Error initializing medium type \"" << itMedia->Value() << "\"", ex);
}
}
}
catch(CARGoSException& ex) {
THROW_ARGOSEXCEPTION_NESTED("Failed to initialize the media. Parse error in the <media> subtree.", ex);
}
}
示例7: GetNodeAttribute
void CFloorEntity::Init(TConfigurationNode& t_tree) {
/* Init parent */
CEntity::Init(t_tree);
/* Get arena size */
m_cFloorSize = CSimulator::GetInstance().GetSpace().GetArenaSize();
/* Parse XML */
GetNodeAttribute(t_tree, "source", m_strColorSource);
if(m_strColorSource == "image") {
std::string strPath;
GetNodeAttribute(t_tree, "path", strPath);
strPath = ExpandARGoSInstallDir(strPath);
m_pcColorSource = new CFloorColorFromImageFile(strPath,
m_cFloorSize.GetX(),
m_cFloorSize.GetY());
}
else if(m_strColorSource == "loop_functions") {
GetNodeAttribute(t_tree, "pixels_per_meter", m_unPixelsPerMeter);
m_pcColorSource = new CFloorColorFromLoopFunctions(m_unPixelsPerMeter,
m_cFloorSize.GetX(),
m_cFloorSize.GetY());
}
else {
THROW_ARGOSEXCEPTION("Unknown image source \"" <<
m_strColorSource <<
"\" for the floor entity \"" <<
GetId() <<
"\"");
}
}
示例8: THROW_ARGOSEXCEPTION
void CLandmarks::Destroy() {
/* Close the output file */
m_cOutFile.close();
if(m_cOutFile.fail()) {
THROW_ARGOSEXCEPTION("Error closing file \"" << m_strOutFile << "\"");
}
}
示例9: UpdateFoodData
void CBTFootbotRecruiterRootBehavior::Step(CCI_FootBotState& c_robot_state) {
// Update Data
UpdateFoodData();
UpdateStateData();
// Decide which behaviour to execute
switch(m_sStateData.State) {
case SStateData::STATE_EXPLORING: {
Explore();
break;
}
case SStateData::STATE_SIGNAL_AND_PICK_UP: {
SignalPickUp();
break;
}
case SStateData::STATE_DROP: {
Drop();
break;
}
case SStateData::STATE_RETURN_TO_NEST: {
ReturnToNest();
break;
}
case SStateData::STATE_GO_TO_FOOD: {
GoToFood();
break;
}
default: {
THROW_ARGOSEXCEPTION("Invalid State");
}
}
}
示例10: GetNodeAttributeOrDefault
void CLuaController::Init(TConfigurationNode& t_tree) {
try {
/* Create RNG */
m_pcRNG = CRandom::CreateRNG("argos");
/* Load script */
std::string strScriptFileName;
GetNodeAttributeOrDefault(t_tree, "script", strScriptFileName, strScriptFileName);
if(strScriptFileName != "") {
SetLuaScript(strScriptFileName, t_tree);
if(! m_bIsOK) {
THROW_ARGOSEXCEPTION("Error loading Lua script \"" << strScriptFileName << "\": " << lua_tostring(m_ptLuaState, -1));
}
}
else {
/* Create a new Lua stack */
m_ptLuaState = luaL_newstate();
/* Load the Lua libraries */
luaL_openlibs(m_ptLuaState);
/* Create and set Lua state */
CreateLuaState();
SensorReadingsToLuaState();
}
}
catch(CARGoSException& ex) {
THROW_ARGOSEXCEPTION_NESTED("Error initializing Lua controller", ex);
}
}
示例11: THROW_ARGOSEXCEPTION
CPhysicsModel& CEmbodiedEntity::GetPhysicsModel(const std::string& str_engine_id) {
CPhysicsModel::TMap::iterator it = m_tPhysicsModelMap.find(str_engine_id);
if(it == m_tPhysicsModelMap.end()) {
THROW_ARGOSEXCEPTION("Entity \"" << GetContext() << GetId() << "\" has no associated entity in physics engine \"" << str_engine_id << "\"");
}
return *(it->second);
}
示例12: THROW_ARGOSEXCEPTION
CDirectionalLEDMedium& CDirectionalLEDEntity::GetMedium() const {
if(m_pcMedium == nullptr) {
THROW_ARGOSEXCEPTION("directional LED entity \"" << GetContext() <<
GetId() << "\" has no associated medium.");
}
return *m_pcMedium;
}
示例13: THROW_ARGOSEXCEPTION
void CRABEquippedEntity::SetData(const CByteArray& c_data) {
if(m_cData.Size() == c_data.Size()) {
m_cData = c_data;
}
else {
THROW_ARGOSEXCEPTION("CRABEquippedEntity::SetData() : data size does not match, expected " << m_cData.Size() << ", got " << c_data.Size());
}
}
示例14: THROW_ARGOSEXCEPTION
CCI_Actuator* CActuatorsFactory::NewActuator(const std::string& str_actuator_type,
const std::string& str_actuator_implementation) {
std::string strKey = str_actuator_type + " (" + str_actuator_implementation + ")";
if(GetActuatorPlugin()->FactoryMap.find(strKey) == GetActuatorPlugin()->FactoryMap.end()) {
THROW_ARGOSEXCEPTION("Actuator type \"" << str_actuator_type << "\", implementation \"" << str_actuator_implementation << "\" not found");
}
return GetActuatorPlugin()->FactoryMap[strKey]();
}
示例15: THROW_ARGOSEXCEPTION
const CComposableEntity& CEntity::GetParent() const {
if(m_pcParent != NULL) {
return *m_pcParent;
}
else {
THROW_ARGOSEXCEPTION("Entity \"" << GetId() << "\" has no parent");
}
}