I have a container that currently allows the user to alter the Node 
container. I want to allow the user to be able to alter the Node 
contents but to not be able to insert, erase Nodes from the vector.

What's the best way to proceed?

/** \c ElementList is a convenient container of the nodes 
 *  and the elements making up the domain. It ensures that
 *  nodes are numbered so that nodes shared between elements
 *  come before nodes internal to a single element.
 *  This makes it trivially easy to write the structure info to file.
 */
template <typename Element>
class ElementList {
public:
        /** The constructor ensures that the list of \c nodes 
         *  and \c elements is always self-consistent.
         */
        ElementList(std::vector<Node> const & nodes,
                    std::vector<Element> const & elements);

        /** Nodal coordinates, velocity and concentration can 
         *  all change.
         *  Do NOT use this accessor to insert, erase new nodes.
         */
        std::vector<Node> & nodes() { return nodes_; }
        std::vector<Node> const & nodes() const { return nodes_; }

        /// The element list is immutable.
        std::vector<Element> const & elements() const { return elements_; }

private:
        /** Renumbers the nodes so that all nodes internal to 
         *  any element come after those nodes shared by two or 
         *  more elements.
         */
        void renumber_end_nodes_first();

        std::vector<Node> nodes_;
        std::vector<Element> elements_;
};
 
Angus

Reply via email to