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

📄 monitorserver.cpp

📁 linux 下的机器人足球仿真平台
💻 CPP
字号:
/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*-   this file is part of rcssserver3D   Fri May 9 2003   Copyright (C) 2002,2003 Koblenz University   Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group   $Id: monitorserver.cpp,v 1.8 2007/06/17 10:49:40 jboedeck Exp $   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; version 2 of the License.   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., 675 Mass Ave, Cambridge, MA 02139, USA.*/#include <zeitgeist/logserver/logserver.h>#include "monitorserver.h"#include "monitoritem.h"using namespace oxygen;using namespace boost;using namespace std;MonitorServer::MonitorServer() : Node(){}MonitorServer::~MonitorServer(){}boolMonitorServer::RegisterMonitorSystem(const std::string& monitorSysName){    // check if a monitor system of the requested type was already created    shared_ptr<MonitorSystem> monitorSys =        shared_dynamic_cast<MonitorSystem>(GetChildOfClass(monitorSysName));    if (monitorSys.get() != 0)    {        return true;    }    // create the monitor system    monitorSys = shared_dynamic_cast<MonitorSystem>(GetCore()->New(monitorSysName));    if (monitorSys.get() == 0)    {        GetLog()->Error() << "ERROR: (MonitorServer) Cannot create monitor system '"                          << monitorSysName << "'" << std::endl;        return false;    }    // link the monitor system in the hierarchy    monitorSys->SetName(monitorSysName);    if (! AddChildReference(monitorSys))        {            GetLog()->Error() << "ERROR: (MonitorServer) Cannot link the monitor system '"                              << monitorSysName << "' to the hierarchy\n";            return false;        }    GetLog()->Debug() << "(MonitorServer) Registered monitor system '"                      << monitorSysName << "'\n";    return true;}boolMonitorServer::RegisterMonitorItem(const std::string& monitorItemName){    // check if a monitor item of the requested type was already created    shared_ptr<MonitorItem> monitorItem =        shared_dynamic_cast<MonitorItem>(GetChildOfClass(monitorItemName));    if (monitorItem.get() != 0)    {        return true;    }    // create the monitor item    monitorItem = shared_dynamic_cast<MonitorItem>(GetCore()->New(monitorItemName));    if (monitorItem.get() == 0)    {        GetLog()->Error() << "ERROR: (MonitorServer) Cannot create monitor item '"                          << monitorItemName << "'" << std::endl;        return false;    }    // link the monitor item in the hierarchy    monitorItem->SetName(monitorItemName);    if (! AddChildReference(monitorItem))        {            GetLog()->Error() << "ERROR: (MonitorServer) Cannot link the monitor item '"                              << monitorItemName << "' to the hierarchy\n";            return false;        }    GetLog()->Debug() << "(MonitorServer) Registered monitor item '"                      << monitorItemName << "'\n";    return true;}boost::shared_ptr<MonitorSystem> MonitorServer::GetMonitorSystem(){    return shared_static_cast<MonitorSystem>        (         FindChildSupportingClass<MonitorSystem>()         );}voidMonitorServer::CollectItemPredicates(bool initial, PredicateList& pList){    Leaf::TLeafList itemList;    ListChildrenSupportingClass<MonitorItem>(itemList);    for (        Leaf::TLeafList::const_iterator iter = itemList.begin();        iter != itemList.end();        ++iter        )    {        shared_ptr<MonitorItem> item =            shared_static_cast<MonitorItem>(*iter);        if (initial)        {            item->GetInitialPredicates(pList);        } else        {            item->GetPredicates(pList);        }    }}string MonitorServer::GetMonitorHeaderInfo(){    shared_ptr<MonitorSystem> monitorSystem = GetMonitorSystem();    if (monitorSystem.get() == 0)    {        GetLog()->Warning()            << "WARNING: (MonitorServer) Monitor System missing.\n";        return string();    }    PredicateList pList;    CollectItemPredicates(true,pList);    return monitorSystem->GetMonitorHeaderInfo(pList);}string MonitorServer::GetMonitorInfo(){    shared_ptr<MonitorSystem> monitorSystem = GetMonitorSystem();    if (monitorSystem.get() == 0)        {            return string();        }    PredicateList pList;    CollectItemPredicates(false,pList);    return monitorSystem->GetMonitorInfo(pList);}void MonitorServer::ParseMonitorMessage(const string& data){    shared_ptr<MonitorSystem> monitorSystem = GetMonitorSystem();    if (monitorSystem.get() != 0)        {            monitorSystem->ParseMonitorMessage(data);        }}

⌨️ 快捷键说明

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