⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 predicate.h

📁 浙江大学 RoboCup3D 2006 源代码
💻 H
字号:
/*************************************************************************** *   Copyright (C) 2004 - 2006 by ZJUBase                                  *
 *                                National Lab of Industrial Control Tech. * *                                Zhejiang University, China               *
*                                                                         * *   Team members:                                                         *
 *    Currently the team leader is,                                        * *           Hao JIANG (jianghao@iipc.zju.edu.cn; riveria@gmail.com)       *
 *    In the next season, the leader will be                               * *           Yifeng ZHANG (yfzhang@iipc.zju.edu.cn)                        *
 *    ZJUBase 3D agent is created by                                       * *           Dijun LUO (djluo@iipc.zju.edu.cn)                             *
 *    All the members who has ever contributed:                            * *           Jun JIANG                                                     *
 *           Xinfeng DU (xfdu@iipc.zju.edu.cn)                             *
 *           Yang ZHOU (yzhou@iipc.zju.edu.cn)                             *
 *           Zhipeng YANG                                                  *
 *           Xiang FAN                                                     *
 *                                                                         *
 *   Team Manager:                                                          *
 *      Ms. Rong XIONG (rxiong@iipc.zju.edu.cn)                            *
 *                                                                         *
 *   If you met any problems or you have something to discuss about        * *   ZJUBase. Please feel free to contact us through EMails given below.   * *                                                                         * *   This program is free software; you can redistribute it and/or modify  * *   it under the terms of the GNU General Public License as published by  * *   the Free Software Foundation; either version 2 of the License, or     * *   (at your option) any later version.                                   * *                                                                         * *   This program is distributed in the hope that it will be useful,       * *   but WITHOUT ANY WARRANTY; without even the implied warranty of        * *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * *   GNU General Public License for more details.                          * *                                                                         * *   You should have received a copy of the GNU General Public License     * *   along with this program; if not, write to the                         * *   Free Software Foundation, Inc.,                                       * *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * ***************************************************************************/
#ifndef _PREDICATE_H
#define _PREDICATE_H

#include "global.h"
#include <string>
#include <cstdlib>
#include <map>
#include <vector>
using namespace std;

class Predicate : public multimap<string, vector<string> > {
public:
    string name;
    Predicate() : name("") {}
    virtual ~Predicate() {}
// get value without a iterator
    bool GetValue(const string& name, vector<string>& value) {
        iterator it = find(name);
        if (it == end()) {
            return false;
        }
        value = it->second;
        return true;
    }
    bool GetValue(const string& name, string& value) {
        vector <string> vv;
        if (GetValue(name, vv) == false || vv.size() < 1) {
            return false;
        }
        value = vv[0];
        return true;
    }
    bool GetValue(const string& name, double& value) {
        string vv;
        if (GetValue(name, vv) == false) {
            return false;
        }
        value = atof(vv.data());
        return true;
    }
    bool GetValue(const string& name, int& value) {
        string vv;
        if (GetValue(name, vv) == false) {
            return false;
        }
        value = atoi(vv.data());
        return true;
    }
// get value with a iterator
    bool GetValue(iterator it, const string& name, vector<string>& value) {
        if (it == end() || it->first != name) {
            return false;
        }
        value = it->second;
        return true;
    }
    bool GetValue(iterator it, const string& name, string& value) {
        vector <string> vv;
        if (GetValue(it, name, vv) == false || vv.size() < 1) {
            return false;
        }
        value = vv[0];
        return true;
    }
    bool GetValue(iterator it, const string& name, double& value) {
        string vv;
        if (GetValue(it, name, vv) == false) {
            return false;
        }
        value = atof(vv.data());
        return true;
    }
    bool GetValue(iterator it, const string& name, int& value) {
        string vv;
        if (GetValue(it, name, vv) == false) {
            return false;
        }
        value = atoi(vv.data());
        return true;
    }
// find
    bool FindParameter(const string& name) {
        return find(name) != end();
    }
};

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -