T
toton
Hi,
I have a little design related problem, and finding a good way to
resolve it.
To state the problem, I have points from writing of several documents.
Each document represents a Session class , and a SessionManager holds a
deque of Session.
Session holds deque of Page for that document. Page in turn holds
vector of Char in that page.
However Char do not hold the Point associated with that Char. Instead
it holds a pair of iterator for the points of the Char. The actual
points are stored in the Session class instead. This is done as I need
heavy processing of intercharacter points. Thus it is better to have an
linear array of Points, while Char point to to start & end in the
array. Char also contains deque of Stroke.
Now, all the relationships are bidirectional, i.e Char knows the Page,
and Page knows the Session. The other way is ofcourse known from
association.
Now I need to iterate over the points in a Stroke, or in a Char, or in
a Page.
My questions are,
1) Will I store the iterators directly in the Stroke, or Char. Or will
I store the index to the start & end point only construct the iterator
& return? (Iterator contains an extra field, the reference to the Point
array along with the start & end point).
2) If I store the start & end point only, then is it better to store
the a reference to the Point array inside the Segment, Char, Page class
etc, or to access through parent (i.e Segments parent Char, its parent
Page, its parent Session and which stores the Point array) .
3) Is it good to return a const reference of the container class from
the iterator? so that I can construct another pair of iterators from
the container? It will be helpfull if I store iterators in the Segment,
Char & Page class.
Note: I have heavy numeric calculation over Point array, and also want
to optimize memory.
Also it will be helpfull if someone suggests the standard practice.
Thanks for any kind of suggestion.
I have a little design related problem, and finding a good way to
resolve it.
To state the problem, I have points from writing of several documents.
Each document represents a Session class , and a SessionManager holds a
deque of Session.
Session holds deque of Page for that document. Page in turn holds
vector of Char in that page.
However Char do not hold the Point associated with that Char. Instead
it holds a pair of iterator for the points of the Char. The actual
points are stored in the Session class instead. This is done as I need
heavy processing of intercharacter points. Thus it is better to have an
linear array of Points, while Char point to to start & end in the
array. Char also contains deque of Stroke.
Now, all the relationships are bidirectional, i.e Char knows the Page,
and Page knows the Session. The other way is ofcourse known from
association.
Now I need to iterate over the points in a Stroke, or in a Char, or in
a Page.
My questions are,
1) Will I store the iterators directly in the Stroke, or Char. Or will
I store the index to the start & end point only construct the iterator
& return? (Iterator contains an extra field, the reference to the Point
array along with the start & end point).
2) If I store the start & end point only, then is it better to store
the a reference to the Point array inside the Segment, Char, Page class
etc, or to access through parent (i.e Segments parent Char, its parent
Page, its parent Session and which stores the Point array) .
3) Is it good to return a const reference of the container class from
the iterator? so that I can construct another pair of iterators from
the container? It will be helpfull if I store iterators in the Segment,
Char & Page class.
Note: I have heavy numeric calculation over Point array, and also want
to optimize memory.
Also it will be helpfull if someone suggests the standard practice.
Thanks for any kind of suggestion.