00001 // See ../../license.txt for license information. 00002 // 00003 // context.cpp 00004 // 00005 // 4-Jul-2003 phamilton Created 00006 // 00007 00008 #include "context.hpp" 00009 #include "boost/lexical_cast.hpp" 00010 #include <boost/test/test_tools.hpp> 00011 #include "root.hpp" 00012 #include "foo.hpp" 00013 #include "bar.hpp" 00014 00015 using namespace persist_test; 00016 00017 ph::common::object_base *context::create( 00018 const std::string &type, const std::string &name) 00019 /* 00020 This should be a factory. Just hacked for the test. 00021 */ 00022 { 00023 if (type == "root") 00024 return new root(type, name); 00025 else if (type == "foo") 00026 return new foo(type, name); 00027 else if (type == "bar") 00028 return new bar(type, name); 00029 else 00030 return 0; 00031 } 00032 00033 ph::common::object_base *context::find_object( 00034 ph::common::object_base *r, 00035 ph::common::object_base *obj, 00036 const std::string &location) 00037 /* 00038 There should be some type of parseing code to parse out the location. 00039 00040 for now, the locations are just root/[foos|bars] 00041 */ 00042 { 00043 root *rt = dynamic_cast<root *>(r); 00044 BOOST_REQUIRE(rt); 00045 00046 if (location == "root/foos") 00047 return rt->get_composite_object("foos"); 00048 else if (location == "root/bars") 00049 return rt->get_composite_object("bars"); 00050 else 00051 return 0; 00052 } 00053 00054 ph::common::object_base *context::find_composite_object( 00055 ph::common::object_base *r, 00056 ph::common::object_base *obj, 00057 const std::string &location) 00058 /* 00059 There should be some type of parseing code to parse out the location. 00060 00061 for now, the locations are just root/[foos|bars] 00062 */ 00063 { 00064 return find_object(r, obj, location); 00065 }