1 ///////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2013 Academy of Motion Picture Arts and Sciences
3 // ("A.M.P.A.S."). Portions contributed by others as indicated.
4 // All rights reserved.
5 //
6 // A worldwide, royalty-free, non-exclusive right to copy, modify, create
7 // derivatives, and use, in source and binary forms, is hereby granted,
8 // subject to acceptance of this license. Performance of any of the
9 // aforementioned acts indicates acceptance to be bound by the following
10 // terms and conditions:
11 //
12 //  * Copies of source code, in whole or in part, must retain the
13 //    above copyright notice, this list of conditions and the
14 //    Disclaimer of Warranty.
15 //
16 //  * Use in binary form must retain the above copyright notice,
17 //    this list of conditions and the Disclaimer of Warranty in the
18 //    documentation and/or other materials provided with the distribution.
19 //
20 //  * Nothing in this license shall be deemed to grant any rights to
21 //    trademarks, copyrights, patents, trade secrets or any other
22 //    intellectual property of A.M.P.A.S. or any contributors, except
23 //    as expressly stated herein.
24 //
25 //  * Neither the name "A.M.P.A.S." nor the name of any other
26 //    contributors to this software may be used to endorse or promote
27 //    products derivative of or based on this software without express
28 //    prior written permission of A.M.P.A.S. or the contributors, as
29 //    appropriate.
30 //
31 // This license shall be construed pursuant to the laws of the State of
32 // California, and any disputes related thereto shall be subject to the
33 // jurisdiction of the courts therein.
34 //
35 // Disclaimer of Warranty: THIS SOFTWARE IS PROVIDED BY A.M.P.A.S. AND
36 // CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
37 // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
38 // FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT ARE DISCLAIMED. IN NO
39 // EVENT SHALL A.M.P.A.S., OR ANY CONTRIBUTORS OR DISTRIBUTORS, BE LIABLE
40 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, RESITUTIONARY,
41 // OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
42 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
43 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
44 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
45 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
46 // THE POSSIBILITY OF SUCH DAMAGE.
47 //
48 // WITHOUT LIMITING THE GENERALITY OF THE FOREGOING, THE ACADEMY
49 // SPECIFICALLY DISCLAIMS ANY REPRESENTATIONS OR WARRANTIES WHATSOEVER
50 // RELATED TO PATENT OR OTHER INTELLECTUAL PROPERTY RIGHTS IN THE ACADEMY
51 // COLOR ENCODING SYSTEM, OR APPLICATIONS THEREOF, HELD BY PARTIES OTHER
52 // THAN A.M.P.A.S., WHETHER DISCLOSED OR UNDISCLOSED.
53 ///////////////////////////////////////////////////////////////////////////
54 
55 
56 //-----------------------------------------------------------------------------
57 //
58 //	class FunctionCall, class FunctionArg
59 //
60 //-----------------------------------------------------------------------------
61 
62 #include <CtlFunctionCall.h>
63 #include <CtlType.h>
64 #include <string>
65 
66 using namespace std;
67 
68 namespace Ctl {
69 
FunctionCall(const string & name)70 FunctionCall::FunctionCall (const string &name): _name (name)
71 {
72     // empty
73 }
74 
75 
~FunctionCall()76 FunctionCall::~FunctionCall ()
77 {
78     // empty
79 }
80 
81 
82 FunctionArgPtr
findInputArg(const string & name)83 FunctionCall::findInputArg (const string &name)
84 {
85     for (size_t i = 0; i < _inputArgs.size(); ++i)
86 	if (_inputArgs[i]->name() == name)
87 	    return _inputArgs[i];
88 
89     return 0;
90 }
91 
92 
93 FunctionArgPtr
findOutputArg(const string & name)94 FunctionCall::findOutputArg (const string &name)
95 {
96     for (size_t i = 0; i < _outputArgs.size(); ++i)
97 	if (_outputArgs[i]->name() == name)
98 	    return _outputArgs[i];
99 
100     return 0;
101 }
102 
103 
104 void
setInputArg(size_t i,const FunctionArgPtr & arg)105 FunctionCall::setInputArg (size_t i, const FunctionArgPtr &arg)
106 {
107     if (_inputArgs.size() <= i)
108 	_inputArgs.resize (i + 1);
109 
110     _inputArgs[i] = arg;
111 }
112 
113 
114 void
setOutputArg(size_t i,const FunctionArgPtr & arg)115 FunctionCall::setOutputArg (size_t i, const FunctionArgPtr &arg)
116 {
117     if (_outputArgs.size() <= i)
118 	_outputArgs.resize (i + 1);
119 
120     _outputArgs[i] = arg;
121 }
122 
123 
124 void
setReturnValue(const FunctionArgPtr & rval)125 FunctionCall::setReturnValue (const FunctionArgPtr &rval)
126 {
127     _returnValue = rval;
128 }
129 
FunctionArg(const string & name,FunctionCall * func,const DataTypePtr & type,bool varying)130 FunctionArg::FunctionArg
131     (const string &name,
132      FunctionCall* func,
133      const DataTypePtr &type,
134      bool varying)
135 :
136     TypeStorage(name, type),
137     _func (func),
138     _varying (varying)
139 {
140     // empty
141 }
142 
~FunctionArg()143 FunctionArg::~FunctionArg ()
144 {
145     // empty
146 }
147 
148 } // namespace Ctl
149