예제 #1
0
//--------------------------------------------------------------------------------//
void LinuxInputManager::_parseConfigSettings( ParamList &paramList )
{
	ParamList::iterator i = paramList.find("WINDOW");
	if( i == paramList.end() ) 
		OIS_EXCEPT( E_InvalidParam, "LinuxInputManager >> No WINDOW!" );

	//TODO 64 bit proof this little conversion xxx wip
	window  = strtoul(i->second.c_str(), 0, 10);

	//--------- Keyboard Settings ------------//
	i = paramList.find("XAutoRepeatOn");
	if( i != paramList.end() )
		if( i->second == "true" )
			useXRepeat = true;

	i = paramList.find("x11_keyboard_grab");
	if( i != paramList.end() )
		if( i->second == "false" )
			grabKeyboard = false;

	//--------- Mouse Settings ------------//
	i = paramList.find("x11_mouse_grab");
	if( i != paramList.end() )
		if( i->second == "false" )
			grabMouse = false;

	i = paramList.find("x11_mouse_hide");
	if( i != paramList.end() )
		if( i->second == "false" )
			hideMouse = false;
}
bool
Action::TimepointsMove::is_candidate(const ParamList &x)
{
	if(!candidate_check(get_param_vocab(),x))
		return false;

	if(	x.find("addlayer") == x.end() &&
		x.find("addcanvas") == x.end() &&
		x.find("addvaluedesc") == x.end())
		return false;
	return true;
}
/**
 * Function representing <par_dec_list> prods
 */
ParamList* RecursiveDescentParser::par_dec_list() {
	ParamList* retVal = NULL;
	if(errorCondition) return retVal;
	if(token == TK_INT || token == TK_CHAR) 
	{
#if DEBUG_PARSER
		std::cout << "<par_dec_list> --> <type><par_spec><par_dec_list_prime>;<par_dec_list>\n";
#endif
		Type t = type();
		VariableEntry* va = par_spec(t);
		
		retVal = par_dec_list_prime(t);
		retVal->push_front(va);
		
		match(TK_SEMICOLON);

		ParamList* pList = par_dec_list();
		retVal->splice(retVal->end(), *pList);
		delete(pList);
	} 
	else if(token == TK_LEFT_BRACE) 
	{
#if DEBUG_PARSER
		std::cout << "<par_dec_list> --> e\n";
#endif
		retVal = new ParamList();
	}
	else 
	{
		errorHandler();
	}
	
	return retVal;
}
예제 #4
0
//--------------------------------------------------------------------------------//
void Win32InputManager::_initialize( ParamList &paramList )
{
	HINSTANCE hInst = 0;
	HRESULT hr;


	//First of all, get the Windows Handle and Instance
	ParamList::iterator i = paramList.find("WINDOW");
	if( i == paramList.end() )
		OIS_EXCEPT( E_InvalidParam, "Win32InputManager::Win32InputManager >> No HWND found!" );

	// Get number as 64 bit and then convert. Handles the case of 32 or 64 bit HWND
	unsigned __int64 handle = _strtoui64(i->second.c_str(), 0, 10);
	hWnd  = (HWND)handle;

	if( IsWindow(hWnd) == 0 )
		OIS_EXCEPT( E_General, "Win32InputManager::Win32InputManager >> The sent HWND is not valid!");

	hInst = GetModuleHandle(0);

	//Create the device
	hr = DirectInput8Create( hInst, DIRECTINPUT_VERSION, IID_IDirectInput8, (VOID**)&mDirectInput, NULL );
    if (FAILED(hr))
		OIS_EXCEPT( E_General, "Win32InputManager::Win32InputManager >> Not able to init DirectX8 Input!");

	//Ok, now we have DirectInput, parse whatever extra settings were sent to us
	_parseConfigSettings( paramList );

	// Enumerate devices ...
	_enumerateDevices();
}
예제 #5
0
//--------------------------------------------------------------------------------//
void Win32InputManager::_parseConfigSettings( ParamList &paramList )
{
    //Here we pick up settings such as a device's cooperation mode
    std::map<std::string, DWORD> temp;
    temp["DISCL_BACKGROUND"]	= DISCL_BACKGROUND;
    temp["DISCL_EXCLUSIVE"]		= DISCL_EXCLUSIVE;
    temp["DISCL_FOREGROUND"]	= DISCL_FOREGROUND;
    temp["DISCL_NONEXCLUSIVE"]	= DISCL_NONEXCLUSIVE;
    temp["DISCL_NOWINKEY"]		= DISCL_NOWINKEY;

    //Check for pairs: ie. ("w32_keyboard","DISCL_NOWINKEY")("w32_keyboard","DISCL_FOREGROUND")
    ParamList::iterator i = paramList.begin(), e = paramList.end();
    for( ; i != e; ++i )
    {
        if( i->first == "w32_keyboard" )
            kbSettings |= temp[i->second];
        else if( i->first == "w32_mouse" )
            mouseSettings |= temp[i->second];
        else if( i->first == "w32_joystick" )
            joySettings |= temp[i->second];
    }
    if( kbSettings == 0 ) kbSettings = DISCL_FOREGROUND | DISCL_EXCLUSIVE;
    if( mouseSettings == 0 ) mouseSettings = DISCL_FOREGROUND | DISCL_EXCLUSIVE;
    if( joySettings == 0 ) joySettings = DISCL_FOREGROUND | DISCL_EXCLUSIVE;
}
예제 #6
0
//----------------------------------------------------------------------------
void Win32InputManager::ParseConfigSettings (ParamList &paramList)
{
	std::map<std::string, DWORD> temp;
	temp["DISCL_BACKGROUND"]	= DISCL_BACKGROUND;
	temp["DISCL_EXCLUSIVE"]		= DISCL_EXCLUSIVE;
	temp["DISCL_FOREGROUND"]	= DISCL_FOREGROUND;
	temp["DISCL_NONEXCLUSIVE"]	= DISCL_NONEXCLUSIVE;
	temp["DISCL_NOWINKEY"]		= DISCL_NOWINKEY;

	ParamList::iterator it = paramList.begin();
	for (; it!=paramList.end(); it++)
	{
		if (it->first == "Win32Keyboard")
		{
			mKeyboardSettings |= temp[it->second];
		}
		else if (it->first == "Win32Mouse")
		{
			mMouseSettings |= temp[it->second];
		}
	}

	if (0 == mKeyboardSettings)
	{
		mKeyboardSettings
			= DISCL_FOREGROUND | DISCL_NONEXCLUSIVE | DISCL_NOWINKEY;
	}

	if (0 == mMouseSettings)
	{
		mMouseSettings = DISCL_FOREGROUND | DISCL_NONEXCLUSIVE;
	}
}
예제 #7
0
//--------------------------------------------------------------------------------//
void Win32InputManager::_initialize( ParamList &paramList )
{
    HINSTANCE hInst = 0;
    HRESULT hr;

    //TODO 64 bit proof this little conversion xxx wip
    //First of all, get the Windows Handle and Instance
    ParamList::iterator i = paramList.find("WINDOW");
    if( i == paramList.end() )
        OIS_EXCEPT( E_InvalidParam, "Win32InputManager::Win32InputManager >> No HWND found!" );

#ifdef _MSC_VER
#pragma warning(disable:4312)
#endif
    hWnd  = (HWND)strtoul(i->second.c_str(), 0, 10);
#ifdef _MSC_VER
#pragma warning(default:4312)
#endif

    hInst = GetModuleHandle(0);

    //Create the device
    hr = DirectInput8Create( hInst, DIRECTINPUT_VERSION, IID_IDirectInput8, (VOID**)&mDirectInput, NULL );
    if (FAILED(hr))
        OIS_EXCEPT( E_General, "Win32InputManager::Win32InputManager >> Not able to init DirectX8 Input");

    //Ok, now we have DirectInput, parse whatever extra settings were sent to us
    _parseConfigSettings( paramList );
    _enumerateDevices();
}
예제 #8
0
//----------------------------------------------------------------------------
void Win32InputManager::Initialize (ParamList &paramList)
{
	HINSTANCE hInst = 0;
	HRESULT hr;

	ParamList::iterator i = paramList.find("Window");
	if (i == paramList.end()) 
	{
		assertion(false, 
			"Win32InputManager::Win32InputManager >> No HWND found!");
	}

	unsigned __int64 handle = _strtoui64(i->second.c_str(), 0, 10);
	mhWnd = (HWND)handle;

	if (IsWindow(mhWnd) == 0)
	{
		assertion(false, "The sent HWND is not valid!");
	}

	hInst = GetModuleHandle(0);

	hr = DirectInput8Create( hInst, DIRECTINPUT_VERSION, IID_IDirectInput8, 
		(VOID**)&mDirectInput, 0 );
	if (FAILED(hr))
	{
		assertion(false, "Not able to init DirectX8 Input!");
	}

	ParseConfigSettings(paramList);
	EnumerateDevices();
}
예제 #9
0
bool
Action::ValueDescLinkOpposite::is_candidate(const ParamList &x)
{
	// If action parameters are not Value Desc
	if(!candidate_check(get_param_vocab(),x))
		return false;

	int total_tangents=0;
	ParamList::const_iterator iter;
	//Search thru all the Param and pick up the value descriptions
	for(iter=x.begin(); iter!=x.end(); iter++)
	{
		if(iter->first == "value_desc")
		{
			ValueDesc v_desc(iter->second.get_value_desc());
			// if the value description parent is linkable value node, continue
			if(!v_desc.parent_is_linkable_value_node())
				return false;
			// if the link describe to any tangent (index 4 or 5), continue
			if(v_desc.get_index() != 4 && v_desc.get_index() != 5)
				return false;
			total_tangents++;
		}
	}
	// If we found two tangents then continue
	if(total_tangents!=2)
		return false;
	// We have reached exactly two tangents
	return true;
}
예제 #10
0
//--------------------------------------------------------------------------------//
void MacInputManager::_parseConfigSettings( ParamList &paramList )
{
    // Some carbon apps are running in a window, however full screen apps
	// do not have a window, so we need to account for that too.
	ParamList::iterator i = paramList.find("WINDOW");
	if(i != paramList.end())
	{
		mWindow = (WindowRef)strtoul(i->second.c_str(), 0, 10);
		if(mWindow == 0)
		{
			mWindow = NULL;
			mEventTargetRef = GetApplicationEventTarget();
		}
		else
		{
			//mEventTargetRef = GetWindowEventTarget(mWindow);
			mEventTargetRef = GetApplicationEventTarget();
		}
    }
	else
	{
		// else get the main active window.. user might not have access to it through some
		// graphics libraries, if that fails then try at the application level.
		mWindow = ActiveNonFloatingWindow();
		if(mWindow == NULL)
		{
			mEventTargetRef = GetApplicationEventTarget();
		}
		else
		{
			//mEventTargetRef = GetWindowEventTarget(mWindow);
			mEventTargetRef = GetApplicationEventTarget();
		}
	}
	
	if(mEventTargetRef == NULL)
		OIS_EXCEPT( E_General, "MacInputManager::_parseConfigSettings >> Unable to find a window or event target" );
    
    // Keyboard
    if(paramList.find("MacAutoRepeatOn") != paramList.end())
	{
        if(paramList.find("MacAutoRepeatOn")->second == "true")
		{
            mUseRepeat = true;
        }
    }
}
예제 #11
0
RobotInterface::ParamList RobotInterface::XMLReader::Private::readParamsTag(TiXmlElement *paramsElem)
{
    const std::string &valueStr = paramsElem->ValueStr();

    if (valueStr.compare("params") != 0) {
        SYNTAX_ERROR(paramsElem->Row()) << "Expected \"params\". Found" << valueStr;
    }

    std::string filename;
    if (paramsElem->QueryStringAttribute("file", &filename) == TIXML_SUCCESS) {
        // yDebug() << "Found params file [" << filename << "]";
#ifdef WIN32
        std::replace(filename.begin(), filename.end(), '/', '\\');
        filename = path + "\\" + filename;
#else // WIN32
        filename = path + "/" + filename;
#endif //WIN32
        return readParamsFile(filename);
    }

    std::string robotName;
    if (paramsElem->QueryStringAttribute("robot", &robotName) != TIXML_SUCCESS) {
        SYNTAX_WARNING(paramsElem->Row()) << "\"params\" element should contain the \"robot\" attribute";
    }

    if (robotName != robot.name()) {
        SYNTAX_WARNING(paramsElem->Row()) << "Trying to import a file for the wrong robot. Found" << robotName << "instead of" << robot.name();
    }

    unsigned int build;
#if TINYXML_UNSIGNED_INT_BUG
    if (paramsElem->QueryUnsignedAttribute("build", &build()) != TIXML_SUCCESS) {
        // No build attribute. Assuming build="0"
        SYNTAX_WARNING(paramsElem->Row()) << "\"params\" element should contain the \"build\" attribute [unsigned int]. Assuming 0";
    }
#else
    int tmp;
    if (paramsElem->QueryIntAttribute("build", &tmp) != TIXML_SUCCESS || tmp < 0) {
        // No build attribute. Assuming build="0"
        SYNTAX_WARNING(paramsElem->Row()) << "\"params\" element should contain the \"build\" attribute [unsigned int]. Assuming 0";
        tmp = 0;
    }
    build = (unsigned)tmp;
#endif

    if (build != robot.build()) {
        SYNTAX_WARNING(paramsElem->Row()) << "Import a file for a different robot build. Found" << build << "instead of" << robot.build();
    }

    ParamList params;
    for (TiXmlElement* childElem = paramsElem->FirstChildElement(); childElem != 0; childElem = childElem->NextSiblingElement()) {
        ParamList childParams = readParams(childElem);
        for (ParamList::const_iterator it = childParams.begin(); it != childParams.end(); ++it) {
            params.push_back(*it);
        }
    }

    return params;
}
예제 #12
0
void
Action::Base::set_param_list(const ParamList &param_list)
{
	ParamList::const_iterator iter;

	for(iter=param_list.begin();iter!=param_list.end();++iter)
		set_param(iter->first,iter->second);
}
void AndroidInputManager::_initialize( ParamList &paramList )
{
        ParamList::iterator i = paramList.find("WINDOW");
        if(i != paramList.end())
        {
                size_t whandle = strtoul(i->second.c_str(), 0, 10);            
    }

        //TODO: setup window
}
예제 #14
0
 yarp::os::Property paramsAsProperty() const
 {
     ParamList p = RobotInterface::mergeDuplicateGroups(params);
     std::string s;
     s += "(device " + type + ")";
     for (RobotInterface::ParamList::const_iterator it = p.begin(); it != p.end(); ++it) {
         const RobotInterface::Param &param = *it;
         s += " (" + param.name() + " " + param.value() + ")";
     }
     return yarp::os::Property(s.c_str());
 }
예제 #15
0
bool
Action::LayerResetPose::is_candidate(const ParamList &x)
{
	if(!candidate_check(get_param_vocab(),x))
		return false;

	for(ParamList::const_iterator i = x.find("layer"); i != x.end() && i->first == "layer"; ++i)
		if (i->second.get_type()==Param::TYPE_LAYER
		 && i->second.get_layer()->get_name() == "skeleton_deformation")
			return true;

	return false;
}
예제 #16
0
RobotInterface::ParamList RobotInterface::XMLReader::Private::readParamListTag(TiXmlElement* paramListElem)
{
    if (paramListElem->ValueStr().compare("paramlist") != 0) {
        SYNTAX_ERROR(paramListElem->Row()) << "Expected \"paramlist\". Found" << paramListElem->ValueStr();
    }

    ParamList params;
    Param mainparam;

    if (paramListElem->QueryStringAttribute("name", &mainparam.name()) != TIXML_SUCCESS) {
        SYNTAX_ERROR(paramListElem->Row()) << "\"paramlist\" element should contain the \"name\" attribute";
    }

    params.push_back(mainparam);

    // yDebug() << "Found paramlist [" << params.at(0).name() << "]";

    for (TiXmlElement* childElem = paramListElem->FirstChildElement(); childElem != 0; childElem = childElem->NextSiblingElement()) {
        if (childElem->ValueStr().compare("elem") != 0) {
            SYNTAX_ERROR(childElem->Row()) << "Expected \"elem\". Found" << childElem->ValueStr();
        }

        Param childParam;

        if (childElem->QueryStringAttribute("name", &childParam.name()) != TIXML_SUCCESS) {
            SYNTAX_ERROR(childElem->Row()) << "\"elem\" element should contain the \"name\" attribute";
        }

        const char *valueText = childElem->GetText();
        if (!valueText) {
            SYNTAX_ERROR(childElem->Row()) << "\"elem\" element should have a value [ \"name\" = " << childParam.name() << "]";
        }
        childParam.value() = valueText;

        params.push_back(childParam);
    }

    if (params.empty()) {
        SYNTAX_ERROR(paramListElem->Row()) << "\"paramlist\" cannot be empty";
    }

    // +1 skips the first element, that is the main param
    for (ParamList::iterator it = params.begin() + 1; it != params.end(); ++it) {
        Param &param = *it;
        params.at(0).value() += (params.at(0).value().empty() ? "(" : " ") + param.name();
    }
    params.at(0).value() += ")";

    // yDebug() << params;
    return params;
}
예제 #17
0
RobotInterface::Param RobotInterface::XMLReader::Private::readGroupTag(TiXmlElement* groupElem)
{
    if (groupElem->ValueStr().compare("group") != 0) {
        SYNTAX_ERROR(groupElem->Row()) << "Expected \"group\". Found" << groupElem->ValueStr();
    }

    Param group(true);

    if (groupElem->QueryStringAttribute("name", &group.name()) != TIXML_SUCCESS) {
        SYNTAX_ERROR(groupElem->Row()) << "\"group\" element should contain the \"name\" attribute";
    }

    // yDebug() << "Found group [" << group.name() << "]";

    ParamList params;
    for (TiXmlElement* childElem = groupElem->FirstChildElement(); childElem != 0; childElem = childElem->NextSiblingElement()) {
        ParamList childParams = readParams(childElem);
        for (ParamList::const_iterator it = childParams.begin(); it != childParams.end(); ++it) {
            params.push_back(*it);
        }
    }
    if (params.empty()) {
        SYNTAX_ERROR(groupElem->Row()) << "\"group\" cannot be empty";
    }

    std::string groupString;
    for (ParamList::iterator it = params.begin(); it != params.end(); ++it) {
        if (!groupString.empty()) {
            groupString += " ";
        }
        groupString += "(" + it->name() + " " + it->value() + ")";
    }

    group.value() = groupString;

    return group;
}
예제 #18
0
RobotInterface::Robot& RobotInterface::XMLReader::Private::readRobotTag(TiXmlElement *robotElem)
{
    if (robotElem->ValueStr().compare("robot") != 0) {
        SYNTAX_ERROR(robotElem->Row()) << "Root element should be \"robot\". Found" << robotElem->ValueStr();
    }

    if (robotElem->QueryStringAttribute("name", &robot.name()) != TIXML_SUCCESS) {
        SYNTAX_ERROR(robotElem->Row()) << "\"robot\" element should contain the \"name\" attribute";
    }

#if TINYXML_UNSIGNED_INT_BUG
    if (robotElem->QueryUnsignedAttribute("build", &robot.build()) != TIXML_SUCCESS) {
        // No build attribute. Assuming build="0"
        SYNTAX_WARNING(robotElem->Row()) << "\"robot\" element should contain the \"build\" attribute [unsigned int]. Assuming 0";
    }
#else
    int tmp;
    if (robotElem->QueryIntAttribute("build", &tmp) != TIXML_SUCCESS || tmp < 0) {
        // No build attribute. Assuming build="0"
        SYNTAX_WARNING(robotElem->Row()) << "\"robot\" element should contain the \"build\" attribute [unsigned int]. Assuming 0";
        tmp = 0;
    }
    robot.build() = (unsigned)tmp;
#endif

    if (robotElem->QueryStringAttribute("portprefix", &robot.portprefix()) != TIXML_SUCCESS) {
        SYNTAX_WARNING(robotElem->Row()) << "\"robot\" element should contain the \"portprefix\" attribute. Using \"name\" attribute";
        robot.portprefix() = robot.name();
    }

    // yDebug() << "Found robot [" << robot.name() << "] build [" << robot.build() << "] portprefix [" << robot.portprefix() << "]";

    for (TiXmlElement* childElem = robotElem->FirstChildElement(); childElem != 0; childElem = childElem->NextSiblingElement()) {
        if (childElem->ValueStr().compare("device") == 0 || childElem->ValueStr().compare("devices") == 0) {
            DeviceList childDevices = readDevices(childElem);
            for (DeviceList::const_iterator it = childDevices.begin(); it != childDevices.end(); ++it) {
                robot.devices().push_back(*it);
            }
        } else {
            ParamList childParams = readParams(childElem);
            for (ParamList::const_iterator it = childParams.begin(); it != childParams.end(); ++it) {
                robot.params().push_back(*it);
            }
        }
    }

    return robot;
}
예제 #19
0
bool
Action::ColorSet::is_candidate(const ParamList &x)
{
	if (!candidate_check(get_param_vocab(), x))
		return false;

	std::multimap<synfig::String, Param>::const_iterator iter;
	for (iter = x.begin(); iter != x.end(); ++iter)
	{
		if (iter->first == "value_desc" &&
				iter->second.get_value_desc().get_value_type() != type_color)
			return false;
	}

	return true;
}
void RecursiveDescentParser::matchParameters(FunctionEntry* fEntry, ParamList* &callerParams, Token tk) {
	if(fEntry->getEntryType()!=TableEntry::FUNCTION) return;
	
	int paramCount = 1;
	ParamList* declParams = fEntry->getParamaterList();
	
	ParamList::iterator j=callerParams->begin();

	for(ParamList::iterator i=declParams->begin();
		i!=declParams->end();
		++i)
	{
		if(j==callerParams->end()) {
			std::stringstream errorMsg;
			errorMsg << "Function '" << fEntry->getName() << "' does not take " 
				<< paramCount-1 << " parameter(s)";
			errorHandler(errorMsg.str(), tk);
			return;
		}
		
		if((*i)->getType() != (*j)->getType()) {
			std::stringstream errorMsg;
			errorMsg << "Parameter " << paramCount << " should be of type " 
				<< (((*i)->getType()==T_INT)? "'int'" : "'char'");
			errorHandler(errorMsg.str(), tk);
		} 
		
		if((*i)->getAttribute() != (*j)->getAttribute()) {
			std::stringstream errorMsg;
			errorMsg << "Parameter " << paramCount << " should "
				<< (((*i)->getAttribute()==VA_SIMPLE)? "not " : "")
				<< "be an array";
			errorHandler(errorMsg.str(), tk);
		}
		
		++paramCount;
		++j;
	}
	
	if(j!=callerParams->end()) {
		std::stringstream errorMsg;
		errorMsg << "Function '" << fEntry->getName() << "' only takes " 
			<< declParams->size() << " parameter(s)";
		errorHandler(errorMsg.str(), tk);
	}
}
예제 #21
0
RobotInterface::Action RobotInterface::XMLReader::Private::readActionTag(TiXmlElement* actionElem)
{
    if (actionElem->ValueStr().compare("action") != 0) {
        SYNTAX_ERROR(actionElem->Row()) << "Expected \"action\". Found" << actionElem->ValueStr();
    }

    Action action;

    if (actionElem->QueryValueAttribute<ActionPhase>("phase", &action.phase()) != TIXML_SUCCESS || action.phase() == ActionPhaseUnknown) {
        SYNTAX_ERROR(actionElem->Row()) << "\"action\" element should contain the \"phase\" attribute [startup|interrupt{1,2,3}|shutdown]";
    }


    if (actionElem->QueryValueAttribute<ActionType>("type", &action.type()) != TIXML_SUCCESS || action.type() == ActionTypeUnknown) {
        SYNTAX_ERROR(actionElem->Row()) << "\"action\" element should contain the \"type\" attribute [configure|calibrate|attach|abort|detach|park|custom]";
    }

    // yDebug() << "Found action [ ]";

#if TINYXML_UNSIGNED_INT_BUG
    if (actionElem->QueryUnsignedAttribute("level", &action.level()) != TIXML_SUCCESS) {
        SYNTAX_ERROR(actionElem->Row()) << "\"action\" element should contain the \"level\" attribute [unsigned int]";
    }
#else
    int tmp;
    if (actionElem->QueryIntAttribute("level", &tmp) != TIXML_SUCCESS || tmp < 0) {
        SYNTAX_ERROR(actionElem->Row()) << "\"action\" element should contain the \"level\" attribute [unsigned int]";
    }
    action.level() = (unsigned)tmp;
#endif

    for (TiXmlElement* childElem = actionElem->FirstChildElement(); childElem != 0; childElem = childElem->NextSiblingElement()) {
        ParamList childParams = readParams(childElem);
        for (ParamList::const_iterator it = childParams.begin(); it != childParams.end(); ++it) {
            action.params().push_back(*it);
        }
    }

    // yDebug() << action;
    return action;
}
예제 #22
0
RobotInterface::Device RobotInterface::XMLReader::Private::readDeviceTag(TiXmlElement *deviceElem)
{
    const std::string &valueStr = deviceElem->ValueStr();

    if (valueStr.compare("device") != 0) {
        SYNTAX_ERROR(deviceElem->Row()) << "Expected \"device\". Found" << valueStr;
    }

    Device device;

    if (deviceElem->QueryStringAttribute("name", &device.name()) != TIXML_SUCCESS) {
        SYNTAX_ERROR(deviceElem->Row()) << "\"device\" element should contain the \"name\" attribute";
    }

    // yDebug() << "Found device [" << device.name() << "]";

    if (deviceElem->QueryStringAttribute("type", &device.type()) != TIXML_SUCCESS) {
        SYNTAX_ERROR(deviceElem->Row()) << "\"device\" element should contain the \"type\" attribute";
    }

    device.params().push_back(Param("robotName", robot.portprefix().c_str()));

    for (TiXmlElement* childElem = deviceElem->FirstChildElement(); childElem != 0; childElem = childElem->NextSiblingElement()) {
        if (childElem->ValueStr().compare("action") == 0 ||
            childElem->ValueStr().compare("actions") == 0) {
            ActionList childActions = readActions(childElem);
            for (ActionList::const_iterator it = childActions.begin(); it != childActions.end(); ++it) {
                device.actions().push_back(*it);
            }
        } else {
            ParamList childParams = readParams(childElem);
            for (ParamList::const_iterator it = childParams.begin(); it != childParams.end(); ++it) {
                device.params().push_back(*it);
            }
        }
    }

    // yDebug() << device;
    return device;
}
예제 #23
0
RobotInterface::ParamList RobotInterface::XMLReader::Private::readSubDeviceTag(TiXmlElement *subDeviceElem)
{
    if (subDeviceElem->ValueStr().compare("subdevice") != 0) {
        SYNTAX_ERROR(subDeviceElem->Row()) << "Expected \"subdevice\". Found" << subDeviceElem->ValueStr();
    }

    ParamList params;

//FIXME    Param featIdParam;
    Param subDeviceParam;

//FIXME    featIdParam.name() = "FeatId";
    subDeviceParam.name() = "subdevice";

//FIXME    if (subDeviceElem->QueryStringAttribute("name", &featIdParam.value()) != TIXML_SUCCESS) {
//        SYNTAX_ERROR(subDeviceElem->Row()) << "\"subdevice\" element should contain the \"name\" attribute";
//    }

    if (subDeviceElem->QueryStringAttribute("type", &subDeviceParam.value()) != TIXML_SUCCESS) {
        SYNTAX_ERROR(subDeviceElem->Row()) << "\"subdevice\" element should contain the \"type\" attribute";
    }

//FIXME    params.push_back(featIdParam);
    params.push_back(subDeviceParam);

    // yDebug() << "Found subdevice [" << params.at(0).value() << "]";

    for (TiXmlElement* childElem = subDeviceElem->FirstChildElement(); childElem != 0; childElem = childElem->NextSiblingElement()) {
        ParamList childParams = readParams(childElem);
        for (ParamList::const_iterator it = childParams.begin(); it != childParams.end(); ++it) {
            params.push_back(Param(it->name(), it->value()));
        }
    }

    // yDebug() << params;
    return params;
}