convar.h

Go to the documentation of this file.
00001 
00048 #ifndef ABA_CONVAR_H
00049 #define ABA_CONVAR_H
00050 
00051 #include "abacus/abacusroot.h"
00052 
00053 #include <iostream>
00054 using namespace std;
00055 
00056 class ABA_MASTER;
00057 class ABA_SUB;
00058 class ABA_VARIABLE;
00059 class ABA_CONSTRAINT;
00060 // class ostream;
00061 
00062 template<class BaseType, class CoType> class ABA_POOLSLOT;
00063 template<class BaseType, class CoType> class ABA_POOLSLOTREF;
00064 template<class BaseType, class CoType> class ABA_STANDARDPOOL;
00065 template<class BaseType, class CoType> class ABA_CUTBUFFER;
00066 
00067 #ifdef ABACUS_PARALLEL
00068 #include "abacus/id.h"
00069 
00070 class ABA_MESSAGE;
00071 
00072 #define NUMCON_CLASSID  8001            // preliminary
00073 #define ROWCON_CLASSID  8002            // preliminary
00074 #define SROWCON_CLASSID 8003            // preliminary
00075 #define NUMVAR_CLASSID  8004            // preliminary
00076 #define COLVAR_CLASSID  8005            // preliminary
00077 #endif
00078 
00079 class  ABA_CONVAR : public ABA_ABACUSROOT  {
00080   friend class ABA_POOLSLOT<ABA_CONSTRAINT, ABA_VARIABLE>;
00081   friend class ABA_POOLSLOT<ABA_VARIABLE, ABA_CONSTRAINT>;
00082   friend class ABA_POOLSLOTREF<ABA_CONSTRAINT, ABA_VARIABLE>;
00083   friend class ABA_POOLSLOTREF<ABA_VARIABLE, ABA_CONSTRAINT>;
00084   friend class ABA_STANDARDPOOL<ABA_CONSTRAINT, ABA_VARIABLE>;
00085   friend class ABA_STANDARDPOOL<ABA_VARIABLE, ABA_CONSTRAINT>;
00086   friend class ABA_CUTBUFFER<ABA_CONSTRAINT, ABA_VARIABLE>;
00087   friend class ABA_CUTBUFFER<ABA_VARIABLE, ABA_CONSTRAINT>;
00088   friend class ABA_SUB;
00089   public:
00090 
00103     ABA_CONVAR (ABA_MASTER *master, const ABA_SUB *sub, bool dynamic, bool local);
00104 
00107     virtual ~ABA_CONVAR();
00108 #ifdef ABACUS_PARALLEL
00109 
00121     ABA_CONVAR (ABA_MASTER *master, ABA_MESSAGE &msg);
00122 
00138     virtual void pack(ABA_MESSAGE &msg) const;
00139     virtual int classId() const = 0;
00140 #endif
00141 
00153     bool active() const;
00154 
00158     bool local() const;
00159 
00163     bool global() const;
00164 
00170     virtual bool dynamic() const;
00171 
00191     bool expanded() const;
00192 
00198     void _expand();
00199 
00200 
00206     void _compress();
00207 
00221     virtual void print(ostream &out);
00223 
00228     const ABA_SUB *sub() const;
00229 
00235     void sub(ABA_SUB *sub);
00236 
00263     virtual unsigned hashKey();
00264 
00291     virtual const char *name();
00292 
00321     virtual bool equal(ABA_CONVAR *cv);
00322 
00328     virtual double rank();
00329   protected:
00330 
00333     ABA_MASTER *master_;
00334 
00338     const ABA_SUB *sub_;
00339 
00342     bool expanded_;
00343 
00347     int nReferences_;
00348 
00356     bool dynamic_;
00357 
00368     int nActive_;
00369 
00372     int nLocks_;
00373 
00377     bool local_;
00378 #ifdef ABACUS_PARALLEL
00379     ABA_ID identification_;
00380 #endif
00381 
00382   private:
00383 
00390     void activate();
00391 
00397     void deactivate();
00398 
00405     int nReferences() const;
00406 
00414     void addReference();
00415 
00422     void removeReference();
00423 
00436     bool locked() const;
00437 
00440     void lock();
00441 
00444     void unlock();
00446 
00454     virtual bool deletable() const;
00455 
00459     virtual void expand();
00460 
00464     virtual void compress();
00465 };
00466 
00467 inline bool ABA_CONVAR::active() const
00468   {
00469     if (nActive_) return true;
00470     else          return false;
00471   }
00472 
00473 inline void ABA_CONVAR::activate()
00474   {
00475     ++nActive_;
00476   }
00477 
00478 inline int ABA_CONVAR::nReferences() const
00479   {
00480     return nReferences_;
00481   }
00482 
00483 inline void ABA_CONVAR::addReference()
00484   {
00485     ++nReferences_;
00486   }
00487 
00488 inline bool ABA_CONVAR::locked() const
00489   {
00490     if (nLocks_) return true;
00491     else         return false;
00492   }
00493 
00494 inline void ABA_CONVAR::lock()
00495   {
00496     ++nLocks_;
00497   }
00498 
00499 inline bool ABA_CONVAR::local() const
00500   {
00501     return local_;
00502   }
00503 
00504 inline bool ABA_CONVAR::global() const
00505   {
00506 #ifdef ABACUS_NO_BOOL
00507     if (local_) return false;
00508     else        return true;
00509 #else
00510     return !local_;
00511 #endif
00512   }
00513 
00514 inline const ABA_SUB *ABA_CONVAR::sub() const
00515   {
00516     return sub_;
00517   }
00518 
00519 inline void ABA_CONVAR::sub(ABA_SUB *sub)
00520   {
00521     sub_ = sub;
00522   }
00523 
00524 inline bool ABA_CONVAR::expanded() const
00525   {
00526     return expanded_;
00527   }
00528 
00529 
00530 #endif  // !ABA_CONVAR_H
00531 

Generated on Tue Aug 14 18:09:53 2007 for ABACUS by  doxygen 1.5.1