1// BEGIN LICENSE BLOCK 2// Version: CMPL 1.1 3// 4// The contents of this file are subject to the Cisco-style Mozilla Public 5// License Version 1.1 (the "License"); you may not use this file except 6// in compliance with the License. You may obtain a copy of the License 7// at www.eclipse-clp.org/license. 8// 9// Software distributed under the License is distributed on an "AS IS" 10// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 11// the License for the specific language governing rights and limitations 12// under the License. 13// 14// The Original Code is The ECLiPSe Constraint Logic Programming System. 15// The Initial Developer of the Original Code is Cisco Systems, Inc. 16// Portions created by the Initial Developer are 17// Copyright (C) 2006 Cisco Systems, Inc. All Rights Reserved. 18// 19// Contributor(s): 20// 21// END LICENSE BLOCK 22 23package com.parctechnologies.eclipse.visualisation; 24 25import com.parctechnologies.eclipse.*; 26import java.util.*; 27import java.io.Serializable; 28 29/** 30 * Class to represent some basic properties of viewables. This class does not 31 * mirror the contents of the ECLiPSe-side data structure. 32 */ 33public class Viewable implements SymRefable, Serializable 34{ 35 private String name; 36 private ViewableType type; 37 38 /** 39 * Hold the symbolic refernce for this viewable. Having SymRefs simplifies 40 * scenario recording/playing 41 */ 42 private SymRef symRef ; 43 44 /** 45 * Integer used to ensure unique interest spec names. 46 */ 47 private int interestSpecNumber; 48 49 public Viewable(String name, ViewableType type) 50 { 51 this.name = name; 52 this.type = type; 53 interestSpecNumber = 0; 54 this.symRef = new SymRef(this, getNameString()); 55 } 56 57 public Atom getNameAtom() 58 { 59 return(new Atom(name)); 60 } 61 62 /** 63 * Create a uniquely-named interest spec for this viewable. 64 */ 65 public synchronized InterestSpec createInterestSpec() 66 { 67 if (DebuggingSupport.logMessages) { 68 DebuggingSupport.logMessage(this, 69 "createInterestSpec name=" + 70 getNameString() + 71 "number=" + interestSpecNumber); 72 } 73 InterestSpec result = 74 new InterestSpec(getNameString()+interestSpecNumber, this); 75 interestSpecNumber++; 76 return(result); 77 } 78 79 /** 80 * Return name in form of a string whether it is one or not. 81 */ 82 public String getNameString() 83 { 84 return(name); 85 } 86 87 public ViewableType getType() 88 { 89 return(type); 90 } 91 92 void setType(ViewableType type) 93 { 94 this.type = type; 95 } 96 97 public SymRef getSymRef() { 98 return symRef; 99 } 100 101 public void setSymRef(SymRef symRef) { 102 this.symRef = symRef; 103 } 104} 105