|
Boost Users : |
From: rzako23 (rzako_at_[hidden])
Date: 2002-03-30 16:28:47
Are there any generic components in Boost (or elsewhere) for *directly*
representing associations between classes?
Generalization, composition, aggregation and association are major
ideas in the object model. Generalization can be implemented fairly
directly in C++ using inheritance. Composition and aggregation can be
represented directly in C++ using data members (when the number of
parts in each whole is small and fixed), or using STL containers (when
the number of parts in each whole is large or variable). But Standard
C++ (including the STL) provides no *direct* support for representing
associations, i.e., collections of links between objects in two or more
classes. (David Papurt makes this point in "Inside the Object Model:
The Sensible Use of C++.")
For example, the STL does not offer a way to *directly* represent the
1-to-many "Supervises" association from the Manager class to the
Employee class. One would like to have links in both directions:
forward links forthe employees a manager supervises and a back link to
the manager each employee is supervised by. Of course, one could code
this all "by hand" using a container of pointers to employees for each
manager and a back pointer for each employee. But the implementation
details really have little to do with managers and employees and would
be pretty much the same for parents and children or teachers and
students. Moreover, while not difficult, managing the forward and back
links correctly (and in an exception-safe manner) is tedious. It would
be nice to have templates that can be instantiated to implement
specific associations.
In brief, STL containers directly support composition and aggregation
but not association.
I am new to the Boost library, but was not able to find this capability
in Boost. If an association library is available in Boost (or
elsewhere), I would be happy to know so.
If not, is an association library something that would be worth looking
into?
Thanks,
Rob Zako
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