-/*\r
- *\r
- * Copyright 2004 The Ant-Contrib project\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package net.sf.antcontrib.cpptasks;\r
-\r
-import org.apache.tools.ant.types.DataType;\r
-import org.apache.tools.ant.types.Reference;\r
-\r
-/**\r
- * Information on the execution platforms for the generated code.\r
- * (Non-functional prototype)\r
- *\r
- */\r
-public final class TargetDef\r
- extends DataType {\r
- /**\r
- * if property.\r
- */\r
- private String ifCond;\r
-\r
- /**\r
- * unless property.\r
- */\r
- private String unlessCond;\r
-\r
- /**\r
- * cpu.\r
- *\r
- */\r
- private CPUEnum cpu;\r
-\r
- /**\r
- * architecture.\r
- *\r
- */\r
- private ArchEnum arch;\r
-\r
- /**\r
- * OS Family.\r
- *\r
- */\r
- private OSFamilyEnum osFamily;\r
-\r
- /**\r
- * Constructor.\r
- *\r
- */\r
- public TargetDef() {\r
- }\r
-\r
- /**\r
- * Bogus method required for documentation generation.\r
- */\r
- public void execute() {\r
- throw new org.apache.tools.ant.BuildException(\r
- "Not an actual task, but looks like one for documentation purposes");\r
- }\r
-\r
- /**\r
- * Returns true if the define's if and unless conditions (if any) are\r
- * satisfied.\r
- * @return true if active\r
- */\r
- public boolean isActive() {\r
- return CUtil.isActive(getProject(), ifCond, unlessCond);\r
- }\r
-\r
- /**\r
- * Sets a description of the current data type.\r
- * @param desc description\r
- */\r
- public void setDescription(final String desc) {\r
- super.setDescription(desc);\r
- }\r
-\r
- /**\r
- * Sets an id that can be used to reference this element.\r
- *\r
- * @param id\r
- * id\r
- */\r
- public void setId(final String id) {\r
- //\r
- // this is actually accomplished by a different\r
- // mechanism, but we can document it\r
- //\r
- }\r
-\r
- /**\r
- * Sets the property name for the 'if' condition.\r
- *\r
- * The define will be ignored unless the property is defined.\r
- *\r
- * The value of the property is insignificant, but values that would imply\r
- * misinterpretation ("false", "no") will throw an exception when\r
- * evaluated.\r
- *\r
- * @param propName\r
- * property name\r
- */\r
- public void setIf(final String propName) {\r
- ifCond = propName;\r
- }\r
-\r
- /**\r
- * Specifies that this element should behave as if the content of the\r
- * element with the matching id attribute was inserted at this location. If\r
- * specified, no other attributes should be specified.\r
- * @param r id of referenced target\r
- */\r
- public void setRefid(final Reference r) {\r
- super.setRefid(r);\r
- }\r
-\r
- /**\r
- * Set the property name for the 'unless' condition.\r
- *\r
- * If named property is set, the define will be ignored.\r
- *\r
- * The value of the property is insignificant, but values that would imply\r
- * misinterpretation ("false", "no") of the behavior will throw an\r
- * exception when evaluated.\r
- *\r
- * @param propName\r
- * name of property\r
- */\r
- public void setUnless(final String propName) {\r
- unlessCond = propName;\r
- }\r
-\r
- /**\r
- * Gets cpu.\r
- * @return cpu, may be null.\r
- *\r
- */\r
- public CPUEnum getCpu() {\r
- if (isReference()) {\r
- TargetDef refPlatform = (TargetDef)\r
- getCheckedRef(TargetDef.class,\r
- "TargetDef");\r
- return refPlatform.getCpu();\r
- }\r
- return cpu;\r
- }\r
-\r
- /**\r
- * Gets arch.\r
- * @return arch, may be null.\r
- *\r
- */\r
- public ArchEnum getArch() {\r
- if (isReference()) {\r
- TargetDef refPlatform = (TargetDef)\r
- getCheckedRef(TargetDef.class,\r
- "TargetDef");\r
- return refPlatform.getArch();\r
- }\r
- return arch;\r
- }\r
-\r
- /**\r
- * Gets operating system family.\r
- * @return os family, may be null.\r
- *\r
- */\r
- public OSFamilyEnum getOsfamily() {\r
- if (isReference()) {\r
- TargetDef refPlatform = (TargetDef)\r
- getCheckedRef(TargetDef.class,\r
- "TargetDef");\r
- return refPlatform.getOsfamily();\r
- }\r
- return osFamily;\r
- }\r
-\r
- /**\r
- * Sets preferred cpu, but does not use cpu specific instructions.\r
- * @param value new value\r
- */\r
- public void setCpu(final CPUEnum value) {\r
- if (isReference()) {\r
- throw tooManyAttributes();\r
- }\r
- cpu = value;\r
- }\r
-\r
- /**\r
- * Sets cpu architecture, compiler may use cpu specific instructions.\r
- * @param value new value\r
- */\r
- public void setArch(final ArchEnum value) {\r
- if (isReference()) {\r
- throw tooManyAttributes();\r
- }\r
- if (cpu != null) {\r
- throw tooManyAttributes();\r
- }\r
- arch = value;\r
- }\r
-\r
- /**\r
- * Sets operating system family.\r
- * @param value new value\r
- */\r
- public void setOsfamily(final OSFamilyEnum value) {\r
- if (isReference()) {\r
- throw tooManyAttributes();\r
- }\r
- if (cpu != null) {\r
- throw tooManyAttributes();\r
- }\r
- osFamily = value;\r
- }\r
-\r
-}\r