SetLogLevelOrd.hpp
上传用户:romrleung
上传日期:2022-05-23
资源大小:18897k
文件大小:2k
源码类别:

MySQL数据库

开发平台:

Visual C++

  1. /* Copyright (C) 2003 MySQL AB
  2.    This program is free software; you can redistribute it and/or modify
  3.    it under the terms of the GNU General Public License as published by
  4.    the Free Software Foundation; either version 2 of the License, or
  5.    (at your option) any later version.
  6.    This program is distributed in the hope that it will be useful,
  7.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  8.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  9.    GNU General Public License for more details.
  10.    You should have received a copy of the GNU General Public License
  11.    along with this program; if not, write to the Free Software
  12.    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
  13. #ifndef SET_LOGLEVEL_ORD_HPP
  14. #define SET_LOGLEVEL_ORD_HPP
  15. #include <LogLevel.hpp>
  16. #include "EventSubscribeReq.hpp"
  17. #include "SignalData.hpp"
  18. /**
  19.  * 
  20.  */
  21. class SetLogLevelOrd {
  22.   /**
  23.    * Sender(s)
  24.    */
  25.   friend class MgmtSrvr; /* XXX can probably be removed */
  26.   friend class MgmApiSession;
  27.   friend class CommandInterpreter;
  28.   
  29.   /**
  30.    * Reciver(s)
  31.    */
  32.   friend class Cmvmi;
  33.   friend class NodeLogLevel;
  34.   
  35. private:
  36.   STATIC_CONST( SignalLength = 1 + LogLevel::LOGLEVEL_CATEGORIES  );
  37.   
  38.   Uint32 noOfEntries;
  39.   Uint32 theData[LogLevel::LOGLEVEL_CATEGORIES];
  40.   
  41.   void clear();
  42.   
  43.   /**
  44.    * Note level is valid as 0-15
  45.    */
  46.   void setLogLevel(LogLevel::EventCategory ec, int level = 7);
  47.   
  48.   SetLogLevelOrd& operator= (const LogLevel& ll){
  49.     noOfEntries = LogLevel::LOGLEVEL_CATEGORIES;
  50.     for(size_t i = 0; i<noOfEntries; i++){
  51.       theData[i] = (i << 16) | ll.getLogLevel((LogLevel::EventCategory)i);
  52.     }
  53.     return * this;
  54.   }
  55.   SetLogLevelOrd& operator= (const EventSubscribeReq& ll){
  56.     noOfEntries = ll.noOfEntries;
  57.     for(size_t i = 0; i<noOfEntries; i++){
  58.       theData[i] = ll.theData[i];
  59.     }
  60.     return * this;
  61.   }
  62. };
  63. inline
  64. void
  65. SetLogLevelOrd::clear(){
  66.   noOfEntries = 0;
  67. }
  68. inline
  69. void
  70. SetLogLevelOrd::setLogLevel(LogLevel::EventCategory ec, int level){
  71.   theData[noOfEntries] = (ec << 16) | level;
  72.   noOfEntries++;
  73. }
  74. #endif