Menu

DefragPolicySelector.h

Go to the documentation of this file.
00001 /*******************************************************************************
00002  *
00003  * Copyright (c) 2009-2010 Philipp Werner <philipp.werner@st.ovgu.de>
00004  * All rights reserved.
00005  *
00006  *    Redistribution and use in source and binary forms, with or without
00007  *    modification, are permitted provided that the following conditions
00008  *    are met:
00009  *
00010  *    * Redistributions of source code must retain the above copyright
00011  *      notice, this list of conditions and the following disclaimer.
00012  *
00013  *    * Redistributions in binary form must reproduce the above copyright
00014  *      notice, this list of conditions and the following disclaimer in
00015  *      the documentation and/or other materials provided with the
00016  *      distribution.
00017  *
00018  *    * Neither the name of the copyright holders nor the names of
00019  *      contributors may be used to endorse or promote products derived
00020  *      from this software without specific prior written permission.
00021  *
00022  *
00023  *    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
00024  *    IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
00025  *    TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
00026  *    PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00027  *    OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00028  *    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00029  *    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00030  *    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00031  *    THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00032  *    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00033  *    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00034  *
00035  *
00036  * $Id$
00037  *
00038  ******************************************************************************/
00039 
00040 
00041 #ifndef __DEFRAGPOLICYSELECTOR_H_113525CAC772E0__
00042 #define __DEFRAGPOLICYSELECTOR_H_113525CAC772E0__
00043 
00044 
00045 #include "mw/afp/CommonPolicySelector.h"
00046 #include "mw/afp/EmptyType.h"
00047 
00048 
00049 // Policies
00050 #include "mw/afp/defrag/EventSeqHeaderSupport.h"
00051 #include "mw/afp/defrag/NoEventSeqHeaderSupport.h"
00052 
00053 #include "mw/afp/defrag/NoFECHeaderSupport.h"
00054 #include "mw/afp/defrag/FECHeaderSupport.h"
00055 
00056 #include "mw/afp/defrag/EventSeqDemux.h"
00057 #include "mw/afp/defrag/SingleEventDemux.h"
00058 #include "mw/afp/defrag/MultiSourceDemux.h"
00059 
00060 #include "mw/afp/defrag/InOrderEventDataReconstructor.h"
00061 #include "mw/afp/defrag/OutOfOrderEventDataReconstructor.h"
00062 #include "mw/afp/defrag/FECEventDataReconstructor.h"
00063 
00064 #include "mw/afp/defrag/NoDuplicateChecker.h"
00065 #include "mw/afp/defrag/DuplicateChecker.h"
00066 
00067 #include "mw/afp/defrag/Statistics.h"
00068 
00069 
00070 namespace famouso {
00071     namespace mw {
00072         namespace afp {
00073 
00081             typedef defrag::Statistics<EmptyType> DefragmentationStatistics;
00082 
00083             IF_CONTAINS_SELECT_TYPE_(SubjectType);
00084             IF_CONTAINS_SELECT_TYPE_(DefragStatistics);
00085 
00086             // TODO: support multiple publishers per subject
00087 
00088             // config: not only underlying net, but what to support
00089             template <typename Config>
00090             struct DefragPolicySelector {
00091                 typedef DefragPolicySelector ThisType;
00092                 typedef CommonPolicySelector<Config> Common;
00093 
00095                 typedef typename if_select_type<
00096                             !Config::event_seq,
00097                             typename if_select_type<
00098                                         Config::multiple_subjects,
00099                                         defrag::MultiSourceDemux<ThisType>,   // no eseq and multiple subjects
00100                                         defrag::SingleEventDemux<ThisType>    // no eseq and one subject
00101                             >::type,
00102                             defrag::EventSeqDemux<ThisType>                   // eseq and maybe multiple subjects
00103                         >::type DemuxPolicy;
00104 
00106                 typedef typename if_select_type<
00107                             Config::duplicates,
00108                             defrag::DuplicateChecker<ThisType>,               // dupliactes
00109                             defrag::NoDuplicateChecker<ThisType>              // no duplicates
00110                         >::type DuplicateCheckingPolicy;
00111 
00113                 typedef typename if_select_type<
00114                             Config::FEC,
00115                             defrag::FECEventDataReconstructor<ThisType>,                    // FEC support
00116                             typename if_select_type<
00117                                         Config::reordering,
00118                                         defrag::OutOfOrderEventDataReconstructor<ThisType>, // reordering
00119                                         defrag::InOrderEventDataReconstructor<ThisType>     // no reordering
00120                             >::type
00121                         >::type EventDataReconstructionPolicy;
00122 
00124                 typedef typename if_contains_select_type_SubjectType<
00125                             Config,
00126                             EmptyType
00127                         >::type SubjectType;
00128 
00130                 typedef typename if_select_type<
00131                             !Config::event_seq,
00132                             typename if_select_type<
00133                                         Config::multiple_subjects,
00134                                         defrag::SubjectDemuxKey<ThisType, SubjectType>, // ideal net and multiple subjects
00135                                         defrag::EmptyDemuxKey<ThisType, SubjectType>    // ideal net and one subject
00136                             >::type,
00137                             typename if_select_type<
00138                                         Config::multiple_subjects,
00139                                         defrag::EseqSubjectDemuxKey<ThisType, SubjectType>, // non ideal net and multiple subjects
00140                                         defrag::EseqDemuxKey<ThisType, SubjectType>         // non ideal net and one subject
00141                             >::type
00142                         >::type EventDemuxKey;
00143 
00144 
00146                 typedef typename if_select_type<
00147                             Config::defrag_statistics,
00148                             typename if_contains_select_type_DefragStatistics<
00149                                 Config,                         // Return Config::DefragStatistics if defined
00150                                 DefragmentationStatistics       // Default statistics otherwise
00151                             >::type,
00152                             defrag::NoStatistics                // No statistics
00153                         >::type DefragStatistics;
00154 
00156                 typedef typename Common::OverflowErrorChecking OverflowErrorChecking;
00157 
00159                 typedef typename Common::Allocator Allocator;
00160 
00162                 typedef typename Common::SizeProp SizeProp;
00163 
00164                 enum {
00166                     concurrent_events = Config::concurrent_events,
00167 
00169                     old_event_ids = Config::old_event_ids,
00170 
00172                     max_fragments = Config::max_fragments
00173                 };
00174             };
00175 
00176         } // namespace afp
00177     } // namespace mw
00178 } // namespace famouso
00179 
00180 
00181 #endif // __DEFRAGPOLICYSELECTOR_H_113525CAC772E0__
00182