00001 /* Copyright (C) 2000 KOM/Darmstadt University of Technology 00002 * 00003 * You are allowed to use all other parts of the code under the following terms: 00004 * 00005 * For non-commercial use, code may be used in unmodified form provided 00006 * that this copyright notice and this permission notice appear in 00007 * supporting documentation. 00008 * 00009 * This software is provided "as is" and without any express or implied 00010 * warranties, including, without limitation, the implied warranty of 00011 * fitness for a particular purpose. 00012 * 00013 * The code may be subjected to the GNU General Public License, Version 2, 00014 * and re-distributed under the terms of this license. 00015 * As a special exception, permission is granted to link this code 00016 * with the Qt library and distribute executables, as long as you 00017 * follow the requirements of the GNU GPL in regard to all of the 00018 * software in the executable aside from Qt. 00019 * 00020 * Commercial use other than under the terms of the GNU General Public 00021 * License is allowed only after express negotiation of conditions 00022 * with the authors. 00023 */ 00024 #ifndef MN_CONCATINIZER_STREAM_HANDLER_H 00025 #define MN_CONCATINIZER_STREAM_HANDLER_H 00026 00027 #include <sys/types.h> 00028 #include <sys/time.h> 00029 00030 #include "SH.h" 00031 #include "SHEndpoint.h" 00032 #include "SHEndpointSpec.h" 00033 00034 #include "MNTimer.h" 00035 #include "MNTimerCall.h" 00036 00037 #include "MNThread.h" 00038 #include "MNList.h" 00039 #include "var_type.h" 00040 00041 namespace SH 00042 { 00043 00044 class ConcatinizerSH; 00045 class ConcatinizerSinkEndpoint; 00046 class ConcatinizerSourceEndpoint; 00047 00052 /**********************************************************************/ 00053 /* ConcatinizerSinkEndpoint */ 00054 /**********************************************************************/ 00055 00056 /* There is no push method because this streamhandler is ACTIVE only !!! 00057 * A call to push returns SH_ACTIVE as error message. 00058 */ 00059 class ConcatinizerSinkEndpoint 00060 : public SinkEndpoint 00061 { 00062 public: 00063 ConcatinizerSinkEndpoint( ConcatinizerSH* mySH ); 00064 virtual ~ConcatinizerSinkEndpoint( ); 00065 }; 00066 00067 /**********************************************************************/ 00068 /* ConcatinizerSourceEndpoint */ 00069 /**********************************************************************/ 00070 00071 /* There is no pull method because this streamhandler is ACTIVE only !!! 00072 * A call to pull returns SH_ACTIVE as error message. 00073 */ 00074 class ConcatinizerSourceEndpoint 00075 : public SourceEndpoint 00076 { 00077 public: 00078 ConcatinizerSourceEndpoint( ConcatinizerSH* mySH ); 00079 virtual ~ConcatinizerSourceEndpoint( ); 00080 }; 00081 00082 /**********************************************************************/ 00083 /* ConcatinizerSH */ 00084 /**********************************************************************/ 00085 00086 class ConcatinizerSH 00087 : public Base 00088 , public MNThread 00089 { 00093 SA_CONCATINIZER_MEM_THRESHOLD _memoryThreshold; 00094 00097 SA_CONCATINIZER_BUFFER_SIZE _bufferSize; 00098 00103 bool _memBuffer; 00104 00107 MNList<DataPtr> *_tmpBuffer; 00108 00112 SA_HAS_ORDERED_DATA _hasOrderedData; 00113 00120 long _lastPatchPos; 00121 long _lastMainPos; 00122 long _firstMainPos; 00123 00126 bool _patchActive; 00127 00130 bool _mainActive; 00131 00135 SA_CONCATINIZER_CACHING_ENABLED _cachingEnabled; 00136 00139 bool _run; 00140 00141 public: 00142 ConcatinizerSH( SHGraphManager* mgr, 00143 u_int32_t runtimeId, 00144 MNSelector& sel ); 00145 00146 private: 00147 00149 ConcatinizerSH( const ConcatinizerSH& ); 00150 00152 ConcatinizerSH& operator=( const ConcatinizerSH& ); 00153 00154 public: 00157 virtual SH_RC initSH(); 00160 virtual SH_RC uninitSH(); 00161 00164 virtual SH_RC startStreaming(); 00167 virtual SH_RC stopStreaming(); 00168 00169 //virtual void timer_callback ( MNTimer* timer, int fd ); 00170 00173 virtual void run(); 00174 00177 void patchComplete(); 00178 00181 void mainComplete(); 00182 00186 void createFileEndpoint(); 00187 00188 /******************************************************************/ 00189 /* additional attributes for the set() functions */ 00190 /******************************************************************/ 00191 00192 public: 00193 // Attributes have been moved to SH.h 00194 00195 /******************************************************************/ 00196 /* functions required for SHStatus */ 00197 /******************************************************************/ 00198 protected: 00199 friend class ConcatinizerSinkEndpoint; 00200 friend class ConcatinizerSourceEndpoint; 00201 00202 virtual void pushReport( ReportPtr report, Direction d ); 00203 00204 SinkEndpoint* _in_ep_a[2]; 00205 SourceEndpoint* _out_ep_a[2]; 00206 ConcatinizerSinkEndpoint _inEPpatch; 00207 ConcatinizerSinkEndpoint _inEPmain; 00208 ConcatinizerSourceEndpoint _outEPnet; 00209 ConcatinizerSourceEndpoint* _outEPfile; 00210 00211 public: 00212 virtual SinkEndpoint** getSinkSpecs(); 00213 virtual SourceEndpoint** getSourceSpecs(); 00214 00228 virtual bool isConnected() const; 00229 }; 00230 00232 00233 }; // namespace SH 00234 00235 #endif /* MN_CONCATINIZER_STREAM_HANDLER_H */ 00236