Cisco Packet Tracer Extensions API 8.1.0
API for communication between Cisco Packet Tracer application and its extension applications and modules.
Public Member Functions | List of all members
NetworkFile Class Reference

NetworkFile is the main system file for the application. It holds all the configurations for the engine as well as the UI. More...

Inheritance diagram for NetworkFile:
ActivityFile

Public Member Functions

QString getSavedFilename ()
 Returns the filename of the currently opened file. More...
 
QString getVersion ()
 Returns the version the current file was saved in. More...
 
QString getNetworkDescription ()
 Returns the network description of the current file. More...
 
void setNetworkDescription (QString)
 Sets the network description for the current file. More...
 
Options getOptions ()
 Returns the option settings of the current file. More...
 
Network getMainNetwork ()
 Returns the network of the current file. More...
 
UserProfile getUserProfile ()
 Returns the user profile of the current file. More...
 
Simulation getMainSimulation ()
 Returns the simulation of the current file. More...
 
Workspace getWorkspace ()
 Returns the workspace of the current file. More...
 
ActivityScriptEngine getActivityScriptEngine ()
 Returns the activity script engine of the current file. More...
 
ActivityScriptEngine getScriptEngine ()
 Returns the script engine of the current file. More...
 
void resetScriptEngine ()
 Removes the current activity script engine and creates a new one. More...
 
bool addScript (QString, QString)
 Adds a script to the activity file. More...
 
bool addScriptFile (QString, QString)
 Adds the script contents to the activity file from a file path. More...
 
void addDefaultScripts ()
 Resets the scripts to the default scripts. More...
 
bool removeScript (QString)
 Removes the specified script from the activity file hash. More...
 
QString getScript (QString)
 Returns the content of the script with the specified ID. More...
 
vector< QString > getScriptIDs ()
 Returns the list of IDs currently in the system. More...
 
bool addScriptDataStore (QString, QString)
 Adds script data store for persistent storage (e.g. constants, options, settings). More...
 
bool removeScriptDataStore (QString)
 Removes the specified script data store for persistent storage (e.g. constants, options, settings). More...
 
QString getScriptDataStore (QString)
 Returns the content of the specified script data store. More...
 
vector< QString > getScriptDataStoreIDs ()
 Returns the list of IDs of script data stores. More...
 
FilterSet getFilterSet ()
 Returns the engine filter set for simulation packets, what is filtered out. More...
 
bool addCustomTrafficType (QString)
 Adds a custom traffic type. Returns true if successful, false otherwise. More...
 
bool hasCustomTrafficType (QString)
 Returns whether a custom traffic type is already added. More...
 
bool addCustomPduType (QString, QString)
 Adds a custom PDU type. Returns true if successful, false otherwise. More...
 
bool hasCustomPduType (QString)
 Returns whether a custom PDU type is already added. More...
 
void duplicateDevice (Device)
 Creates and stores a copy of the given device. More...
 
bool isActivityFile ()
 Returns whether this file is an activity file or regular network file. More...
 

Detailed Description

NetworkFile is the main system file for the application. It holds all the configurations for the engine as well as the UI.

Member Function Documentation

◆ addCustomPduType()

bool NetworkFile::addCustomPduType ( QString  ,
QString   
)

Adds a custom PDU type. Returns true if successful, false otherwise.

Parameters
customPduType,thecustom PDU type name.
jsonDefinition,aJSON string representing the definition of the PDU in the following format and must include the following: { "title": "My Protocol PDU", "units": "Bits", "unit_marks": [16], "width": 32, "fields": [{"value": "TYPE: {type}","size": 32}, {"value": "data: {data}","size": 32}]
Returns
bool, true if successfully added the custom PDU type, otherwise false.

◆ addCustomTrafficType()

bool NetworkFile::addCustomTrafficType ( QString  )

Adds a custom traffic type. Returns true if successful, false otherwise.

Returns
bool, true if successfully added the custom traffic type, otherwise false.

◆ addDefaultScripts()

void NetworkFile::addDefaultScripts ( )

Resets the scripts to the default scripts.

Remarks
Missing script files will be addded, existing scripts of the same name will be overwritten.

◆ addScript()

bool NetworkFile::addScript ( QString  ,
QString   
)

Adds a script to the activity file.

Parameters
id,theID (e.g. filename) of the the script.
contents,thecontent of the script.
Returns
bool, true if successful, otherwise false.

◆ addScriptDataStore()

bool NetworkFile::addScriptDataStore ( QString  ,
QString   
)

Adds script data store for persistent storage (e.g. constants, options, settings).

Parameters
id,theID (e.g. name) of the data store.
contents,thecontent of the data store.
Returns
bool, true if successful, otherwise false.

◆ addScriptFile()

bool NetworkFile::addScriptFile ( QString  ,
QString   
)

Adds the script contents to the activity file from a file path.

Parameters
id,theID (e.g. filename) of the the script.
filename,thepath including the filename of the script.
Remarks
The script is not evaluated immediately.
Returns
bool, true if the script was successfully added, false if not.

◆ duplicateDevice()

void NetworkFile::duplicateDevice ( Device  )

Creates and stores a copy of the given device.

Parameters
device,deviceto duplicate.

◆ getActivityScriptEngine()

ActivityScriptEngine NetworkFile::getActivityScriptEngine ( )

Returns the activity script engine of the current file.

Returns
ActivityScriptEngine, the ActivityScriptEngine object of the current file.

◆ getFilterSet()

FilterSet NetworkFile::getFilterSet ( )

Returns the engine filter set for simulation packets, what is filtered out.

Returns
FilterSet, the filter set.

◆ getMainNetwork()

Network NetworkFile::getMainNetwork ( )

Returns the network of the current file.

Returns
Network, the Network object of the current file.

◆ getMainSimulation()

Simulation NetworkFile::getMainSimulation ( )

Returns the simulation of the current file.

Returns
Simulation, the Simulation object of the current file.

◆ getNetworkDescription()

QString NetworkFile::getNetworkDescription ( )

Returns the network description of the current file.

Returns
QString, the network description.

◆ getOptions()

Options NetworkFile::getOptions ( )

Returns the option settings of the current file.

Returns
Options, the Options object of the current file.

◆ getSavedFilename()

QString NetworkFile::getSavedFilename ( )

Returns the filename of the currently opened file.

Returns
QString, the filename of the currently opened file.

◆ getScript()

QString NetworkFile::getScript ( QString  )

Returns the content of the script with the specified ID.

Parameters
id,theID (e.g. filename) of the script.
Returns
QString, the content of the script with the specified ID.

◆ getScriptDataStore()

QString NetworkFile::getScriptDataStore ( QString  )

Returns the content of the specified script data store.

Parameters
id,theID (e.g. name) of the data store of interest.
Returns
QString, the content of the specified script data store.

◆ getScriptDataStoreIDs()

vector< QString > NetworkFile::getScriptDataStoreIDs ( )

Returns the list of IDs of script data stores.

Returns
vector<QString>, the list of IDs of script data stores.

◆ getScriptEngine()

ActivityScriptEngine NetworkFile::getScriptEngine ( )

Returns the script engine of the current file.

Returns
ActivityScriptEngine, the ActivityScriptEngine object of the current file.

◆ getScriptIDs()

vector< QString > NetworkFile::getScriptIDs ( )

Returns the list of IDs currently in the system.

Returns
vector<QString>, the list of IDs currently in the system.

◆ getUserProfile()

UserProfile NetworkFile::getUserProfile ( )

Returns the user profile of the current file.

Returns
UserProfile, the UserProfile object of the current file.

◆ getVersion()

QString NetworkFile::getVersion ( )

Returns the version the current file was saved in.

Returns
QString, the version the current file was saved in.

◆ getWorkspace()

Workspace NetworkFile::getWorkspace ( )

Returns the workspace of the current file.

Returns
Workspace, the Workspace object of the current file.

◆ hasCustomPduType()

bool NetworkFile::hasCustomPduType ( QString  )

Returns whether a custom PDU type is already added.

Returns
bool, true the custom traffic PDU is already added, otherwise false.

◆ hasCustomTrafficType()

bool NetworkFile::hasCustomTrafficType ( QString  )

Returns whether a custom traffic type is already added.

Returns
bool, true the custom traffic type is already added, otherwise false.

◆ isActivityFile()

bool NetworkFile::isActivityFile ( )

Returns whether this file is an activity file or regular network file.

◆ removeScript()

bool NetworkFile::removeScript ( QString  )

Removes the specified script from the activity file hash.

Parameters
id,theID (e.g. filename) of the script.
Returns
bool, true if successful, otherwise false.
Remarks
This will not remove the script contents from memory. However, upon the next resetScriptEngine(), the removed script will not be loaded.

◆ removeScriptDataStore()

bool NetworkFile::removeScriptDataStore ( QString  )

Removes the specified script data store for persistent storage (e.g. constants, options, settings).

Parameters
id,theID (e.g. name) of the data store of interest.
Returns
bool, true if successful, otherwise false.

◆ resetScriptEngine()

void NetworkFile::resetScriptEngine ( )

Removes the current activity script engine and creates a new one.

Remarks
All loaded script results will be lost.

◆ setNetworkDescription()

void NetworkFile::setNetworkDescription ( QString  )

Sets the network description for the current file.

Parameters
description,thenetwork description for the current file.

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