Boost logo

Boost Users :

From: Stephen torri (storri_at_[hidden])
Date: 2004-10-21 22:31:45


I have a need to store an instance of a template class in each vertex of
a adjacency_list. I was wondering if my idea below will do:

template <class House_Type, class Number_Type>
class Home
{
public:
        uint32_t id;
        House_Type type;
        Number_Type digits;
};

The following classes are specific instances of the Home class:

class Ranch_Home : public Home <std::string, uint8_t>
{}

class Tudor_Home : public Home <std::string, float>
{}

I was thinking that the property to store this would have to be
something allows for either Home type to be stored at a vertex.

struct house_obj{};

typedef property < house_obj,
                   boost::shared_ptr< Home< House_Type_Base,
                                            Digit_Type_Base> > >
VertexProperty;

In this case the House_Type_Base and Digit_Type_Base what I am not sure
about here.

I want to use a Factory to create the appropriate Home based on a string
I read from the file as was seen above. For example, for each line of
the file I plan on using a boost spirit parser to parse the file since I
need all three elements before calling the factory.

1 "Ranch" 20
2 "Tudor" 20509.0

So how can I use the property when the template arguments are objects
that have no common base class between them?

Stephen

-- 
Email: storri_at_[hidden]

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net