Next: , Previous: Library framework, Up: Library framework



5.3.1 The library_base class

The library_base class provides the interface that library implementations must implement to create iterators on a library. It also has virtual functions can be overriden to provide more efficient ways to search and list libraries.

— Destructor: virtual library_base::~library_base (void);

A virtual destructor.

— Function: virtual library_base::const_iterator library_base::begin (void) const = 0;

This should be overriden to construct a library_base::const_iterator pointing to the start of the library.

— Function: library_base::const_iterator library_base::end (void) const;

This returns a default constructed library_base::const_iterator representing one past the end of the library.

— Function: virtual bool library_base::good (void) const = 0;

This function should be overriden to return true if a valid library is currently loaded and false otherwise.

— Function: virtual method library_base::load (const char* name, int stage) const;

The default implementation of load iterates through the library searching for an entry with the correct name. When comparing method names, it does so in a case-insensitive manner. If stage is non-zero, load requires that the method is on that number of bells.

If no such method is found, if exceptions are enabled, an exception of class library_base::invalid_name will be thrown; otherwise, the method returned will be an empty method with the name "Not Found".

Library implementations may wish to override this if there is a more efficient way to locate the method.

— Function: virtual int library_base::dir (list<string>& result) const;
— Function: virtual int library_base::mdir (list<method>& result) const;

The default implementations of dir and mdir iterate through the library, pushing each name (in the case of dir) or method (in the case of mdir) onto result. The return value is the number of values pushed onto result.

Library implementations may wish to override this if there is a more efficient way to locate the method.

— Function: virtual bool library_base::writeable (void) const;
— Function: virtual bool library_base::save (const method& m);
— Function: virtual bool library_base::rename_method (const string& name1, const string& name2);
— Function: virtual bool library_base::remove (const string& name);

These functions are for writing to method libraries. This functionality is still experimental.