00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef WIFI_TRACES_MERGE_HXX_
00023 # define WIFI_TRACES_MERGE_HXX_
00024
00025 # include "merge.hh"
00026
00027 # include <stdexcept>
00028
00029 # include <wipal/pcap/dumper.hh>
00030 # include <wipal/pcap/list_of_traces.hh>
00031 # include <wipal/wifi/frame/filter/merge.hh>
00032
00033 namespace wifi
00034 {
00035
00036 namespace traces
00037 {
00038
00040 namespace merge_helpers
00041 {
00042
00043 struct dump
00044 {
00045 dump(pcapxx::dumper& d): d_ (d)
00046 {
00047 }
00048
00049 template <class Merger>
00050 void
00051 operator () (const Merger& m)
00052 {
00053 m.for_each(d_);
00054 }
00055
00056 private:
00057 pcapxx::dumper& d_;
00058 };
00059
00060 template <class Trace>
00061 pcapxx::dumper
00062 pcap_dumper(const Trace& t, const std::string& output)
00063 {
00064 return t.dumper(output);
00065 }
00066
00067 template <>
00068 pcapxx::dumper
00069 pcap_dumper(const pcapxx::list_of_traces<>& t, const std::string& output)
00070 {
00071 if (t.empty())
00072 throw std::invalid_argument ("Empty trace");
00073
00074 return t.get(0).dumper(output);
00075 }
00076
00077 }
00078
00079 template <class UniqueId, class PhyHeader,
00080 template <class, class, class> class Intersector,
00081 template <class, class, class, class> class Merger,
00082 class T1, class T2>
00083 void
00084 merge(T1& t1,
00085 T2& t2,
00086 const std::string& output,
00087 tool::opt::list& options)
00088 {
00089 pcapxx::dumper pcap_dump = (merge_helpers::
00090 pcap_dumper(t2, output));
00091 merge_helpers::dump dump (pcap_dump);
00092
00093
00094 frame::filter::provide_merge<UniqueId, PhyHeader, Intersector, Merger>
00095 (t1.begin(), t1.end(), t2.begin(), t2.end(), options, dump);
00096 }
00097
00098 }
00099
00100 }
00101
00102 #endif // ! WIFI_TRACES_MERGE_HXX_