1 /***************************************************************************
2                           quinegroup.h  -  description
3                              -------------------
4     begin                : Thu Oct 4 2001
5     copyright            : (C) 2001 by Dannel Albert
6     email                : dalbert@capitol-college.edu
7  ***************************************************************************/
8 
9 /***************************************************************************
10  *                                                                         *
11  *   This program is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU General Public License as published by  *
13  *   the Free Software Foundation; either version 2 of the License, or     *
14  *   (at your option) any later version.                                   *
15  *                                                                         *
16  ***************************************************************************/
17 
18 #ifndef _QUINEGROUP_H_
19 #define _QUINEGROUP_H_
20 
21 #include <iostream>
22 #include "globals.h"
23 #include "quinenode.h"
24 
25 class QuineGroup
26 {
27 private:
28   QuineGroup* next;
29   QuineGroup* prev;
30   QuineNode* head;
31   QuineNode* tail;
32   unsigned int numBits;
33   unsigned int numItems;
34   unum* diffBits;
35   unsigned int numDiffBits;
36   unsigned int primeImplicant;
37   unsigned int repeatCount;
38   bool hasCombined;
39 
40 public:
41   // CONSTRUCTOR / DESTRUCTOR
42   QuineGroup(unsigned int nb, QuineGroup* n=NULL, QuineGroup* p=NULL);
43   ~QuineGroup();
44 
45   // ACCESSORS
Size()46   unsigned int Size() const { return numItems; }
47   unum* GetDiffBits(unsigned int& numElements) const;
GetNext()48   QuineGroup* GetNext() const { return next; }
GetPrev()49   QuineGroup* GetPrev() const { return prev; }
PrimeImplicant()50   unsigned int PrimeImplicant() const { return primeImplicant; }
HasCombined()51   bool HasCombined() const { return hasCombined; }
GetRepeatCount()52   unsigned int GetRepeatCount() const { return repeatCount; }
GetNumBits()53   unsigned int GetNumBits() const { return numBits; }
54 
55   // MODIFIERS
SetNext(QuineGroup * n)56   void SetNext(QuineGroup* n) { next = n; }
SetPrev(QuineGroup * p)57   void SetPrev(QuineGroup* p) { prev = p; }
SetPrimeImplicant(unsigned int pi)58   void SetPrimeImplicant(unsigned int pi) { primeImplicant = pi; }
SetHasCombined(bool hc)59   void SetHasCombined(bool hc) { hasCombined = hc; }
SetRepeatCount(unsigned int rc)60   void SetRepeatCount(unsigned int rc) { repeatCount = rc; }
SetNumBits(unsigned int nBits)61   void SetNumBits(unsigned int nBits) { numBits = nBits; }
62 
63   void Insert(unum value);
64   bool CalculateDiffBits();
65   unum ValueAt(unsigned int index) const;
66 
67   friend std::ostream& operator<<(std::ostream& outs, const QuineGroup& qg);
68 
69 private:
70   QuineNode* FindGreaterThan(unum n);
71 };
72 
73 std::ostream& operator<<(std::ostream& outs, const QuineGroup& qg);
74 
75 #endif