1 /* $Id: Resource.java 1 2010-02-24 13:03:05Z haidw $ */
2 package dol.datamodel.pn;
4 import java.util.Vector;
6 import dol.visitor.PNVisitor;
9 * This class is the basic class which abstracts a resource of a generic
10 * process network. The resource has a name and a list of ports.
12 public class Resource {
15 * Constructor to create a resource with a name and an empty
18 public Resource(String name) {
21 _portList = new Vector<Port>();
22 _srcList = new Vector<SourceCode>();
23 _cfgList = new Vector<Configuration>();
24 _profilingList = new Vector<ProfilingConfiguration>();
30 * @param x visitor object
32 public void accept(PNVisitor x) {
33 x.visitComponent(this);
37 * Clone this resource.
39 * @return new instance of the resource.
41 @SuppressWarnings("unchecked")
42 public Object clone() {
44 Resource newObj = (Resource) super.clone();
45 newObj.setName(_name);
46 newObj.setType(_type);
47 newObj.setBasename(_basename);
48 newObj.setPortList((Vector)_portList.clone() );
49 newObj.setSrcList((Vector)_srcList.clone() );
50 newObj.setCfgList((Vector)_cfgList.clone() );
51 newObj.setProfilingList((Vector)_profilingList.clone() );
53 } catch (CloneNotSupportedException e) {
54 System.out.println("Error Clone not Supported");
59 public String getBasename() {
63 public void setBasename(String basename) {
68 * Get the name of this resource.
70 * @return name of the resource
72 public String getName() {
77 * Set the name of this resource.
79 * @param name name of the resource
81 public void setName(String name) {
86 * Get the type of this resource.
88 * @return type of the resource
90 public String getType() {
95 * Set the type of this resource.
97 * @param type type of the resource
99 public void setType(String type) {
104 * Get the list of source codes of this resource.
106 * @return list of source codes
108 public Vector<SourceCode> getSrcList() {
113 * Get the list of ports of this resource.
115 * @return list of ports
117 public Vector<Port> getPortList() {
122 * Set the list of ports of this resource.
124 * @param portList port list
126 public void setPortList(Vector<Port> portList) {
127 _portList = portList;
131 * Get the list of configurations of this resource.
133 * @return list of configurations
135 public Vector<Configuration> getCfgList() {
140 * Set the list of configurations of this resource.
142 * @param cfgList configuration list
144 public void setCfgList(Vector<Configuration> cfgList) {
149 * Get the list of profiling info of this resource.
151 * @return list of profiling info
153 public Vector<ProfilingConfiguration> getProfilingList() {
154 return _profilingList;
158 * Set the list of profiling info of this resource.
160 * @param cfgList profiling info list
162 public void setProfilingList(Vector<ProfilingConfiguration> cfgList) {
163 _profilingList = cfgList;
167 * Return a profiling which has a specific name. Return null when it
170 * @param name name of the profiling to search for
171 * @return profiling with the specified name
173 public ProfilingConfiguration getProfilingCfg(String name) {
174 for (ProfilingConfiguration cfg : _profilingList) {
175 if (cfg.getName().equals(name)) {
183 * Set the list of source code of this resource.
185 * @param srcList port list
187 public void setSrcList(Vector<SourceCode> srcList) {
192 * Get the hierarchical parent of this resource.
194 * @return parent of this resource
196 public Resource getParentResource() {
197 return _parentResource;
201 * Set the hierarchical parent of this resource.
203 * @param parentResource new parent
205 public void setParentResource(Resource parentResource) {
206 _parentResource = parentResource;
210 * Return a string representation of the resource.
212 * @return string representation of the resource
214 public String toString() {
215 return "Resource: " + _name;
219 * Return a port which has a specific name. Return null when port
222 * @param name name of the port to search for
223 * @return port with the specified name
225 public Port getPort(String name) {
226 for (Port port : _portList) {
227 if (port.getName().equals(name)) {
235 * Return a port which has a specific name. Return null when port
238 * @return port with the specified name
240 public Port getFirstPort() {
241 return (Port) _portList.firstElement();
244 /** name of the resource */
245 protected String _name = null;
247 /** type of the resource */
248 protected String _type = null;
250 /** basename of the resource, if no basename, store the name */
251 protected String _basename = null;
253 /** list of the ports of the Resource */
254 protected Vector<Port> _portList = null;
256 /** list of the source codes of the Resource */
257 protected Vector<SourceCode> _srcList = null;
259 /** list of the configurations of the Resource */
260 protected Vector<Configuration> _cfgList = null;
262 /** list of the profiling info of the Resource */
263 protected Vector<ProfilingConfiguration> _profilingList = null;
266 * parent resource of this resource in a hierarchical process network
268 protected Resource _parentResource = null;