X-Git-Url: http://sraa.de/git/?a=blobdiff_plain;f=dol%2Fsrc%2Fdol%2Fdatamodel%2Fpn%2FResource.java;fp=dol%2Fsrc%2Fdol%2Fdatamodel%2Fpn%2FResource.java;h=d212bbe477855df5b939c018f21032223546b246;hb=8c411cf24ed0eb889191aaeafd8fa1e69081df42;hp=0000000000000000000000000000000000000000;hpb=dea7a4fb1ed110d3ce6e6d9255103d724bd66c0e;p=jump.git diff --git a/dol/src/dol/datamodel/pn/Resource.java b/dol/src/dol/datamodel/pn/Resource.java new file mode 100644 index 0000000..d212bbe --- /dev/null +++ b/dol/src/dol/datamodel/pn/Resource.java @@ -0,0 +1,269 @@ +/* $Id: Resource.java 1 2010-02-24 13:03:05Z haidw $ */ +package dol.datamodel.pn; + +import java.util.Vector; + +import dol.visitor.PNVisitor; + +/** + * This class is the basic class which abstracts a resource of a generic + * process network. The resource has a name and a list of ports. + */ +public class Resource { + + /** + * Constructor to create a resource with a name and an empty + * portList. + */ + public Resource(String name) { + _name = name; + _basename = name; + _portList = new Vector(); + _srcList = new Vector(); + _cfgList = new Vector(); + _profilingList = new Vector(); + } + + /** + * Accept a Visitor + * + * @param x visitor object + */ + public void accept(PNVisitor x) { + x.visitComponent(this); + } + + /** + * Clone this resource. + * + * @return new instance of the resource. + */ + @SuppressWarnings("unchecked") + public Object clone() { + try { + Resource newObj = (Resource) super.clone(); + newObj.setName(_name); + newObj.setType(_type); + newObj.setBasename(_basename); + newObj.setPortList((Vector)_portList.clone() ); + newObj.setSrcList((Vector)_srcList.clone() ); + newObj.setCfgList((Vector)_cfgList.clone() ); + newObj.setProfilingList((Vector)_profilingList.clone() ); + return (newObj); + } catch (CloneNotSupportedException e) { + System.out.println("Error Clone not Supported"); + } + return null; + } + + public String getBasename() { + return _basename; + } + + public void setBasename(String basename) { + _basename = basename; + } + + /** + * Get the name of this resource. + * + * @return name of the resource + */ + public String getName() { + return _name; + } + + /** + * Set the name of this resource. + * + * @param name name of the resource + */ + public void setName(String name) { + _name = name; + } + + /** + * Get the type of this resource. + * + * @return type of the resource + */ + public String getType() { + return _type; + } + + /** + * Set the type of this resource. + * + * @param type type of the resource + */ + public void setType(String type) { + _type = type; + } + + /** + * Get the list of source codes of this resource. + * + * @return list of source codes + */ + public Vector getSrcList() { + return _srcList; + } + + /** + * Get the list of ports of this resource. + * + * @return list of ports + */ + public Vector getPortList() { + return _portList; + } + + /** + * Set the list of ports of this resource. + * + * @param portList port list + */ + public void setPortList(Vector portList) { + _portList = portList; + } + + /** + * Get the list of configurations of this resource. + * + * @return list of configurations + */ + public Vector getCfgList() { + return _cfgList; + } + + /** + * Set the list of configurations of this resource. + * + * @param cfgList configuration list + */ + public void setCfgList(Vector cfgList) { + _cfgList = cfgList; + } + + /** + * Get the list of profiling info of this resource. + * + * @return list of profiling info + */ + public Vector getProfilingList() { + return _profilingList; + } + + /** + * Set the list of profiling info of this resource. + * + * @param cfgList profiling info list + */ + public void setProfilingList(Vector cfgList) { + _profilingList = cfgList; + } + + /** + * Return a profiling which has a specific name. Return null when it + * cannot be found. + * + * @param name name of the profiling to search for + * @return profiling with the specified name + */ + public ProfilingConfiguration getProfilingCfg(String name) { + for (ProfilingConfiguration cfg : _profilingList) { + if (cfg.getName().equals(name)) { + return cfg; + } + } + return null; + } + + /** + * Set the list of source code of this resource. + * + * @param srcList port list + */ + public void setSrcList(Vector srcList) { + _srcList = srcList; + } + + /** + * Get the hierarchical parent of this resource. + * + * @return parent of this resource + */ + public Resource getParentResource() { + return _parentResource; + } + + /** + * Set the hierarchical parent of this resource. + * + * @param parentResource new parent + */ + public void setParentResource(Resource parentResource) { + _parentResource = parentResource; + } + + /** + * Return a string representation of the resource. + * + * @return string representation of the resource + */ + public String toString() { + return "Resource: " + _name; + } + + /** + * Return a port which has a specific name. Return null when port + * cannot be found. + * + * @param name name of the port to search for + * @return port with the specified name + */ + public Port getPort(String name) { + for (Port port : _portList) { + if (port.getName().equals(name)) { + return port; + } + } + return null; + } + + /** + * Return a port which has a specific name. Return null when port + * cannot be found. + * + * @return port with the specified name + */ + public Port getFirstPort() { + return (Port) _portList.firstElement(); + } + + /** name of the resource */ + protected String _name = null; + + /** type of the resource */ + protected String _type = null; + + /** basename of the resource, if no basename, store the name */ + protected String _basename = null; + + /** list of the ports of the Resource */ + protected Vector _portList = null; + + /** list of the source codes of the Resource */ + protected Vector _srcList = null; + + /** list of the configurations of the Resource */ + protected Vector _cfgList = null; + + /** list of the profiling info of the Resource */ + protected Vector _profilingList = null; + + /** + * parent resource of this resource in a hierarchical process network + */ + protected Resource _parentResource = null; +}