• Classes
  • Modules
  • Namespaces
  • Files
  • Related Pages
  • File List
  • File Members

bulkDataNTReceiverStream.h

Go to the documentation of this file.
00001 #ifndef _BULK_DATA_NT_RECEIVER_STREAM_H_
00002 #define _BULK_DATA_NT_RECEIVER_STREAM_H_
00003 /*******************************************************************************
00004  * ALMA - Atacama Large Millimiter Array
00005  * (c) European Southern Observatory, 2011
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00020  *
00021  * "@(#) $Id: bulkDataNTReceiverStream.h,v 1.20 2012/10/15 09:46:17 bjeram Exp $"
00022  *
00023  * who       when      what
00024  * --------  --------  ----------------------------------------------
00025  * bjeram  2011-04-19  created
00026  */
00027 
00028 /************************************************************************
00029  *
00030  *----------------------------------------------------------------------
00031  */
00032 
00033 #ifndef __cplusplus
00034 #error This is a C++ include file and cannot be used from plain C
00035 #endif
00036 
00037 #include "bulkDataNTStream.h"
00038 #include "bulkDataNTReceiverFlow.h"
00039 #include <map>
00040 
00041 namespace AcsBulkdata
00042 {
00043 
00044 
00045 
00046 //TBD: actually we can move lots of stuff from BulkDataNTReceiverStream template class which do not depend on template parameter
00047 class BulkDataNTReceiverStreamBase : public BulkDataNTStream
00048 {
00049 public:
00050         BulkDataNTReceiverStreamBase(const char* streamName, const ReceiverStreamConfiguration &cfg):
00051                 BulkDataNTStream(streamName, cfg), receiverName_m("DefaultReceiver")
00052         {
00053                 flowUnicastPort_m = (cfg.isUseIncrementUnicastPort()) ? (cfg.getBaseUnicastPort()) : 0;
00054         }
00055 
00056         BulkDataNTReceiverStreamBase( const char* receiverName, const char* streamName, const ReceiverStreamConfiguration &cfg):
00057                         BulkDataNTStream(streamName, cfg), receiverName_m(receiverName)
00058         {
00059                 flowUnicastPort_m = (cfg.isUseIncrementUnicastPort()) ? (cfg.getBaseUnicastPort()) : ReceiverFlowConfiguration::DEFAULT_UNICAST_PORT/*=0*/;
00060         }
00061 
00066         void setReceiverName(char * recvName) { receiverName_m = recvName; }
00067 
00072         void setReceiverName(const char * recvName) { receiverName_m = recvName; }
00073 
00078         const char* getReceiverName() { return receiverName_m.c_str(); }
00079 
00084         unsigned short getNextFlowUnicastPort()
00085         {
00086                 unsigned short port=flowUnicastPort_m;
00087                 if (flowUnicastPort_m!=ReceiverFlowConfiguration::DEFAULT_UNICAST_PORT/*=0*/) flowUnicastPort_m++;
00088                 return port;
00089         }
00090 
00091 protected:
00092 
00093         std::string receiverName_m;
00094         unsigned short flowUnicastPort_m; 
00095 
00096 };//BulkDataNTReceiverStreamBase
00097 
00098 template<class TReceiverCallback>
00099 class BulkDataNTReceiverStream : public BulkDataNTReceiverStreamBase
00100 
00101 //, public AcsBulkdata::BulkDataNTDDSSubscriber
00102 
00103 {
00104 public:
00105 
00113         BulkDataNTReceiverStream(const char* streamName, const ReceiverStreamConfiguration &cfg=ReceiverStreamConfiguration(), bool enabledCallingCBforAllFlows=true);
00114 
00122         BulkDataNTReceiverStream(
00123                         const char* receiverName,
00124                         const char* streamName,
00125                         const ReceiverStreamConfiguration &cfg=ReceiverStreamConfiguration(),
00126                         bool enabledCallingCBforAllFlows=true);
00127 
00131         virtual ~BulkDataNTReceiverStream();
00132 
00133 
00142         BulkDataNTReceiverFlow* createFlow(const char *flowName, const ReceiverFlowConfiguration &cfg=ReceiverFlowConfiguration(),
00143                         BulkDataNTCallback *cb=0, bool releaseCB=false);
00144 
00151         BulkDataNTReceiverFlow* getFlow(const char* flowName);
00152 
00153 
00159         bool existFlow(const char* flowName);
00160 
00169         void createMultipleFlowsFromConfig(const char *config);
00170 
00179         std::vector<std::string> getFlowNames();
00180 
00185         unsigned int getFlowNumber();
00186 
00188         void enableCallingCBforAllFlows();
00189 
00191         void disableCallingCBforAllFlows();
00192 
00193 
00194 
00203 
00204 
00216 
00217 
00218         /*
00219          *  @throw ACSBulkDataError::AVNotificationMechanismErrorExImpl
00220          */
00222 
00223 
00224 
00226 
00227 
00228 protected:
00229 
00230         virtual void removeFlowFromMap(const char* flow);
00231 
00232         typedef std::map<std::string, BulkDataNTReceiverFlow*> ReceiverFlowMap;
00233         ReceiverFlowMap receiverFlows_m;
00234         // we need a flag that prevents elements to be removed from map when we delete flows from dtor
00235         bool notRemoveFromMap_m;
00236 
00237         bool enabledCallingCBforAllFlows_m;
00238 
00240         BulkDataNTReceiverStream();
00242         void operator=(const BulkDataNTReceiverStream&);
00244         BulkDataNTReceiverStream(const BulkDataNTReceiverStream&);
00245 };//class BulkDataNTReceiverStream
00246 
00247 };//namespace AcsBulkdata
00248 
00249 #include "bulkDataNTReceiverStream.i"
00250 
00251 #endif 

Generated on Mon May 4 2015 08:27:43 for ACS-2015.4 C++ API by  doxygen 1.7.0