summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/prdf/framework/config/iipDomainContainer.C
blob: e952ce00d436219a7b994dff0ac8aac9f98e8aa1 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/prdf/framework/config/iipDomainContainer.C $     */
/*                                                                        */
/* IBM CONFIDENTIAL                                                       */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 1996,2012              */
/*                                                                        */
/* 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                                                     */

// Module Description **************************************************
//
// Description: This module provides the implementation for the PRD
//              DomainContainer class.
//
// End Module Description **********************************************

//----------------------------------------------------------------------
//  Includes
//----------------------------------------------------------------------

#include <iipServiceDataCollector.h>
#include <prdfErrorSignature.H>
#include <iipDomainContainer.h>

#include <prdfRuleChip.H>
#include <prdfPluginDef.H>
#include <prdfPlatServices.H>
#include <algorithm>

//----------------------------------------------------------------------
//  User Types
//----------------------------------------------------------------------

//----------------------------------------------------------------------
//  Constants
//----------------------------------------------------------------------

//----------------------------------------------------------------------
//  Macros
//----------------------------------------------------------------------

//----------------------------------------------------------------------
//  Internal Function Prototypes
//----------------------------------------------------------------------

//----------------------------------------------------------------------
//  Global Variables
//----------------------------------------------------------------------

//---------------------------------------------------------------------
// Member Function Specifications
//---------------------------------------------------------------------

// @jl02 a Start
// This is used with the CHIP_CLASS vectors to remove one that matches a chipID
// Predicate function for comparing chip IDs.  This is required by remove_if from STL.
// TODO:FIXME: Add compiler directives or some method to make sure the type handling here
// is generic enough or correct enough to handle future use of this functionality.
class prdfCompareChipIds: public std::unary_function<void*&, bool>
{
  public:
    //Constructor allows a value to be passed in to compare against.
    inline prdfCompareChipIds(TARGETING::TargetHandle_t cid) : __cid(cid) {};
    //This operator is the one I'd like to call straight.  But, because of the void ptr type
    // I cannot call it directly.  C++ won't allow it because of "strong typing" rules.
    inline bool operator() (CHIP_CLASS& i)
    {
       return (__cid == i.GetChipHandle());
    };
    //Really fancy caste for the benefit of the compiler.
    inline bool operator() (void*& i)
    {
        //Anonymous Union for calling void ptr a CHIP_CLASS.
        union {CHIP_CLASS* c; void* v;} cptr;
        //assign value passed in to it's void ptr type.
        cptr.v = i;
        //pass CHIP_CLASS type to inline overloaded operator above.
        return this->operator()(*cptr.c);
    };
  private:
    //Private storage for value passed in.
    TARGETING::TargetHandle_t __cid;
};
// @jl02 a Stop

template<class T>
inline
DomainContainer<T>::DomainContainer(DOMAIN_ID domainId, unsigned int size) :
Domain(domainId),
chips()  // dg04 - remove size from arg list
{
  chips.reserve(size); // dg04
}

template<class T>
inline
bool DomainContainer<T>::Query(ATTENTION_TYPE attentionType)     // DG03
{
  bool rc = false;

  SYSTEM_DEBUG_CLASS sysdebug;
  unsigned int size = GetSize();
  for(unsigned int i = 0;(i < size) && (rc == false);i++)
  {
    TARGETING::TargetHandle_t l_pchipHandle = LookUp(i)->GetChipHandle();
    if(sysdebug.IsAttentionActive(l_pchipHandle) == true)
    {
      if(sysdebug.GetAttentionType(l_pchipHandle) == attentionType) rc = true;
    }
  }

  return(rc);
}

template<class T>
inline
int32_t DomainContainer<T>::Analyze(STEP_CODE_DATA_STRUCT & serviceData,
                                    ATTENTION_TYPE attentionType)
{
  serviceData.service_data->GetErrorSignature()->clear();
  Order(attentionType);                    // DG01 DG02
  return(LookUp(0)->Analyze(serviceData, attentionType));
}

template<class T>
inline
void DomainContainer<T>::Swap(unsigned int index1, unsigned int index2)
{
  void * ptr = chips[index1];
  chips[index1] = chips[index2];
  chips[index2] = ptr;
}

template<class T> // pw01 - Added function.
inline
void DomainContainer<T>::MoveToFront(unsigned int index)
{
    for (unsigned int i = index; i > 0; i--)
    {
        Swap(i, i-1);
    }
}

template<class T>
inline
void DomainContainer<T>::Remove(TARGETING::TargetHandle_t i_pChipHandle)
{
    // erase and remove_if functions are from the STL and require begin end and predicate functions to work.
    // This will iterate thru the vectors and remove any vectors with chip ID that matches the i_chip.
    chips.erase(std::remove_if(chips.begin(), chips.end(), prdfCompareChipIds(i_pChipHandle)), chips.end());
}
OpenPOWER on IntegriCloud