sipxmedialib
Version 3.3
|
MpResourceTopology is used to define a set of resources and how they are to be connected in a flowgraph. More...
#include <MpResourceTopology.h>
Classes | |
struct | ConnectionDef |
A connection type for use with addConnections(). More... | |
struct | ResourceDef |
A resource type for use with addResources(). More... | |
Public Types | |
enum | MpLogicalPortTypes { MP_TOPOLOGY_NEXT_AVAILABLE_PORT = -1 } |
typedef UtlHashMapIterator * | VirtualPortIterator |
Public Member Functions | |
MpResourceTopology () | |
Constructor. More... | |
virtual | ~MpResourceTopology () |
Destructor. More... | |
OsStatus | addResource (const UtlString &resourceType, const UtlString &resourceName, MpConnectionID connectionId=MP_INVALID_CONNECTION_ID, int streamId=-1) |
Add a new resource definition to the topology. More... | |
OsStatus | addResources (const ResourceDef *defines, int numDefines) |
Add resources from an array. More... | |
OsStatus | addConnection (const UtlString &outputResourceName, int outputPortIndex, const UtlString &inputResourceName, int inputPortIndex) |
Add a new connection definition to the topology. More... | |
OsStatus | addConnections (const ConnectionDef *defines, int numDefines) |
Add resources from an array. More... | |
OsStatus | addVirtualInput (const UtlString &realResourceName, int realPortIndex, const UtlString &virtualResourceName, int virtualPortIndex) |
Add a new virtual input definition to the topology. More... | |
OsStatus | addVirtualOutput (const UtlString &realResourceName, int realPortIndex, const UtlString &virtualResourceName, int virtualPortIndex) |
Add a new virtual output definition to the topology. More... | |
OsStatus | validateConnections (UtlString &firstUnconnectedResourceName, UtlString &firstDanglingResourceName, UtlBoolean allowExternalResources=FALSE) const |
Validate that the connections are connect the resources. More... | |
OsStatus | validateResourceTypes (MpResourceFactory &resourceFactory, int &firstInvalidResourceIndex) const |
Validate that all the resource types in this topology have a constructor in the factory. More... | |
OsStatus | getResource (int resourceIndex, UtlString &resourceType, UtlString &resourceName, MpConnectionID &connectionId, int &streamId) const |
Get the resource definition indicated by the resourceIndex. More... | |
OsStatus | getResource (int resourceIndex, UtlString &resourceName) const |
Get the resource name by the resourceIndex. More... | |
OsStatus | getInputVirtualResource (const UtlString &virtualName, int virtualPort, UtlString &resourceName, int &resourcePort) const |
Get the resource name and port index by the virtual input name and port index. More... | |
OsStatus | getOutputVirtualResource (const UtlString &virtualName, int virtualPort, UtlString &resourceName, int &resourcePort) const |
Get the resource name and port index by the virtual output name and port index. More... | |
OsStatus | getConnection (int connectionIndex, UtlString &outputResourceName, int &outputPortIndex, UtlString &inputResourceName, int &inputPortIndex) |
Get the connection definition indicated by the connectionIndex. More... | |
int | getNextLogicalPortNumber () |
Get the next logical port, used when the same port number ??? More... | |
void | initVirtualInputIterator (VirtualPortIterator &portIter) |
Initialize virtual input ports iterator. More... | |
void | freeVirtualInputIterator (VirtualPortIterator &portIter) |
Destroy virtual input ports iterator. More... | |
OsStatus | getNextVirtualInput (VirtualPortIterator &portIter, UtlString &realResourceName, int &realPortIndex, UtlString &virtualResourceName, int &virtualPortIndex) |
Get virtual input data from an iterator. More... | |
void | initVirtualOutputIterator (VirtualPortIterator &portIter) |
Initialize virtual output ports iterator. More... | |
void | freeVirtualOutputIterator (VirtualPortIterator &portIter) |
Destroy virtual output ports iterator. More... | |
OsStatus | getNextVirtualOutput (VirtualPortIterator &portIter, UtlString &realResourceName, int &realPortIndex, UtlString &virtualResourceName, int &virtualPortIndex) |
Get virtual output data from an iterator. More... | |
int | dumpResources (UtlString &dumpString) |
Dump resources to debug string. More... | |
int | dumpConnections (UtlString &dumpString) |
Dump connections to debug string. More... | |
Static Public Member Functions | |
static void | replaceNumInName (UtlString &resourceName, int resourceNum) |
Utility to replace "%d" in resource name with an integer. More... | |
Protected Member Functions | |
int | findResourceConnections (const UtlString &resourceName, UtlContainer &connectionsToTraverse) const |
Protected Attributes | |
int | mPriorLogicalPort |
UtlDList | mResources |
UtlDList | mConnections |
UtlHashMap | mVirtualInputs |
Mapping between virtual and real inputs. More... | |
UtlHashMap | mVirtualOutputs |
Mapping between virtual and real outputs. More... | |
Private Member Functions | |
MpResourceTopology (const MpResourceTopology &rMpResourceTopology) | |
Disabled copy constructor. More... | |
MpResourceTopology & | operator= (const MpResourceTopology &rhs) |
Disabled assignment operator. More... | |
MpResourceTopology is used to define a set of resources and how they are to be connected in a flowgraph.
MpResourceTopology defines a list of resources to be created and a list of connections defining how the resources are to be connected in a flowgraph. There are two types of MpResourceTopologies that may be defined:
1) Full topologies which define all the resources and connections for a new, empty flowgraph. In a full topology the connections must reference only resources defined in the MpResourceTopology.
2) Incremental topologies which define a set of resources to be added to a flowgraph and a set of connections defining how the new resources are connected amongst themselves and the existing resources in the flowgraph. An incremental topology the connections may reference resources which already exist in the flowgraph or resources defined in the MpResourceTopology.
The MpResourceTopology only defines the resources and connections to be created. The actual creation and linking of resources is performed by the flowgraph itself. The flowgraph uses a MpResourceFactory to create the resources listed in the MpResourceTopology. The list of resources in the MpResourceTopology consists of pairs of a resource type and name. The type is used by the flowgraph to instruct the MpResourceFactory to create a specific resource type. The name is the name the resource is to assume in the flowgraph.
typedef UtlHashMapIterator* VirtualPortIterator |
enum MpLogicalPortTypes |
Constructor.
|
virtual |
Destructor.
|
private |
Disabled copy constructor.
OsStatus addResource | ( | const UtlString & | resourceType, |
const UtlString & | resourceName, | ||
MpConnectionID | connectionId = MP_INVALID_CONNECTION_ID , |
||
int | streamId = -1 |
||
) |
Add a new resource definition to the topology.
[in] | resourceType | - type for MpResourceFactory construction |
[in] | resourceName | - unique name for resource in this topology and ultimately in flowgraph. |
[in] | connectionId | - the ID of a connection this resource will belong to. If set to MP_INVALID_CONNECTION_ID then it will be replaced with the concrete ID if requested. |
[in] | streamId | = the ID of a stream in a connection this resource will belong to. |
OsStatus addResources | ( | const ResourceDef * | defines, |
int | numDefines | ||
) |
Add resources from an array.
This method is barely a convenient wrapper around addResource().
OsStatus addConnection | ( | const UtlString & | outputResourceName, |
int | outputPortIndex, | ||
const UtlString & | inputResourceName, | ||
int | inputPortIndex | ||
) |
Add a new connection definition to the topology.
OsStatus addConnections | ( | const ConnectionDef * | defines, |
int | numDefines | ||
) |
Add resources from an array.
This method is barely a convenient wrapper around addConnection(). This method also supports easy creation of chained resources. If outputResourceName is NULL for some connections, name of a source resource is taken from previous inputResourceName. This implies that first connection should always have outputResourceName set.
OsStatus addVirtualInput | ( | const UtlString & | realResourceName, |
int | realPortIndex, | ||
const UtlString & | virtualResourceName, | ||
int | virtualPortIndex | ||
) |
Add a new virtual input definition to the topology.
OS_INVALID_ARGUMENT | if given virtual port is already used. |
OS_SUCCESS | on success. |
OsStatus addVirtualOutput | ( | const UtlString & | realResourceName, |
int | realPortIndex, | ||
const UtlString & | virtualResourceName, | ||
int | virtualPortIndex | ||
) |
Add a new virtual output definition to the topology.
OS_INVALID_ARGUMENT | if given virtual port is already used. |
OS_NOT_FOUND | if real resource name is not found in topology. |
OS_SUCCESS | on success. |
OsStatus validateConnections | ( | UtlString & | firstUnconnectedResourceName, |
UtlString & | firstDanglingResourceName, | ||
UtlBoolean | allowExternalResources = FALSE |
||
) | const |
Validate that the connections are connect the resources.
A full topology MUST NOT have connections that reference resources outside this topology AND all resources MUST be connected to such that there are no dangling resources. An incremental topology MAY have connections that reference resources outside of this topology AND all resources in this topology MUST have at least one connection.
[out] | firstUnconnectedResourceName | - first resource found to not have any connections. |
[out] | firstDanglingResourceName | - first resource found to not be connected topologically to the rest of the resources. This can only be tested in full topologies. We do not know the pre-existing topology in the flowgraph for incremental topologies. |
[in] | allowExternalResources | - FALSE = full topology, TRUE = incremental topology (see definitions at top of this class). |
OsStatus validateResourceTypes | ( | MpResourceFactory & | resourceFactory, |
int & | firstInvalidResourceIndex | ||
) | const |
Validate that all the resource types in this topology have a constructor in the factory.
[in] | resourceFactory | - resource factory to test against. |
[out] | firstInvalidResourceIndex | - index of the first resource found to lack constructor in the provided factory. |
|
static |
Utility to replace "%d" in resource name with an integer.
OsStatus getResource | ( | int | resourceIndex, |
UtlString & | resourceType, | ||
UtlString & | resourceName, | ||
MpConnectionID & | connectionId, | ||
int & | streamId | ||
) | const |
Get the resource definition indicated by the resourceIndex.
OsStatus getResource | ( | int | resourceIndex, |
UtlString & | resourceName | ||
) | const |
Get the resource name by the resourceIndex.
OsStatus getInputVirtualResource | ( | const UtlString & | virtualName, |
int | virtualPort, | ||
UtlString & | resourceName, | ||
int & | resourcePort | ||
) | const |
Get the resource name and port index by the virtual input name and port index.
OsStatus getOutputVirtualResource | ( | const UtlString & | virtualName, |
int | virtualPort, | ||
UtlString & | resourceName, | ||
int & | resourcePort | ||
) | const |
Get the resource name and port index by the virtual output name and port index.
OsStatus getConnection | ( | int | connectionIndex, |
UtlString & | outputResourceName, | ||
int & | outputPortIndex, | ||
UtlString & | inputResourceName, | ||
int & | inputPortIndex | ||
) |
Get the connection definition indicated by the connectionIndex.
int getNextLogicalPortNumber | ( | ) |
Get the next logical port, used when the same port number ???
Used when more than one connection should refer to the same port number, but the port number is not yet known (e.g. use the next available port).
void initVirtualInputIterator | ( | VirtualPortIterator & | portIter | ) |
Initialize virtual input ports iterator.
void freeVirtualInputIterator | ( | VirtualPortIterator & | portIter | ) |
Destroy virtual input ports iterator.
OsStatus getNextVirtualInput | ( | VirtualPortIterator & | portIter, |
UtlString & | realResourceName, | ||
int & | realPortIndex, | ||
UtlString & | virtualResourceName, | ||
int & | virtualPortIndex | ||
) |
Get virtual input data from an iterator.
This method can be called after initVirtualInputIterator() to get first virtual input data and then again to get next virtual input data and so on. On reaching the end of the virtual inputs list method returns OS_NO_MORE_DATA.
OS_NO_MORE_DATA | - No more virtual ports available. Output parameters are not touched. |
OS_SUCCESS | - Next virtual port fetched and all output parameters are filled with correct values. |
void initVirtualOutputIterator | ( | VirtualPortIterator & | portIter | ) |
Initialize virtual output ports iterator.
void freeVirtualOutputIterator | ( | VirtualPortIterator & | portIter | ) |
Destroy virtual output ports iterator.
OsStatus getNextVirtualOutput | ( | VirtualPortIterator & | portIter, |
UtlString & | realResourceName, | ||
int & | realPortIndex, | ||
UtlString & | virtualResourceName, | ||
int & | virtualPortIndex | ||
) |
Get virtual output data from an iterator.
This method can be called after initVirtualOutputIterator() to get first virtual output data and then again to get next virtual output data and so on. On reaching the end of the virtual outputs list method returns OS_NO_MORE_DATA.
OS_NO_MORE_DATA | - No more virtual ports available. Output parameters are not touched. |
OS_SUCCESS | - Next virtual port fetched and all output parameters are filled with correct values. |
int dumpResources | ( | UtlString & | dumpString | ) |
Dump resources to debug string.
int dumpConnections | ( | UtlString & | dumpString | ) |
Dump connections to debug string.
|
protected |
|
private |
Disabled assignment operator.
|
protected |
|
protected |
|
protected |
|
protected |
Mapping between virtual and real inputs.
|
protected |
Mapping between virtual and real outputs.