os/ossrv/stdcpp/tsrc/Boost_test/graph/src/serialize.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/stdcpp/tsrc/Boost_test/graph/src/serialize.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,99 @@
     1.4 +// Copyright (C) 2006 Trustees of Indiana University
     1.5 +//
     1.6 +// Distributed under the Boost Software License, Version 1.0.
     1.7 +// (See accompanying file LICENSE_1_0.txt or copy at
     1.8 +// http://www.boost.org/LICENSE_1_0.txt)
     1.9 +/*
    1.10 + * © Portions copyright (c) 2006-2007 Nokia Corporation.  All rights reserved.
    1.11 +*/
    1.12 +
    1.13 +
    1.14 +#include <boost/config.hpp>
    1.15 +#include <iostream>
    1.16 +#include <fstream>
    1.17 +#include <string>
    1.18 +#include <boost/tuple/tuple.hpp>
    1.19 +#include <boost/graph/adjacency_list.hpp>
    1.20 +#include <boost/graph/visitors.hpp>
    1.21 +#include <boost/graph/breadth_first_search.hpp>
    1.22 +#include <map>
    1.23 +#include <boost/graph/adj_list_serialize.hpp>
    1.24 +#include <boost/archive/xml_iarchive.hpp>
    1.25 +#include <boost/archive/xml_oarchive.hpp>
    1.26 +
    1.27 +#ifdef __SYMBIAN32__
    1.28 +#include "std_log_result.h"
    1.29 +#define LOG_FILENAME_LINE __FILE__, __LINE__
    1.30 +#endif
    1.31 +struct vertex_properties {
    1.32 +  std::string name;
    1.33 +
    1.34 +  template<class Archive>
    1.35 +  void serialize(Archive & ar, const unsigned int version) {
    1.36 +    ar & BOOST_SERIALIZATION_NVP(name);
    1.37 +  }  
    1.38 +};
    1.39 +
    1.40 +struct edge_properties {
    1.41 +  std::string name;
    1.42 +
    1.43 +  template<class Archive>
    1.44 +  void serialize(Archive & ar, const unsigned int version) {
    1.45 +    ar & BOOST_SERIALIZATION_NVP(name);
    1.46 +  }  
    1.47 +};
    1.48 +
    1.49 +using namespace boost;
    1.50 +
    1.51 +typedef adjacency_list<vecS, vecS, undirectedS, 
    1.52 +               vertex_properties, edge_properties> Graph;
    1.53 +
    1.54 +typedef graph_traits<Graph>::vertex_descriptor vd_type;
    1.55 +
    1.56 +
    1.57 +typedef adjacency_list<vecS, vecS, undirectedS, 
    1.58 +               vertex_properties> Graph_no_edge_property;
    1.59 +
    1.60 +int main()
    1.61 +{
    1.62 +  {
    1.63 +    std::ofstream ofs("./kevin-bacon2.dat");
    1.64 +    archive::xml_oarchive oa(ofs);
    1.65 +    Graph g;
    1.66 +		vertex_properties vp;
    1.67 +		vp.name = "A";
    1.68 +		vd_type A = add_vertex( vp, g );
    1.69 +		vp.name = "B";
    1.70 +		vd_type B = add_vertex( vp, g );
    1.71 +
    1.72 +		edge_properties ep;
    1.73 +		ep.name = "a";
    1.74 +		add_edge( A, B, ep, g);
    1.75 +
    1.76 +    oa << BOOST_SERIALIZATION_NVP(g);
    1.77 +
    1.78 +    Graph_no_edge_property g_n;
    1.79 +    oa << BOOST_SERIALIZATION_NVP(g_n);
    1.80 +  }
    1.81 +
    1.82 +  {
    1.83 +    std::ifstream ifs("./kevin-bacon2.dat");
    1.84 +    archive::xml_iarchive ia(ifs);
    1.85 +    Graph g;
    1.86 +    ia >> BOOST_SERIALIZATION_NVP(g);
    1.87 +
    1.88 +		if  (!( g[*(vertices( g ).first)].name == "A" )) return -1;
    1.89 +
    1.90 +    Graph_no_edge_property g_n;
    1.91 +    ia >> BOOST_SERIALIZATION_NVP(g_n);
    1.92 +  }
    1.93 +  
    1.94 +  #ifdef __SYMBIAN32__
    1.95 +  
    1.96 +  	std_log(LOG_FILENAME_LINE,"[End Test Case ]");
    1.97 +
    1.98 +	testResultXml("serialize");
    1.99 +	close_log_file();
   1.100 +#endif
   1.101 +  return 0;
   1.102 +}