Logo
  • Main Page
  • Related Pages
  • Modules
  • Classes
  • Files

mmseventsignupmanager.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005-2007 Stefan Schwarzer, Jens Schneider,             *
00003  *                           Matthias Hardt, Guido Madaus                  *
00004  *                                                                         *
00005  *   Copyright (C) 2007-2008 BerLinux Solutions GbR                        *
00006  *                           Stefan Schwarzer & Guido Madaus               *
00007  *                                                                         *
00008  *   Copyright (C) 2009-2013 BerLinux Solutions GmbH                       *
00009  *                                                                         *
00010  *   Authors:                                                              *
00011  *      Stefan Schwarzer   <stefan.schwarzer@diskohq.org>,                 *
00012  *      Matthias Hardt     <matthias.hardt@diskohq.org>,                   *
00013  *      Jens Schneider     <jens.schneider@diskohq.org>,                   *
00014  *      Guido Madaus       <guido.madaus@diskohq.org>,                     *
00015  *      Patrick Helterhoff <patrick.helterhoff@diskohq.org>,               *
00016  *      René Bählkow       <rene.baehlkow@diskohq.org>                     *
00017  *                                                                         *
00018  *   This library is free software; you can redistribute it and/or         *
00019  *   modify it under the terms of the GNU Lesser General Public            *
00020  *   License version 2.1 as published by the Free Software Foundation.     *
00021  *                                                                         *
00022  *   This library is distributed in the hope that it will be useful,       *
00023  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00024  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00025  *   Lesser General Public License for more details.                       *
00026  *                                                                         *
00027  *   You should have received a copy of the GNU Lesser General Public      *
00028  *   License along with this library; if not, write to the                 *
00029  *   Free Software Foundation, Inc.,                                       *
00030  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
00031  **************************************************************************/
00032 
00033 #include "mmscore/mmseventsignupmanager.h"
00034 #include "mmstools/tools.h"
00035 #include <string.h>
00036 #include <algorithm>
00037 
00038 MMSEventSignupManager::MMSEventSignupManager() {
00039 }
00040 
00041 void MMSEventSignupManager::signup(IMMSEventSignup *signup) {
00042     this->signupmutex.lock();
00043     if(signup->isPlugin())
00044         this->signups.push_back((MMSEventSignup *)signup);
00045     else
00046         this->signals.push_back((MMSEventSignup *)signup);
00047 
00048     this->signupmutex.unlock();
00049 }
00050 
00051 vector<MMSPluginData *> MMSEventSignupManager::getReceiverPlugins(_IMMSEvent *event) {
00052     vector<MMSPluginData *> mydata;
00053 
00054     vector<string> subscriptions;
00055     vector<MMSEventSignup *>::iterator signit;
00056 
00057     string heading = event->getHeading();
00058 
00059     for(signit = this->signups.begin();signit != this->signups.end();signit++) {
00060         (*signit)->lock();
00061         subscriptions = (*signit)->getSubScriptions();
00062 
00063         for(vector<string>::iterator it = subscriptions.begin(); it != subscriptions.end(); ++it) {
00064             //DEBUGMSG("MMSEventSignupManager", "comparing %s - %s - %d\n", (*it).c_str(), heading.c_str(), (*it).size());
00065             if(heading.compare(0, (*it).size(), *it) == 0) {
00066                 MMSPluginData *myplugin = new MMSPluginData;
00067                 *myplugin = (*signit)->getPluginData();
00068                 mydata.push_back(myplugin);
00069             }
00070         }
00071         (*signit)->unlock();
00072     }
00073 
00074     if(mydata.empty())
00075         throw MMSEventSignupManagerError(0,"no subscriptions found for " + heading);
00076 
00077     return mydata;
00078 }
00079 
00080 vector<sigc::signal<void, _IMMSEvent*> *> MMSEventSignupManager::getReceiverSignals(_IMMSEvent *event) {
00081     vector<sigc::signal<void, _IMMSEvent*> *> mysignals;
00082     vector<string> subscriptions;
00083     vector<MMSEventSignup *>::iterator signupsit;
00084 
00085     string heading = event->getHeading();
00086 
00087     for(signupsit= this->signals.begin();signupsit != this->signals.end();++signupsit) {
00088         (*signupsit)->lock();
00089         subscriptions = (*signupsit)->getSubScriptions();
00090 
00091         for(vector<string>::iterator it = subscriptions.begin(); it != subscriptions.end(); ++it) {
00092             //DEBUGMSG("MMSEventSignupManager", "comparing %s - %s - %d\n", (*it).c_str(), heading.c_str(), (*it).size());
00093             if(heading.compare(0, (*it).size(), *it) == 0) {
00094                 mysignals.push_back((*signupsit)->getSignal());
00095             }
00096         }
00097         (*signupsit)->unlock();
00098     }
00099 
00100     if(mysignals.empty())
00101         throw MMSEventSignupManagerError(0,"no subscriptions found");
00102 
00103     return mysignals;
00104 
00105 }

Generated by doxygen