File indexing completed on 2025-04-19 09:10:07
0001 #ifndef MODEL__Main__Color_Function_H
0002 #define MODEL__Main__Color_Function_H
0003
0004 #include <string>
0005
0006 namespace MODEL {
0007
0008 class cf {
0009 public:
0010 enum code {
0011 T=0,
0012 F=1,
0013 D=2,
0014 None=3,
0015 G=4,
0016 UFO=5,
0017 Unknown=99};
0018 };
0019
0020 std::ostream &operator<<(std::ostream &str,const cf::code &c);
0021
0022 class Color_Function {
0023 public:
0024 cf::code m_type;
0025 int m_partarg[3];
0026 char m_strarg[3];
0027 std::string m_string;
0028 Color_Function* p_next;
0029 public:
0030 Color_Function() {
0031 m_type = cf::Unknown;
0032 p_next = 0;
0033 for (short int i=0;i<3;++i) m_partarg[i] = -1;
0034 for (short int i=0;i<3;++i) m_strarg[i] = '?';
0035 }
0036
0037 Color_Function(cf::code _type,
0038 int _partarg0 = -1, int _partarg1 = -1, int _partarg2 = -1,
0039 Color_Function* n=NULL)
0040 : m_type(_type), p_next(n)
0041 {
0042 m_partarg[0] = _partarg0;
0043 m_partarg[1] = _partarg1;
0044 m_partarg[2] = _partarg2;
0045 m_strarg[0] = _partarg0>0?_partarg0+47:52;
0046 m_strarg[1] = _partarg1>0?_partarg1+47:52;
0047 m_strarg[2] = _partarg2>0?_partarg2+47:52;
0048 }
0049
0050 Color_Function(const Color_Function & c) : p_next(NULL)
0051 {
0052 *this=c;
0053 }
0054
0055 Color_Function & operator=(const Color_Function & c);
0056 ~Color_Function();
0057
0058 bool operator==(const Color_Function &c) const;
0059
0060 void SetParticleArg(int a, int b,int c=-1) {
0061 m_partarg[0] = a;m_partarg[1] = b;
0062 if (m_type!=cf::D && m_type!=cf::G) m_partarg[2] = c;
0063 }
0064
0065 void SetStringArg(char a, char b, char c='?') {
0066 m_strarg[0] = a;m_strarg[1] = b;
0067 if (m_type!=cf::D && m_type!=cf::G) m_strarg[2] = c;
0068 }
0069
0070 int ParticleArg(int i) const
0071 {
0072 return m_partarg[i];
0073 }
0074 char StringArg(int i) const
0075 {
0076 return m_strarg[i];
0077 }
0078 cf::code Type() const
0079 {
0080 return m_type;
0081 }
0082 Color_Function * Next() {
0083 return p_next;
0084 }
0085 void Conjugate()
0086 {
0087 if (Type()!=cf::T) return;
0088
0089 int help = m_partarg[1];
0090 m_partarg[1] = m_partarg[2];
0091 m_partarg[2] = help;
0092
0093 char help2 = m_strarg[1];
0094 m_strarg[1] = m_strarg[2];
0095 m_strarg[2] = help2;
0096 }
0097
0098 void Replace(int hit,int prop) {
0099 for (short int i=0;i<3;i++) {
0100 if ((Type()==cf::D || Type()==cf::G) && i==2) break;
0101 if (ParticleArg(i)==hit) m_partarg[i] = prop;
0102 }
0103 }
0104 void Replace(int hit,char repl) {
0105 for (short int j=0;j<3;j++) {
0106 if ((Type()==cf::D || Type()==cf::G) && j==2) break;
0107 if (ParticleArg(j)==hit) m_strarg[j] = repl;
0108 }
0109 }
0110 void Append(Color_Function * last)
0111 {
0112 Color_Function* help = this;
0113 while (help->p_next) help = help->p_next;
0114 help->p_next = last;
0115 }
0116 Color_Function * Erase(Color_Function * granny)
0117 {
0118 Color_Function * mo = p_next;
0119 if (granny) granny->p_next=mo;
0120 p_next=0;
0121 delete this;
0122 return mo;
0123 }
0124
0125 std::string String() const;
0126 std::string PID() const;
0127 std::string FullString() const;
0128 };
0129
0130 std::ostream &operator<<(std::ostream &str,const Color_Function &cf);
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240
0241
0242
0243 }
0244 #endif