00001 /*************************************************************************** 00002 * Copyright (C) 2005 by Robot Group Leipzig * 00003 * martius@informatik.uni-leipzig.de * 00004 * fhesse@informatik.uni-leipzig.de * 00005 * der@informatik.uni-leipzig.de * 00006 * guettler@informatik.uni-leipzig.de * 00007 * * 00008 * This program is free software; you can redistribute it and/or modify * 00009 * it under the terms of the GNU General Public License as published by * 00010 * the Free Software Foundation; either version 2 of the License, or * 00011 * (at your option) any later version. * 00012 * * 00013 * This program is distributed in the hope that it will be useful, * 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00016 * GNU General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU General Public License * 00019 * along with this program; if not, write to the * 00020 * Free Software Foundation, Inc., * 00021 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00022 *************************************************************************** 00023 * * 00024 * DESCRIPTION * 00025 * 00026 * * 00027 * * 00028 * $Log: mediator.h,v $ 00029 * Revision 1.2 2010/03/08 15:42:49 martius 00030 * unsigned 00031 * 00032 * Revision 1.1 2009/08/10 07:34:49 guettler 00033 * -Base classes which support use of design pattern 00034 * mediator - similar to callbackable, but with more functionality: 00035 * The mediator takes a more central role in mediation, the collegues 00036 * are able to inform the mediator that something happend with 00037 * easy use of mediated events (MediatorEvent). 00038 * * 00039 * * 00040 **************************************************************************/ 00041 #ifndef __MEDIATOR_H_ 00042 #define __MEDIATOR_H_ 00043 00044 00045 #include "mediatorcollegue.h" 00046 #include <vector> 00047 00048 /** 00049 * The default MediatorEvent holds no information, 00050 * the implementation of the mediator should implement a 00051 * derived version of the MediatorEvent. 00052 */ 00053 class MediatorEvent 00054 { 00055 public: 00056 }; 00057 00058 class Mediator 00059 { 00060 public: 00061 typedef std::vector<MediatorCollegue*> MediatorCollegueListType; 00062 00063 Mediator(); 00064 virtual ~Mediator(); 00065 00066 virtual void mediatorInformed(MediatorCollegue* source, MediatorEvent* event) = 0; 00067 00068 void addMediatorCollegue(MediatorCollegue* collegue); 00069 00070 void removeAllMediatorCollegues(); 00071 00072 MediatorCollegue* getMediatorCollegue(unsigned int index); 00073 00074 unsigned int getMediatorCollegueIndex(MediatorCollegue* collegue); 00075 00076 unsigned int getNumberOfMediatorCollegues(); 00077 00078 void mediate(unsigned int indexOfMediatorCollegue, MediatorEvent* event); 00079 00080 void mediate(MediatorCollegue* collegue, MediatorEvent* event); 00081 00082 void mediateToAll(MediatorEvent* event); 00083 00084 void mediateToAllQMP(MediatorEvent* event); 00085 00086 00087 00088 protected: 00089 00090 00091 private: 00092 MediatorCollegueListType collegueList; 00093 }; 00094 00095 #endif /* _MEDIATOR_H_ */