nns.c  1.0.1
Nanowire Network simulator
interface.h File Reference

Defines the structure of the nanowire-network device interface to the external world. More...

#include <stdbool.h>
#include "interface/connection.h"

Go to the source code of this file.

Classes

struct  interface
 Interface between the nanowire-network device and external systems. More...
 

Functions

int itcmp (const void *e1, const void *e2)
 Compare two network interfaces according to the number of sources, grounds, and loads. More...
 
interface copy_interface (const interface it)
 Create a deep copy of an interface. More...
 
void destroy_interface (interface it)
 Destroy an interface memorized in the stack. This function practically frees the masks and weights of the interface. The arrays to be freed must have been allocated in the heap with malloc/calloc. More...
 

Detailed Description

Defines the structure of the nanowire-network device interface to the external world.

This file defines the data structures and functions for interfacing with a nanowire-network device. It includes functionality for comparing, copying, and destroying interfaces.

The interface is represented by the interface structure, which holds information about sources, grounds, loads and weights, and index of the nanowire they are connected to. The provided functions allow for the comparison of interfaces, creation of deep copies, and proper cleanup of allocated resources.

Note
The interface uses dynamically allocated memory that must be managed using the provided functions.

Function Documentation

◆ copy_interface()

interface copy_interface ( const interface  it)

Create a deep copy of an interface.

Parameters
[in]itThe interface to copy.
Returns
The deep copy of the interface.

◆ destroy_interface()

void destroy_interface ( interface  it)

Destroy an interface memorized in the stack. This function practically frees the masks and weights of the interface. The arrays to be freed must have been allocated in the heap with malloc/calloc.

Parameters
[in,out]itThe interface to destroy.

◆ itcmp()

int itcmp ( const void *  e1,
const void *  e2 
)

Compare two network interfaces according to the number of sources, grounds, and loads.

Parameters
[in]e1Pointer to the first element to compare.
[in]e2Pointer to the second element to compare.
Returns
0 if the datasheets contain the same data; > 0 if e1 has, in order, more sources, grounds, or loads than e2; < 0 otherwise.