// ---------------------------------------------------------------------------
// - Nameset.hpp -
// - afnix engine - nameset class definition -
// ---------------------------------------------------------------------------
// - This program is free software; you can redistribute it and/or modify -
// - it provided that this copyright notice is kept intact. -
// - -
// - This program is distributed in the hope that it will be useful, but -
// - without any warranty; without even the implied warranty of -
// - merchantability or fitness for a particular purpose. In no event shall -
// - the copyright holder be liable for any direct, indirect, incidental or -
// - special damages arising in any way out of the use of this software. -
// ---------------------------------------------------------------------------
// - copyright (c) 1999-2007 amaury darsch -
// ---------------------------------------------------------------------------
#ifndef AFNIX_NAMESET_HPP
#define AFNIX_NAMESET_HPP
#ifndef AFNIX_OBJECT_HPP
#include "Object.hpp"
#endif
namespace afnix {
/// The Nameset class defines an environment for a set of objects. Since
/// a nameset is an object, it is possible to create or evaluate by
/// name. This class is an abstract class.
/// @author amaury darsch
class Nameset : public Object {
protected:
Nameset* p_parent;
public:
/// create a new nameset
Nameset (void);
/// destroy this nameset
~Nameset (void);
/// set the parent nameset
/// @param nset the parent nameset
void setparent (Nameset* nset);
/// @return the parent nameset
Nameset* getparent (void) const;
/// reset this nameset
virtual void reset (void) =0;
/// @return a child nameset
virtual Nameset* dup (void) =0;
/// add a new object by quark
/// @param quark the object quark
/// @param object the object to bind
virtual void bind (const long quark, Object* object) =0;
/// add a new object by name
/// @param name the object name
/// @param object the object to bind
virtual void bind (const String& name, Object* object);
/// @return true if the quark exists in this nameset
virtual bool exists (const long quark) const =0;
/// @return true if the name exists in this nameset
virtual bool exists (const String& name) const;
/// @return true if the quark is valid in the namesets
virtual bool isvalid (const long quark) const;
/// @return true if the name is valid in the namesets
virtual bool isvalid (const String& name) const;
/// @return an object by quark but do not evaluate
virtual Object* find (const long quark) const =0;
/// @return an object by name but do not evaluate
virtual Object* find (const String& name) const;
/// remove an object by quark in this nameset
/// @param quark the binding to remove
virtual void remove (const long quark) =0;
/// remove an object by name in this nameset
/// @param name the binding to remove
virtual void remove (const String& name);
/// create a child nameset by quark
/// @param quark the child nameset quark
virtual Nameset* mknset (const long quark);
/// create a child nameset by name
/// @param name the child nameset name
virtual Nameset* mknset (const String& name);
/// @return a nameset by quark
virtual Nameset* getnset (const long quark) const;
/// @return a nameset by name
virtual Nameset* getnset (const String& name) const;
/// create a new constant symbol by quark
/// @param quark the symbol quark to create
/// @param object the object to bind
virtual void symcst (const long quark, Object* object);
/// create a new constant symbol by name
/// @param name the symbol name to create
/// @param object the object to bind
virtual void symcst (const String& name, Object* object);
/// create a new symbol by quark
/// @param quark the symbol quark to create
/// @param object the object to bind
virtual void symdef (const long quark, Object* object);
/// create a new symbol by name
/// @param name the symbol name to create
/// @param object the object to bind
virtual void symdef (const String& name, Object* object);
private:
// make the copy constructor private
Nameset (const Nameset&);
// make the assignment operator private
Nameset& operator = (const Nameset&);
};
}
#endif
syntax highlighted by Code2HTML, v. 0.9.1