00001 /******************************************************************************* 00002 * Copyright (c) 2006 International Business Machines Corporation 00003 * All rights reserved. This program and the accompanying materials 00004 * are made available under the terms of the Common Public License v1.0 00005 * which accompanies this distribution, and is available at 00006 * http://www.opensource.org/licenses/cpl1.0.php 00007 * 00008 * Contributors: 00009 * Douglas Sprague, Joel Wheeler - initial API and implementation 00010 * 00011 *****************************************************************************/ 00012 00013 #ifndef STILSignal_H 00014 #define STILSignal_H 00015 00016 #include "stilsignalblock.h" 00017 00018 //forward prototype 00019 class STILSignalList; 00020 00021 // STILSignal Class 00022 //--------------------------------------------------------------------------- 00029 //--------------------------------------------------------------------------- 00030 class STILSignal : public STILSignalBlock { 00031 00032 // - Global std::ostream << operator as friend to output STILSignal object 00033 friend std::ostream& operator<<( std::ostream &os, const STILSignal &); 00034 00035 // - Allow STILSignalList to access data members 00036 friend class STILSignalList; 00037 00038 // - Public members 00039 public: 00040 00041 // The basic type of usage for this signal 00042 enum Usage { 00043 UndefinedUsage, 00044 In, 00045 Out, 00046 InOut, 00047 Supply, 00048 Pseudo 00049 }; 00050 00051 // - Default Constructor 00052 STILSignal(); 00053 00054 // - Copy Constructor 00055 STILSignal(const STILSignal &); 00056 00057 // - Destructor 00058 virtual ~STILSignal(); 00059 00060 // - Assignment Operator 00061 STILSignal & operator=(const STILSignal &); 00062 00063 // - Initialize this STILSignal object. 00064 void init(); 00065 00066 // - Write out this object to a given FILE 00067 virtual void write(FILE * pOutFile, LONG indentation=0) const; 00068 00069 00070 // - Member functions to set/get Usage 00071 void setUsage(Usage) ; 00072 Usage getUsage() const; 00073 00074 // - Member functions to get/set first & last array index (-1 if not an array) 00075 LONG getFirstIndex() const; 00076 void setFirstIndex(LONG); 00077 LONG getLastIndex() const; 00078 void setLastIndex(LONG); 00079 00080 // - Member functions to set/get ID. ID will be a unique numeric 00081 // identifier for this signal. It will be indicative of the count 00082 // (starting at 0) of this particular signal object in the Signals block. 00083 void setID(LONG) ; 00084 LONG getID() const; 00085 00086 // - Static Member functions to convert enumerations to sstring values 00087 static const sstring & convertUsage(Usage); 00088 00089 // Private members 00090 private: 00091 // - Set the base data members to the SignalGroup base values (for 00092 // - flattening from SignalGroups into a SignalList) 00093 void resetBaseValues (const STILSignalBlock*); 00094 00095 // Usage for this signal 00096 Usage m_usage; 00097 00098 // First & Last index if this is a Signal array 00099 // NOTE: For every Signal declaration XYZ[m..n] in the signals block 00100 // there will be a separate Signal object even if the base name 00101 // "XYZ" is the same. It is an error to have more than one 00102 // XYZ signal declarations that share index values. 00103 LONG m_firstIndex; // -1 if not declared as an array 00104 LONG m_lastIndex; // -1 if not declared as an array 00105 00106 // A unique numeric ID for a given signal. This ID value is actually 00107 // the running count (starting at 0) of this particular signal entry in the 00108 // Signals block. 00109 // Note: For signal array entries this is the count of the first element 00110 // of the array. 00111 LONG m_id; 00112 00113 }; // end STILSignal class 00114 00115 00116 // Inline functions 00117 //-------------------------------------------------------------------------- 00125 //-------------------------------------------------------------------------- 00126 inline void STILSignal::setUsage(Usage u) { m_usage = u; } 00127 00128 //-------------------------------------------------------------------------- 00136 //-------------------------------------------------------------------------- 00137 inline STILSignal::Usage STILSignal::getUsage() const { return m_usage; } 00138 00139 //-------------------------------------------------------------------------- 00147 //-------------------------------------------------------------------------- 00148 inline LONG STILSignal::getFirstIndex() const { return m_firstIndex; } 00149 00150 //-------------------------------------------------------------------------- 00158 //-------------------------------------------------------------------------- 00159 inline void STILSignal::setFirstIndex(LONG i) { m_firstIndex = i; } 00160 00161 //-------------------------------------------------------------------------- 00169 //-------------------------------------------------------------------------- 00170 inline LONG STILSignal::getLastIndex() const { return m_lastIndex; } 00171 00172 //-------------------------------------------------------------------------- 00180 //-------------------------------------------------------------------------- 00181 inline void STILSignal::setLastIndex(LONG i) { m_lastIndex = i; } 00182 00183 //-------------------------------------------------------------------------- 00191 //-------------------------------------------------------------------------- 00192 inline LONG STILSignal::getID() const { return m_id; } 00193 00194 //-------------------------------------------------------------------------- 00202 //-------------------------------------------------------------------------- 00203 inline void STILSignal::setID(LONG i) { m_id = i; } 00204 00205 #endif