CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Threaded View

  1. #1
    Join Date
    Nov 2006
    Posts
    103

    Lists of lists using template class..

    I have a structure like:

    +Patient
    +--- Study
    +------Series
    +---------Image

    A Patient is a list of Studies
    A Study is a list of Series
    A Series is a list of Images

    So a so a series is defined as:

    class series : std::list<image>

    Now I'd like to implement this thing using template classes...

    so:
    Code:
    template <tipe, subtipe>
    class  tipe : std::list<subtipe>
    {
    private:
        std::string id;
    public:
       std::string getId();
       void add(subtipe);
       void remove(id);
       subtipe get(id);
    };
    So this is the basic template...

    the ID is used to locate your object in the list...

    There is of course a few issues I have with this...

    1) I want to be able to add an study, series or image to a patient
    2) I want to be able to add a series, or image to a study.
    This template only allows me to add an image to a series.

    I also want to be able to remove a image from a series..
    When the series is empty then the series should be removed from the study.
    When the study is empty then the study should be removed from the patient.

    As is was able to remove add an image to the patient so should I be able to remove an image from a patient and remove a series from a patient etc etc.

    So my problem at this point is that I obviously can't I do this with the above templated class. So how can I expand this template class without writing a class for each layer of the hierarchy?
    Last edited by JustSomeGuy; March 29th, 2007 at 08:31 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured