UniSet
1.4.0
|
00001 /* This file is part of the UniSet project 00002 * Copyright (c) 2002 Free Software Foundation, Inc. 00003 * Copyright (c) 2002 Pavel Vainerman 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 */ 00019 // -------------------------------------------------------------------------- 00023 // -------------------------------------------------------------------------- 00024 #ifndef InfoServer_H_ 00025 #define InfoServer_H_ 00026 //--------------------------------------------------------------------------- 00027 #include <map> 00028 #include <list> 00029 #include "MessageType.h" 00030 #include "UniSetObject.h" 00031 #include "InfoServer_i.hh" 00032 //--------------------------------------------------------------------------- 00033 class ISRestorer; 00034 //--------------------------------------------------------------------------- 00078 class InfoServer: 00079 public UniSetObject, 00080 public POA_InfoServer_i 00081 { 00082 public: 00083 InfoServer( UniSetTypes::ObjectId id=UniSetTypes::DefaultObjectId, ISRestorer* d=0 ); 00084 virtual ~InfoServer(); 00085 00086 virtual UniSetTypes::ObjectType getType(){ return UniSetTypes::getObjectType("InfoServer"); } 00087 00088 00089 // реализация IDL интерфейса 00091 virtual void ackMessage(UniSetTypes::MessageCode msgid, const UniSetTypes::ConsumerInfo& ci, 00092 UniversalIO::UIOCommand cmd, CORBA::Boolean acknotify); 00094 virtual void ackMessageRange(UniSetTypes::MessageCode from, UniSetTypes::MessageCode to, 00095 const UniSetTypes::ConsumerInfo& ci, 00096 UniversalIO::UIOCommand cmd, CORBA::Boolean acknotify); 00097 00098 00100 struct ConsumerInfoExt: 00101 public UniSetTypes::ConsumerInfo 00102 { 00103 ConsumerInfoExt( UniSetTypes::ConsumerInfo ci, 00104 UniSetObject_i_ptr ref=0): 00105 ConsumerInfo(ci),ref(ref){} 00106 00107 UniSetObject_i_ptr ref; 00108 CORBA::Boolean ask; 00109 }; 00110 00112 typedef std::list<ConsumerInfoExt> ConsumerList; 00113 00115 typedef std::map<UniSetTypes::MessageCode,ConsumerList> AskMap; 00116 00117 00118 protected: 00119 // Функции обработки пришедших сообщений 00120 virtual void processingMessage( UniSetTypes::VoidMessage *msg ); 00121 00124 virtual void processing(UniSetTypes::AlarmMessage &amsg){}; 00127 virtual void processing(UniSetTypes::InfoMessage &imsg){}; 00130 virtual void processing(UniSetTypes::ConfirmMessage &cmsg){}; 00131 00132 00136 void preprocessing( UniSetTypes::TransportMessage& tmsg, bool broadcast ); 00137 void preprocessingConfirm( UniSetTypes::ConfirmMessage& am, bool broadcast ); 00138 00139 virtual bool activateObject(); 00140 00141 00145 virtual void dumpOrdersList(UniSetTypes::MessageCode mid, const ConsumerList& lst); 00146 00148 virtual void readDump(); 00149 00151 template<class TMessage> 00152 void event(UniSetTypes::MessageCode key, TMessage& msg, CORBA::Boolean askn); 00153 00154 //---------------------- 00156 template <class TMessage> 00157 void send(ConsumerList& lst, TMessage& msg, CORBA::Boolean acknotify); 00158 bool addConsumer(ConsumerList& lst, const UniSetTypes::ConsumerInfo& cons, CORBA::Boolean acknotify); 00159 bool removeConsumer(ConsumerList& lst, const UniSetTypes::ConsumerInfo& cons, CORBA::Boolean acknotify); 00160 00161 00163 void ask(AskMap& askLst, UniSetTypes::MessageCode key, 00164 const UniSetTypes::ConsumerInfo& cons, UniversalIO::UIOCommand cmd, 00165 CORBA::Boolean acknotify); 00166 00168 ISRestorer* restorer; 00169 00170 private: 00171 friend class ISRestorer; 00172 bool dbrepeat; 00175 AskMap askList; 00177 UniSetTypes::uniset_mutex askMutex; 00178 00179 std::list<UniSetTypes::ConsumerInfo> routeList; 00180 }; 00181 //--------------------------------------------------------------------------- 00182 #endif 00183 //---------------------------------------------------------------------------