Previous: library_entry internals, Up: Library framework



5.3.5 The library_entry::impl class

The library_entry::impl class provides the interface that library implementations must implement to parse individual library entries. Each library_entry and library::const_iterator holds onto one of these.

— Destructor: virtual library_entry::impl::~impl (void);

A virtual destructor.

— Function: virtual library_entry::impl* library_entry::impl::clone (void) const = 0;

This must be overriden to perform a deep copy of the library. Almost always this should be implemented as follows:

          virtual library_entry::impl* mylib::entry_type::clone() const {
            return new mylib::entry_type(*this);
          }
     
— Function: virtual bool library_entry::impl::readentry (library_base& lb) const = 0;

The function should be overriden to read the next entry from the library and return true unless the end of the library has been reached. The source of the data should be held within the library_base implementation, and not this class. For example, if the library implementation reads from a file via an ifstream, the library_base class should contain the ifstream and this class should access it via lb:

          virtual bool mylib::entry_type::readentry( library_base& lb ) {
            ifstream& ifs = dynamic_cast< mylib& >( lb ).ifs;
            std::getline( ifs, this->entry );
          }
     

None of library_entry's other functions should ever access the parent library_base class.

This function gets called whenever a library::const_iterator is constructed or incremented.

— Function: virtual string library_entry::impl::name (void) const = 0;
— Function: virtual string library_entry::impl::base_name (void) const = 0;

These should be overriden to return the name of the current entry. The name function should return a name which is unique within the library (this may require the class name(s) and/or stage name be included); the base_name function should return the name without either the class or stage name.

These functions may be implemented to simply return a name that was parsed by readentry; alternatively it might be implemented to parse some internal representation of the entry (such as a string containing the whole entry). It must not attempt to access the parent library_base which may no longer exist. The readentry function will always have been called before this function gets called.

— Function: virtual string library_entry::impl::pn (void) const = 0;

This should be overriden to return the place notation of the current method.

— Function: virtual string library_entry::impl::pn (void) const = 0;

This should be overriden to return the number of bells that the current method is on.