#include <stdlib.h>#include <stdio.h>#include <string.h>#include <stdbool.h>#include <assert.h>#include <Integra/integra_instance.h>#include <Integra/integra_types.h>#include <Integra/integra_error.h>#include <Integra/integra_server.h>#include "memory.h"#include "namespace.h"#include "helper.h"#include "debug.h"#include "globals.h"| Functions | |
| ntg_instance * | ntg_instance_new (void) | 
| Allocate a new empty instance, and return a pointer to it. | |
| void | ntg_instance_unlink (ntg_instance *instance) | 
| Remove an instance from a linked list of instances. | |
| ntg_error_code | ntg_instance_free (ntg_instance *instance) | 
| free an instance | |
| unsigned long | ntg_instance_get_id (ntg_instance *instance) | 
| Get the ID of an instance. | |
| ntg_error_code | ntg_instance_set_class_id (ntg_instance *instance, ntg_id id) | 
| Set the class id of a instance. | |
| ntg_error_code | ntg_instance_add (ntg_instance *container, ntg_instance *instance) | 
| Add an instance to a given collection. | |
| ntg_instance * | ntg_instance_find_by_path (const ntg_path *path, const ntg_instance *root) | 
| ntg_instance_attribute * | ntg_instance_get_attribute_current (const ntg_instance *instance) | 
| Return a pointer to the 'last used' attribute. | |
| ntg_instance_attribute * | ntg_instance_get_attribute_root (const ntg_instance *instance) | 
| Get the attribute root from an instance. | |
| void | ntg_instance_set_attribute_current (ntg_instance *instance, ntg_instance_attribute *current) | 
| Set the current/'last used' attribute for a given ntg_instance. | |
| ntg_instance_attribute * | ntg_instance_attribute_find_by_name (const ntg_instance *instance, const char *name) | 
| Find an attribute by name. | |
| int | ntg_instance_increment_count (ntg_instance *instance) | 
| Add an instance to the instance counter. | |
| int | ntg_instance_decrement_count (ntg_instance *instance) | 
| Remove an instance from the instance counter. | |
| int | ntg_instance_get_count (ntg_instance *instance) | 
| Get the instance count for a given instance. | |
| void | ntg_free_instance_counts (void) | 
| Free the instance_counts list. | |
| void | ntg_instance_register_namespace (ntg_instance *instance) | 
| Create a namespace entry for a module instance. | |
| ntg_instance * | ntg_instance_add_attributes (ntg_instance *instance, ntg_attribute_list *attribute_list) | 
| Add attributes to instance. | |
| ntg_instance * | ntg_instance_find_by_name_ (const ntg_instance *root, const char *name, bool recursive) | 
| ntg_instance * | ntg_instance_find_by_id_ (const ntg_instance *root, const ntg_id id, bool recursive) | 
| ntg_instance * | ntg_instance_find_by_name (const ntg_instance *root, const char *name) | 
| Find an isntance by name inside the given container. | |
| ntg_instance * | ntg_instance_find_by_name_r (const ntg_instance *root, const char *name) | 
| recursive version of ntg_instance_find_by_name() | |
| ntg_instance * | ntg_instance_find_by_id (const ntg_instance *root, const ntg_id id) | 
| Find an isntance by id inside the given container. | |
| ntg_instance * | ntg_instance_find_by_id_r (const ntg_instance *root, const ntg_id id) | 
| recursive version of ntg_instance_find_by_id() | |
| char * | ntg_instance_name_from_path (const ntg_instance *instance, const ntg_path *path) | 
| ntg_error_code | ntg_instance_set_name (ntg_instance *instance, const char *class_name, const char *name) | 
| Set the name of an instance (assigned to function pointe in struct). | |
| bool | ntg_instance_is_sibling (const ntg_instance *instance, const ntg_instance *sibling) | 
| A check that 'instance' and 'sibling' share the same parent. | |
| ntg_path * | ntg_instance_get_path_ (const ntg_instance *instance, ntg_path *path) | 
| ntg_path * | ntg_instance_get_path (const ntg_instance *instance) | 
| get the full path for an instance | |
| void ntg_free_instance_counts | ( | void | ) | 
Free the instance_counts list.
References instance_counts, ntg_instance_count_::next, and ntg_free().
Referenced by _fini().
| ntg_error_code ntg_instance_add | ( | ntg_instance * | collection, | |
| ntg_instance * | instance | |||
| ) | 
Add an instance to a given collection.
| ntg_instance | *collection A pointer to a collection instance | |
| ntg_instance | *instance A pointer to an instance instance to be added to the collection instance | 
This function is responsible for safely adding an instance (to a collection), and setting the collection's dirty flag.
References NTG_ERROR, NTG_NO_ERROR, and ntg_print_error().
Referenced by ntg_new().
| ntg_instance* ntg_instance_add_attributes | ( | ntg_instance * | instance, | |
| ntg_attribute_list * | attribute_list | |||
| ) | 
Add attributes to instance.
References ntg_attribute_list_::attributes, ntg_instance_attribute_::index, ntg_attribute_list_::n_attributes, _ntg_attribute::name, ntg_instance_attribute_::name, ntg_instance_attribute_::next, ntg_malloc(), ntg_print_error(), and ntg_instance_attribute_::value.
Referenced by ntg_new().
| ntg_instance_attribute* ntg_instance_attribute_find_by_name | ( | const ntg_instance * | instance, | |
| const char * | name | |||
| ) | 
Find an attribute by name.
| ntg_instance | *instance A pointer to the instance we want to get the attribute from | |
| char | *name The name of the given attribute | 
References ntg_instance_attribute_::name, ntg_instance_attribute_::next, ntg_instance_get_attribute_current(), ntg_instance_get_attribute_root(), ntg_instance_set_attribute_current(), and ntg_print_error().
Referenced by ntg_connect(), ntg_disconnect(), ntg_get(), ntg_new(), ntg_server_delete_connection(), ntg_server_fix_connections(), and ntg_set().
| int ntg_instance_decrement_count | ( | ntg_instance * | instance | ) | 
Remove an instance from the instance counter.
References ntg_instance_count_::class_id, instance_counts, ntg_instance_count_::n_instances, and ntg_instance_count_::next.
| ntg_instance* ntg_instance_find_by_id | ( | const ntg_instance * | container, | |
| const ntg_id | instance_id | |||
| ) | 
Find an isntance by id inside the given container.
Traverses the instance list given by container->instances looking for the string *instance_id
References ntg_instance_find_by_id_().
Referenced by ntg_server_fix_connections().
| ntg_instance* ntg_instance_find_by_id_ | ( | const ntg_instance * | root, | |
| const ntg_id | id, | |||
| bool | recursive | |||
| ) | 
References ntg_print_error().
Referenced by ntg_instance_find_by_id(), and ntg_instance_find_by_id_r().
| ntg_instance* ntg_instance_find_by_id_r | ( | const ntg_instance * | root, | |
| const ntg_id | id | |||
| ) | 
recursive version of ntg_instance_find_by_id()
References ntg_instance_find_by_id_().
Referenced by ntg_server_delete_orphaned_connections().
| ntg_instance* ntg_instance_find_by_name | ( | const ntg_instance * | container, | |
| const char * | instance_name | |||
| ) | 
Find an isntance by name inside the given container.
Traverses the instance list given by container->instances looking for the string *instance_name
References ntg_instance_find_by_name_().
Referenced by ntg_connect(), ntg_disconnect(), ntg_instance_find_by_path(), and ntg_new().
| ntg_instance* ntg_instance_find_by_name_ | ( | const ntg_instance * | root, | |
| const char * | name, | |||
| bool | recursive | |||
| ) | 
References ntg_print_error().
Referenced by ntg_instance_find_by_name(), and ntg_instance_find_by_name_r().
| ntg_instance* ntg_instance_find_by_name_r | ( | const ntg_instance * | root, | |
| const char * | name | |||
| ) | 
recursive version of ntg_instance_find_by_name()
References ntg_instance_find_by_name_().
| ntg_instance* ntg_instance_find_by_path | ( | const ntg_path * | path, | |
| const ntg_instance * | root | |||
| ) | 
References ntg_path_::elems, ntg_path_::n_elems, ntg_instance_find_by_name(), and ntg_print_error().
Referenced by ntg_delete(), ntg_get(), ntg_new(), ntg_nodelist(), ntg_rename(), ntg_server_delete_connection(), ntg_server_update_connection(), and ntg_set().
| ntg_error_code ntg_instance_free | ( | ntg_instance * | instance | ) | 
free an instance
References DB_SERVER, DEBUG_POST(), ntg_free(), ntg_instance_attributes_free(), ntg_instance_unlink(), and NTG_NO_ERROR.
Referenced by ntg_server_instance_delete().
| ntg_instance_attribute* ntg_instance_get_attribute_current | ( | const ntg_instance * | instance | ) | 
Return a pointer to the 'last used' attribute.
If the value of this pointer is NULL, NULL is returned.
References ntg_print_error().
Referenced by ntg_instance_attribute_find_by_name().
| ntg_instance_attribute* ntg_instance_get_attribute_root | ( | const ntg_instance * | instance | ) | 
Get the attribute root from an instance.
References ntg_print_error().
Referenced by ntg_instance_attribute_find_by_name().
| int ntg_instance_get_count | ( | ntg_instance * | instance | ) | 
Get the instance count for a given instance.
This function locates and decrements the instance count for a given instance
References ntg_instance_count_::class_id, instance_counts, ntg_instance_count_::n_instances, and ntg_instance_count_::next.
Referenced by ntg_instance_register_namespace().
| unsigned long ntg_instance_get_id | ( | ntg_instance * | instance | ) | 
Get the ID of an instance.
| ntg_instance | *instance a pointer to an struct of type ntg_instance | 
Referenced by ntg_instance_register_namespace().
| ntg_path* ntg_instance_get_path | ( | const ntg_instance * | instance | ) | 
get the full path for an instance
References ntg_instance_get_path_(), ntg_path_new(), and ntg_path_reverse_elements().
Referenced by ntg_server_update_connection().
| ntg_path* ntg_instance_get_path_ | ( | const ntg_instance * | instance, | |
| ntg_path * | path | |||
| ) | 
References ntg_path_append_element().
Referenced by ntg_instance_get_path().
| int ntg_instance_increment_count | ( | ntg_instance * | instance | ) | 
Add an instance to the instance counter.
This function locates and increments the instance count for a given instance
References ntg_instance_count_::class_id, instance_counts, ntg_instance_count_::n_instances, ntg_instance_count_::next, and ntg_malloc().
Referenced by handler_module_load(), and ntg_new().
| bool ntg_instance_is_sibling | ( | const ntg_instance * | instance, | |
| const ntg_instance * | sibling | |||
| ) | 
A check that 'instance' and 'sibling' share the same parent.
Referenced by ntg_server_update_connection().
| char* ntg_instance_name_from_path | ( | const ntg_instance * | instance, | |
| const ntg_path * | path | |||
| ) | 
References ntg_path_::elems, ntg_path_::n_elems, and ntg_append_string().
| ntg_instance* ntg_instance_new | ( | void | ) | 
Allocate a new empty instance, and return a pointer to it.
| const | int type An integer indicating the instance type to be created. This corresponds to the type variable in the instance struct, and must be taken from the ntg_entity_types enum in integra_types.h | 
References L, ntg_id_new(), and ntg_malloc().
Referenced by ntg_new(), and ntg_server_run().
| void ntg_instance_register_namespace | ( | ntg_instance * | instance | ) | 
Create a namespace entry for a module instance.
References DB_INSTANCE, DEBUG_POST(), integra_namespace, ntg_namespace_::n_registered_modules, _ntg_definition::name, ntg_count_digits(), ntg_free(), ntg_instance_get_count(), ntg_instance_get_id(), ntg_malloc(), ntg_name_reformat(), NTG_NULL_BYTES, ntg_realloc(), ntg_register_namespace(), and ntg_namespace_::port_counts.
| void ntg_instance_set_attribute_current | ( | ntg_instance * | instance, | |
| ntg_instance_attribute * | current | |||
| ) | 
Set the current/'last used' attribute for a given ntg_instance.
Referenced by ntg_instance_attribute_find_by_name().
| ntg_error_code ntg_instance_set_class_id | ( | ntg_instance * | instance, | |
| ntg_id | id | |||
| ) | 
Set the class id of a instance.
References NTG_ERROR, NTG_NO_ERROR, and ntg_print_error().
Referenced by handler_module_load(), and ntg_new().
| ntg_error_code ntg_instance_set_name | ( | ntg_instance * | instance, | |
| const char * | class_name, | |||
| const char * | name | |||
| ) | 
Set the name of an instance (assigned to function pointe in struct).
| ntg_instance | *instance a pointer to an struct of type ntg_instance | |
| *class_name | Optional pointer to class name of class instance belongs to. If name is provided class_name can safely be set to NULL | |
| char | *name A pointer to a NULL-terminated string representing the new name for an instance | 
If a NULL value is passed for the *name pointer, then a combination of the class name and the instance's id will be used to generate a name. If the id has not been set, an error will be raised
References ntg_count_digits(), NTG_ERROR, NTG_NO_ERROR, and ntg_print_error().
Referenced by ntg_new(), ntg_rename(), and ntg_server_run().
| void ntg_instance_unlink | ( | ntg_instance * | instance | ) | 
Remove an instance from a linked list of instances.
Referenced by ntg_instance_free().
 1.6.1
 1.6.1