Click
Loading...
Searching...
No Matches
Public Member Functions | List of all members
NameDB Class Referenceabstract

Superclass for databases mapping names to values. More...

Inheritance diagram for NameDB:
DynamicNameDB StaticNameDB

Public Member Functions

 NameDB (uint32_t type, const String &context, size_t value_size)
 Construct a database.
 
virtual ~NameDB ()
 Destroy a database.
 
uint32_t type () const
 Return the database type.
 
const String & context () const
 Return the database's compound element context as a string.
 
NameDB * context_parent () const
 Return the contextual parent database, if any.
 
size_t value_size () const
 Return the database's value size.
 
virtual bool query (const String &name, void *value, size_t value_size)=0
 Query this database for a given name.
 
virtual String revquery (const void *value, size_t value_size)
 Query this database for a given value.
 
virtual bool define (const String &name, const void *value, size_t value_size)
 Define a name in this database to a given value.
 
bool define_int (const String &name, int32_t value)
 Define a name in this database to a 32-bit integer value.
 

Detailed Description

Superclass for databases mapping names to values.

NameDB databases are Click's general way to map names to values. Many Click elements need to parse names into values of various types. They use NameDB to do it; NameDB and NameInfo implement generally useful properties like names local to a compound element context, and support space- and time-efficient lookups.

Most users should access NameDB's functionality through NameInfo.

See also
NameInfo

Constructor & Destructor Documentation

◆ NameDB()

NameDB::NameDB ( uint32_t  type,
const String &  context,
size_t  value_size 
)
inline

Construct a database.

Parameters
typedatabase type
contextdatabase compound element context, as a String
value_sizedatabase value size

value_size must be greater than 0.

◆ ~NameDB()

virtual NameDB::~NameDB ( )
inlinevirtual

Destroy a database.

Destroying an installed database automatically uninstalls it. See NameInfo::uninstalldb().

Member Function Documentation

◆ type()

uint32_t NameDB::type ( ) const
inline

Return the database type.

◆ context()

const String & NameDB::context ( ) const
inline

Return the database's compound element context as a string.

◆ context_parent()

NameDB * NameDB::context_parent ( ) const
inline

Return the contextual parent database, if any.

The contextual parent database is the unique database, for the same router, with the same type(), whose context() is a prefix of this database's context(), that has the longest context() of any matching database. If there is no such database returns null.

◆ value_size()

size_t NameDB::value_size ( ) const
inline

Return the database's value size.

◆ query()

virtual bool NameDB::query ( const String &  name,
void *  value,
size_t  value_size 
)
pure virtual

Query this database for a given name.

Parameters
namename to look up
valuepoints to value storage
value_sizesize of value storage
Returns
true iff the query succeeded

The value_size parameter must equal this database's value size.

Implemented in StaticNameDB, and DynamicNameDB.

◆ revquery()

String NameDB::revquery ( const void *  value,
size_t  value_size 
)
virtual

Query this database for a given value.

Parameters
valuepoints to value to look up
value_sizesize of value storage
Returns
the name for the given value, or an empty string if the value has not been defined

The value_size parameter must equal this database's value size. The default implementation always returns the empty string.

Reimplemented in StaticNameDB, and DynamicNameDB.

◆ define()

bool NameDB::define ( const String &  name,
const void *  value,
size_t  value_size 
)
virtual

Define a name in this database to a given value.

Parameters
namename to define
valuepoints to value to define
value_sizesize of value storage
Returns
true iff the name was defined

The value_size parameter must equal this database's value size. The default implementation always returns false.

Reimplemented in DynamicNameDB.

◆ define_int()

bool NameDB::define_int ( const String &  name,
int32_t  value 
)
inline

Define a name in this database to a 32-bit integer value.

Parameters
namename to define
valuevalue to define
Returns
true iff the name was defined

The database's value size must equal 4. The implementation is the same as define(name, &value, 4).


The documentation for this class was generated from the following files: