]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/TargetDef.java
Restructuring for better separation of Tool packages.
[mirror_edk2.git] / Tools / Java / Source / Cpptasks / net / sf / antcontrib / cpptasks / TargetDef.java
1 /*
2 *
3 * Copyright 2004 The Ant-Contrib project
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package net.sf.antcontrib.cpptasks;
18
19 import org.apache.tools.ant.types.DataType;
20 import org.apache.tools.ant.types.Reference;
21
22 /**
23 * Information on the execution platforms for the generated code.
24 * (Non-functional prototype)
25 *
26 */
27 public final class TargetDef
28 extends DataType {
29 /**
30 * if property.
31 */
32 private String ifCond;
33
34 /**
35 * unless property.
36 */
37 private String unlessCond;
38
39 /**
40 * cpu.
41 *
42 */
43 private CPUEnum cpu;
44
45 /**
46 * architecture.
47 *
48 */
49 private ArchEnum arch;
50
51 /**
52 * OS Family.
53 *
54 */
55 private OSFamilyEnum osFamily;
56
57 /**
58 * Constructor.
59 *
60 */
61 public TargetDef() {
62 }
63
64 /**
65 * Bogus method required for documentation generation.
66 */
67 public void execute() {
68 throw new org.apache.tools.ant.BuildException(
69 "Not an actual task, but looks like one for documentation purposes");
70 }
71
72 /**
73 * Returns true if the define's if and unless conditions (if any) are
74 * satisfied.
75 * @return true if active
76 */
77 public boolean isActive() {
78 return CUtil.isActive(getProject(), ifCond, unlessCond);
79 }
80
81 /**
82 * Sets a description of the current data type.
83 * @param desc description
84 */
85 public void setDescription(final String desc) {
86 super.setDescription(desc);
87 }
88
89 /**
90 * Sets an id that can be used to reference this element.
91 *
92 * @param id
93 * id
94 */
95 public void setId(final String id) {
96 //
97 // this is actually accomplished by a different
98 // mechanism, but we can document it
99 //
100 }
101
102 /**
103 * Sets the property name for the 'if' condition.
104 *
105 * The define will be ignored unless the property is defined.
106 *
107 * The value of the property is insignificant, but values that would imply
108 * misinterpretation ("false", "no") will throw an exception when
109 * evaluated.
110 *
111 * @param propName
112 * property name
113 */
114 public void setIf(final String propName) {
115 ifCond = propName;
116 }
117
118 /**
119 * Specifies that this element should behave as if the content of the
120 * element with the matching id attribute was inserted at this location. If
121 * specified, no other attributes should be specified.
122 * @param r id of referenced target
123 */
124 public void setRefid(final Reference r) {
125 super.setRefid(r);
126 }
127
128 /**
129 * Set the property name for the 'unless' condition.
130 *
131 * If named property is set, the define will be ignored.
132 *
133 * The value of the property is insignificant, but values that would imply
134 * misinterpretation ("false", "no") of the behavior will throw an
135 * exception when evaluated.
136 *
137 * @param propName
138 * name of property
139 */
140 public void setUnless(final String propName) {
141 unlessCond = propName;
142 }
143
144 /**
145 * Gets cpu.
146 * @return cpu, may be null.
147 *
148 */
149 public CPUEnum getCpu() {
150 if (isReference()) {
151 TargetDef refPlatform = (TargetDef)
152 getCheckedRef(TargetDef.class,
153 "TargetDef");
154 return refPlatform.getCpu();
155 }
156 return cpu;
157 }
158
159 /**
160 * Gets arch.
161 * @return arch, may be null.
162 *
163 */
164 public ArchEnum getArch() {
165 if (isReference()) {
166 TargetDef refPlatform = (TargetDef)
167 getCheckedRef(TargetDef.class,
168 "TargetDef");
169 return refPlatform.getArch();
170 }
171 return arch;
172 }
173
174 /**
175 * Gets operating system family.
176 * @return os family, may be null.
177 *
178 */
179 public OSFamilyEnum getOsfamily() {
180 if (isReference()) {
181 TargetDef refPlatform = (TargetDef)
182 getCheckedRef(TargetDef.class,
183 "TargetDef");
184 return refPlatform.getOsfamily();
185 }
186 return osFamily;
187 }
188
189 /**
190 * Sets preferred cpu, but does not use cpu specific instructions.
191 * @param value new value
192 */
193 public void setCpu(final CPUEnum value) {
194 if (isReference()) {
195 throw tooManyAttributes();
196 }
197 cpu = value;
198 }
199
200 /**
201 * Sets cpu architecture, compiler may use cpu specific instructions.
202 * @param value new value
203 */
204 public void setArch(final ArchEnum value) {
205 if (isReference()) {
206 throw tooManyAttributes();
207 }
208 if (cpu != null) {
209 throw tooManyAttributes();
210 }
211 arch = value;
212 }
213
214 /**
215 * Sets operating system family.
216 * @param value new value
217 */
218 public void setOsfamily(final OSFamilyEnum value) {
219 if (isReference()) {
220 throw tooManyAttributes();
221 }
222 if (cpu != null) {
223 throw tooManyAttributes();
224 }
225 osFamily = value;
226 }
227
228 }