summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/prdf/common/framework/config/iipDomainContainer.h
blob: 88917bb2ecdf4e4237211c306967aa5f6c76b16e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/prdf/common/framework/config/iipDomainContainer.h $ */
/*                                                                        */
/* IBM CONFIDENTIAL                                                       */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 1996,2013              */
/*                                                                        */
/* p1                                                                     */
/*                                                                        */
/* Object Code Only (OCO) source materials                                */
/* Licensed Internal Code Source Materials                                */
/* IBM HostBoot Licensed Internal Code                                    */
/*                                                                        */
/* The source code for this program is not published or otherwise         */
/* divested of its trade secrets, irrespective of what has been           */
/* deposited with the U.S. Copyright Office.                              */
/*                                                                        */
/* Origin: 30                                                             */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */

#ifndef iipDomainContainer_h
#define iipDomainContainer_h

#ifndef iipDomain_h
#include <iipDomain.h>
#endif

#include <vector>

namespace PRDF
{

// Forward References
struct STEP_CODE_DATA_STRUCT;

/**
 Template class that Define a domain that contain other objects - typically
 chips.
 @par
 Contained objects must have interface like CHIP_CLASS see iipchip.h
 @note Parent class: Domain
 @par Usage Examples:
 @code

  // Create a Domain derived class holding chips of a specific type
  class MyChip: public CHIP_CLASS {....};

  class MyDomain : public DomainContainer<MyChip *>
  {
    MyDomain(DOMAIN_ID domainId);

    // Need to implement pure virtual functions
    virtual SINT32 Order(void); // put chip to analyze at top of list
  };

  void foo(MyChip * chipPtr)
  {
    MyDomain myDomain(ID, 10);    // Need to hold about 10 chips

    myDomain.AddChip(chipPtr);    // Add chip to list of chips
    //   ....

    if(myDomain.LookUp(0) == chipPtr)   // lookup first chip
    {
      // LookUp successfully returned pointer to the chip
    }
  }

  void f(Domain & myDomain,
         STEP_CODE_DATA_STRUCT & sevice_data,
         ATTENTION_TYPE system_attention_type)
  {
    if(myDomain->Query())  // if has attention
    {
      myDomain->Analyze(service_data, system_attention_type);
    }
  }
  @endcode
*/
template <class T>
class DomainContainer : public Domain
{
public:

  /**
   Constructor
   <ul>
   <br><b>Parameter:   </b> domainId: Identifies the Domain (See iipconst.h)
   <br><b>Parameter:   </b> size: Estimate of max number of chips in domain
   <br><b>Returns:     </b> None.
   <br><b>Requirements:</b> None.
   <br><b>Promises:    </b> Object created
   <br><b>Exceptions:  </b> None.
   <br><b>Notes:       </b>
   </ul><br>
   */
  DomainContainer(DOMAIN_ID domainId, unsigned int size = 5);

  // Function Specification ********************************************
  //
  // Purpose:      Copy
  // Parameters:   c: Reference to instance to copy
  // Returns:      No value returned.
  // Requirements: None.
  // Promises:     All data members will be copied (Deep copy).
  // Exceptions:   None.
  // Concurrency:  N/A.
  // Notes:  This constructor is not declared.  This compiler generated
  //         default definition is sufficient.
  //
  // End Function Specification ****************************************
  //  DomainContainer(const DomainContainer<T> & c);

  // Function Specification ********************************************
  //
  // Purpose:      Destruction
  // Parameters:   None.
  // Returns:      No value returned
  // Requirements: None.
  // Promises:     None.
  // Exceptions:   None.
  // Concurrency:  Reentrant
  // Notes:  This destructor is not declared.  This compiler generated
  //         default definition is sufficient.
  //
  // End Function Specification ****************************************
  // virtual ~DomainContainer(void);

  // Function Specification ********************************************
  //
  // Purpose:      Assigment
  // Parameters:   c: Reference to instance to assign from
  // Returns:      Reference to this instance
  // Requirements: None.
  // Promises:     All data members are assigned to
  // Exceptions:   None.
  // Concurrency:  N/A.
  // Notes:  This assingment operator is not declared.  The compiler
  //         generated default definition is sufficient.
  //
  // End Function Specification ****************************************
  //  DomainContainer<T> & operator=(const DomainContainer<T> & c);

  /**
   Add a chip to this domain
   <ul>
   <br><b>Parameters:  </b> Pointer to a chip instance
   <br><b>Returns:     </b> None.
   <br><b>Requirements:</b> None.
   <br><b>Promises:    </b> GetSize()++
   <br><b>Exceptions:  </b> None.
   </ul><br>
   */
  void AddChip(T * chipPtr);

  /**
   Query domain for attention
   <ul>
   <br><b>Parameters:  </b> attentionType
   <br><b>Returns:     </b> true if 1 or more chips within the domain have
   the attention type specified otherwise false
   <br><b>Requirements:</b> GetSize() > 0, Initialize()
   <br><b>Promises:    </b> None.
   <br><b>Exceptions:  </b> None.
   </ul><br>
   */
  virtual bool Query(ATTENTION_TYPE attentionType);


  /**
   Determin which chip to Analyze and call it's Analyze() function
   <ul>
   <br><b>Parameter:   </b> serviceData (See iipServiceDataCollector.h)
   <br><b>Parameter:   </b> attentionType [MACHINE_CHECK|RECOVERED|SPECIAL]
   <br><b>Returns:     </b> return code (0 == SUCCESS)
   <br><b>Requirements:</b> Query() == true, Initialize()
   <br><b>Promises:    </b> serviceData complete
   <br><b>Exceptions:  </b> None.
   <br><b>Notes:       </b> This implementation calls Order() to determin
   which chip to analyze and calls that chips
   Analyze() function.
   </ul><br>
   */
  virtual int32_t Analyze(STEP_CODE_DATA_STRUCT & serviceData,ATTENTION_TYPE attentionType);

  /**
   Returns a pointer to the chip at the specified index
   <ul>
   <br><b>Parameters:  </b> chipIndex
   <br><b>Returns:     </b> pointer to a Chip of type T | NULL
   <br><b>Requirements:</b> AddChip(), 0 <= chipIndex < GetSize()
   <br><b>Promises:    </b> None.
   <br><b>Exceptions:  </b> None.
   <br><b>Notes:       </b> NULL is return if chipIndex is out of range
   </ul><br>
   */
  const T * LookUp(unsigned int chipIndex) const;
  T * LookUp(unsigned int chipIndex);

  /**
   Return the number of chips in the domain
   <ul>
   <br><b>Parameters:  </b> None.
   <br><b>Returns:     </b> number of chips in the domain
   <br><b>Requirements:</b> None.
   <br><b>Promises:    </b> None.
   <br><b>Exceptions:  </b> None.
   </ul><br>
   */
  uint32_t GetSize(void) const;

protected:


  /**
   Swaps the position of two chips in the chip list
   <ul>
   <br><b>Parameters:  </b> chip indexes of chips to swap
   <br><b>Returns:     </b> None.
   <br><b>Requirements:</b> indexes < GetSize(), & >= 0
   <br><b>Promises:    </b> chiplist order modified
   <br><b>Exceptions:  </b> None.
   </ul><br>
   */
  void Swap(unsigned int index1, unsigned int index2);

  /**
   * Moves the specified chip to the front of the list but preserves the
   * rest of the order.
   */
  void MoveToFront(unsigned int index); // pw01

// @jl02 a Start
  /**
   Removes a chip from the list inside of each Domain that contains it.
   It will leave the list at the system level for later deletion.
   <ul>
   <br><b>Parameters:  </b> chip identifier of chip to remove
   <br><b>Returns:     </b> None.
   <br><b>Requirements:</b> None.
   <br><b>Promises:    </b> None.
   <br><b>Exceptions:  </b> None.
   </ul><br>
   */
  void Remove(TARGETING::TargetHandle_t i_chip);

private:

  // void * is used to reduce template code bloat
  // the chip type T is restored whenever a reference to a chip
  // is requested
  typedef std::vector<void *>         ChipContainerType;

  ChipContainerType              chips;


};

} // end namespace PRDF

#include "iipDomainContainer.inl"

//#ifdef RS6000 -- changed for V4R1 Bali - 2/27/96 JFP
#ifndef __GNUC__
#include "iipDomainContainer.C"
#endif

#endif
OpenPOWER on IntegriCloud