HAPI::NetworkModel Class Reference

NetworkModel is the ancestor of both Domain and Class. More...

Inheritance diagram for HAPI::NetworkModel:
HAPI::Class HAPI::Domain

List of all members.

Public Member Functions

void deleteAttribute (const std::string &key)
 Delete the specified attribute from the attribute list of this NetworkModel.
void generateTables ()
 Generate tables for all Nodes, having a Model, in this NetworkModel.
std::string getAttribute (const std::string &key) const
 Return the value associated with key in the attribute list of this NetworkModel.
AttributeList getAttributes () const
 Return all the attributes associated with this NetworkModel.
std::string getFileName () const
 Return the file name most recently used for loading or saving this NetworkModel.
NodegetNodeByName (const std::string &name) const
 Search for a node by name in this NetworkModel.
NodeList getNodes () const
 Return the Nodes of this NetworkModel.
std::pair< size_t, size_t > getNodeSize () const
 Return the size of the displayed nodes.
void * getUserData () const
 Return the value stored within the user data slot of this NetworkModel.
bool hasAttribute (const std::string &key) const
 Test if this NetworkModel has an attribute with the specified key.
double INFINITY () const
 The infinity value used by Hugin.
NodeList parseNodes (const std::string &filename, ParseListener *errorHandler)
 Create a nodelist from the data in the given file.
void saveAsNet (const std::string &filename)
 Write a NET description of this NetworkModel to a file.
void setAttribute (const std::string &key, const std::string &value)
 Insert the key/value pair in the attribute list of this NetworkModel.
void setLogFile (FILE *log)
 Set the file to be used for logging by subsequent learning, compilation, triangulation, and table generation operations.
void setNodeSize (size_t width, size_t height)
 Set the size of the nodes.
void setUserData (void *data)
 Set the user data field of this NetworkModel.

Detailed Description

NetworkModel is the ancestor of both Domain and Class.

Since Class and Domain are, in many ways, conceptually and functionally similar, the NetworkModel class is introduced to capture this similarity. It contains functionality and variables that are identical for the two classes.

See also:
Class
Domain

Member Function Documentation

void HAPI::NetworkModel::deleteAttribute ( const std::string &  key  ) 

Delete the specified attribute from the attribute list of this NetworkModel.

If the key doesn't exist, no action is taken.

void HAPI::NetworkModel::generateTables (  ) 

Generate tables for all Nodes, having a Model, in this NetworkModel.

This is done by calling Node::GenerateTable () for each applicable Node. The operation is aborted, if table generation fails for some Node. This may leave the NetworkModel in a state, where some Nodes have got generated Tables, some have not got generated Tables, and one has a partially generated Table. In this case, an exception is thrown.

std::string HAPI::NetworkModel::getAttribute ( const std::string &  key  )  const

Return the value associated with key in the attribute list of this NetworkModel.

Returns:
Standard C++ Library string containing the attribute value.
AttributeList HAPI::NetworkModel::getAttributes (  )  const

Return all the attributes associated with this NetworkModel.

Returns:
A vector of all Attributes
std::string HAPI::NetworkModel::getFileName (  )  const

Return the file name most recently used for loading or saving this NetworkModel.

Returns:
A Standard C++ Library string.
Node* HAPI::NetworkModel::getNodeByName ( const std::string &  name  )  const

Search for a node by name in this NetworkModel.

Parameters:
name The name of the Node to search for.
Returns:
Pointer to the Node with the specified name. If no such node exists (in this NetworkModel), NULL is returned.
NodeList HAPI::NetworkModel::getNodes (  )  const

Return the Nodes of this NetworkModel.

Returns:
NodeList containing the Nodes of this NetworkModel.
std::pair<size_t, size_t> HAPI::NetworkModel::getNodeSize (  )  const

Return the size of the displayed nodes.

Returns:
Standard C++ Library pair<int,int>.
void* HAPI::NetworkModel::getUserData (  )  const [inline]

Return the value stored within the user data slot of this NetworkModel.

If the stored value is NULL, or if no value has been stored, NULL is returned. It is the responsibility of the application programmer to ensure that the data is valid, that pointers are accessed correctly, etc.

Also note that when you delete a NetworkModel, Hugin does not attempt to delete the data pointed to by the user data slot. It is the responsibility of the user.

Returns:
Pointer to user-defined data associated with this NetworkModel.
double HAPI::NetworkModel::INFINITY (  )  const

The infinity value used by Hugin.

Returns:
infinity, represented as a double
NodeList HAPI::NetworkModel::parseNodes ( const std::string &  filename,
ParseListener errorHandler 
)

Create a nodelist from the data in the given file.

This is typically used together with the triangulation function.

Parameters:
filename The name of the file containing the node list description
errorHandler An instance of a ParseListener for handling errors during the parsing.
void HAPI::NetworkModel::saveAsNet ( const std::string &  filename  ) 

Write a NET description of this NetworkModel to a file.

Parameters:
filename The name of the file to save to.
void HAPI::NetworkModel::setAttribute ( const std::string &  key,
const std::string &  value 
)

Insert the key/value pair in the attribute list of this NetworkModel.

If the key is already defined, the value is updated.

void HAPI::NetworkModel::setLogFile ( FILE *  log  ) 

Set the file to be used for logging by subsequent learning, compilation, triangulation, and table generation operations.

Parameters:
log File pointer to an opene file to be used as log. log must be a text file opened for writing or appending. Writing is done sequentially.
void HAPI::NetworkModel::setUserData ( void *  data  )  [inline]

Set the user data field of this NetworkModel.

The Hugin API provides a slot within each NetworkModel object for use exclusively by the user/application. This slot can hold a pointer to arbitrary data, such as a file, a function pointer, etc. Please note that Hugin does not do anything to the user data. Data is not even copied. Only the pointer to the data is stored.

Parameters:
data Pointer to user-defined data associated with this NetworkModel.

Copyright Hugin Expert A/S 1993-2010