TIOVX User Guide
context.py
1
#
2
# Copyright (c) 2017 Texas Instruments Incorporated
3
#
4
# All rights reserved not granted herein.
5
#
6
# Limited License.
7
#
8
# Texas Instruments Incorporated grants a world-wide, royalty-free, non-exclusive
9
# license under copyrights and patents it now or hereafter owns or controls to make,
10
# have made, use, import, offer to sell and sell ("Utilize") this software subject to the
11
# terms herein. With respect to the foregoing patent license, such license is granted
12
# solely to the extent that any such patent is necessary to Utilize the software alone.
13
# The patent license shall not apply to any combinations which include this software,
14
# other than combinations with devices manufactured by or for TI ("TI Devices").
15
# No hardware patent is licensed hereunder.
16
#
17
# Redistributions must preserve existing copyright notices and reproduce this license
18
# (including the above copyright notice and the disclaimer and (if applicable) source
19
# code license limitations below) in the documentation and/or other materials provided
20
# with the distribution
21
#
22
# Redistribution and use in binary form, without modification, are permitted provided
23
# that the following conditions are met:
24
#
25
# No reverse engineering, decompilation, or disassembly of this software is
26
# permitted with respect to any software provided in binary form.
27
#
28
# any redistribution and use are licensed by TI for use only with TI Devices.
29
#
30
# Nothing shall obligate TI to provide you with source code for the software
31
# licensed and provided to you in object code.
32
#
33
# If software source code is provided to you, modification and redistribution of the
34
# source code are permitted provided that the following conditions are met:
35
#
36
# any redistribution and use of the source code, including any resulting derivative
37
# works, are licensed by TI for use only with TI Devices.
38
#
39
# any redistribution and use of any object code compiled from the source code
40
# and any resulting derivative works, are licensed by TI for use only with TI Devices.
41
#
42
# Neither the name of Texas Instruments Incorporated nor the names of its suppliers
43
#
44
# may be used to endorse or promote products derived from this software without
45
# specific prior written permission.
46
#
47
# DISCLAIMER.
48
#
49
# THIS SOFTWARE IS PROVIDED BY TI AND TI'S LICENSORS "AS IS" AND ANY EXPRESS
50
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
51
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
52
# IN NO EVENT SHALL TI AND TI'S LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT,
53
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
54
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
55
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
56
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
57
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
58
# OF THE POSSIBILITY OF SUCH DAMAGE.
59
#
60
#
61
62
from
.
import
*
63
64
80
class
Context
(Reference) :
81
86
def
__init__
(self, name="default") :
87
Reference.__init__(self, Type.CONTEXT, name)
88
self.
ref
= []
89
self.
node_list
= []
90
self.
data_list
= []
91
self.
graph_list
= []
92
self.
target_list
= []
93
self.
is_target_present
= {}
94
for
target
in
Target :
95
self.
is_target_present
[target.name] =
False
96
97
def
isDuplicate(self, ref, list) :
98
for
l
in
list :
99
if
l == ref :
100
return
True
101
return
False
102
103
106
def
add
(self,ref) :
107
if
self.
isDuplicate
(ref, self.
ref
) ==
False
:
108
self.
ref
.append(ref)
109
# add to node, data, graph list
110
if( ref.type == Type.GRAPH) :
111
self.
addGraph
(ref)
112
elif( ref.type == Type.NODE) :
113
self.
addNode
(ref)
114
else
:
115
self.
addData
(ref)
116
117
def
__str__(self):
118
print_str = Reference.__str__(self)
119
for
ref
in
self.
ref
:
120
print_str = print_str +
'\n'
+ str(ref)
121
return
print_str
122
123
def
addGraph(self, ref) :
124
ref.__class__ = Graph
125
if
self.
isDuplicate
(ref, self.
graph_list
) ==
False
:
126
self.
graph_list
.append(ref)
127
for
node
in
ref.ref :
128
self.
addNode
(node)
129
130
def
addData(self, ref) :
131
if
self.
isDuplicate
(ref, self.
data_list
) ==
False
:
132
self.
data_list
.append(ref)
133
134
def
addNode(self, ref) :
135
ref.__class__ = Node
136
if
self.
isDuplicate
(ref, self.
node_list
) ==
False
:
137
self.
node_list
.append(ref)
138
self.
addTarget
(ref.target)
139
for
data
in
ref.ref :
140
self.
addData
(data)
141
142
def
addTarget(self, target) :
143
# if not already added, then add it
144
if
self.
is_target_present
[target.name] ==
False
:
145
self.
target_list
.append(target)
146
self.
is_target_present
[target.name] =
True
tiovx.context.Context.add
def add(self, ref)
Add graph or node or data object to context.
Definition:
context.py:106
tiovx.context.Context.addNode
def addNode(self, ref)
Definition:
context.py:134
tiovx.context.Context.graph_list
graph_list
Definition:
context.py:91
tiovx.context.Context.isDuplicate
def isDuplicate(self, ref, list)
Definition:
context.py:97
tiovx.context.Context.addGraph
def addGraph(self, ref)
Definition:
context.py:123
tiovx.context.Context.node_list
node_list
Definition:
context.py:89
tiovx.context.Context
Context object (OpenVX equivalent = vx_context)
Definition:
context.py:80
tiovx.context.Context.target_list
target_list
Definition:
context.py:92
tiovx.context.Context.ref
ref
Definition:
context.py:88
tiovx.context.Context.__init__
def __init__(self, name="default")
Constructor used to create this object.
Definition:
context.py:86
tiovx.context.Context.data_list
data_list
Definition:
context.py:90
tiovx.context.Context.addData
def addData(self, ref)
Definition:
context.py:130
tiovx.context.Context.addTarget
def addTarget(self, target)
Definition:
context.py:142
tiovx.context.Context.is_target_present
is_target_present
Definition:
context.py:93
tools
PyTIOVX
tiovx
context.py
Generated by
1.8.14