Binding.cpp

Go to the documentation of this file.
00001 /*
00002  * This file is part of Micole Architecture
00003  *
00004  * Copyright (C) 2007 Micole partners
00005  *
00006  * Micole Architecture is free software: you can redistribute it 
00007  * and/or modify it under the terms of the GNU Lesser General 
00008  * Public License as published by the Free Software Foundation, 
00009  * either version 3 of the License, or (at your option) any 
00010  * later version.
00011  *
00012  * Micole Architecture is distributed in the hope that it will be 
00013  * useful, * but WITHOUT ANY WARRANTY; without even the implied 
00014  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00015  * PURPOSE.  See the GNU Lesser General Public License for more 
00016  * details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public
00019  * License along with Micole Architecture.  If not, see
00020  * <http://www.gnu.org/licenses/>.
00021  */
00022 
00023 #include "stdafx.h"
00024 #include "Binding.h"
00025 #include <string.h>
00026 
00027 //Should not be used...
00028 MicoleBinding::MicoleBinding()
00029 :_regexp(_strdup("")), _cb(NULL), _bus(NULL)
00030 {
00031 }
00032 
00033 MicoleBinding::MicoleBinding(const char *regexp, MicoleBus *bus, MicoleCallback * cb)
00034 :_regexp(_strdup(regexp)), _cb(cb), _bus(bus)
00035 {
00036         bus->bindMsg(string(regexp), cb);
00037 }
00038 
00039 
00040 void MicoleBinding::unbindMsg() {
00041         _bus->unbindMsg(_cb);
00042 }
00043 
00044 MicoleBinding::~MicoleBinding()
00045 {
00046         free(_regexp);
00047 }
00048 
00049 MicoleBinding::MicoleBinding(const MicoleBinding &b)
00050 :_regexp(_strdup(b._regexp))
00051 {
00052 /*
00053         _regexp = NULL;
00054         setRegexp(b._regexp);
00055         callback = b.callback;
00056         bind_id = b.bind_id;*/
00057 }
00058 
00064 void MicoleBinding::setRegexp(const char * pRegexp)
00065 {
00066         if(_regexp != NULL) 
00067                 free(_regexp);
00068 
00069         //char * tmpS = (char *)malloc((strlen(pRegexp)+1)*sizeof(char));
00070         //strcpy(tmpS, pRegexp);
00071         //_regexp = tmpS;
00072         _regexp = _strdup(pRegexp);
00073 }

Generated on Tue Oct 16 17:10:42 2007 for Micole by  doxygen 1.4.7