1 // -*- Mode: C++; c-file-style: "stroustrup"; indent-tabs-mode:nil; -*-
2 #ifndef   	BAR_H_
3 # define   	BAR_H_
4 
5 #include <string>
6 #include <boost/shared_ptr.hpp>
7 
8 
9 class Foo
10 {
11     std::string m_datum;
12     bool m_initialized;
13 public:
14     static int instance_count;
15 
Foo()16     Foo () : m_datum (""), m_initialized (false)
17         { Foo::instance_count++; }
18 
Foo(std::string const & datum)19     Foo (std::string const &datum) : m_datum (datum), m_initialized (false)
20         { Foo::instance_count++; }
get_datum()21     const std::string get_datum () const { return m_datum; }
22 
Foo(Foo const & other)23     Foo (Foo const & other) : m_datum (other.get_datum ()), m_initialized (false)
24         { Foo::instance_count++; }
25 
initialize()26     void initialize () { m_initialized = true; }
is_initialized()27     bool is_initialized () const { return m_initialized; }
28 
~Foo()29     virtual ~Foo() { Foo::instance_count--; }
30 
31 };
32 
33 inline std::ostream & operator << (std::ostream &os, Foo const &foo)
34 {
35     os << foo.get_datum ();
36     return os;
37 }
38 
39 
40 void function_that_takes_foo (boost::shared_ptr<Foo> foo);
41 boost::shared_ptr<Foo> function_that_returns_foo ();
42 
43 
44 class ClassThatTakesFoo
45 {
46     boost::shared_ptr<Foo> m_foo;
47 public:
ClassThatTakesFoo(boost::shared_ptr<Foo> foo)48     ClassThatTakesFoo(boost::shared_ptr<Foo> foo) : m_foo(foo) {}
get_foo()49     boost::shared_ptr<Foo> get_foo () const { return m_foo; }
50 
get_modified_foo(boost::shared_ptr<Foo> foo)51     virtual boost::shared_ptr<Foo> get_modified_foo (boost::shared_ptr<Foo> foo) const { return m_foo; }
~ClassThatTakesFoo()52     virtual ~ClassThatTakesFoo() {}
53 };
54 
55 
56 #endif 	    /* !FOO_H_ */
57