123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- #pragma once
- #include "ReferenceCounter.h"
- namespace Framework
- {
- template<class A, class B> class Pair : public virtual ReferenceCounter
- {
- private:
- A* va;
- B* vb;
- public:
- Pair()
- : ReferenceCounter()
- {
- va = 0;
- vb = 0;
- }
- Pair(A* a, B* b)
- : ReferenceCounter()
- {
- va = a;
- vb = b;
- }
- ~Pair()
- {
- if (va) va->release();
- if (vb) vb->release();
- }
- A* getFirst()
- {
- return va ? dynamic_cast<A*>(va->getThis()) : 0;
- }
- A* zFirst()
- {
- return va;
- }
- B* getSecond()
- {
- return vb ? dynamic_cast<B*>(vb->getThis()) : 0;
- }
- B* zSecond()
- {
- return vb;
- }
- void setFirst(A* a)
- {
- if (va) va->release();
- va = a;
- }
- void setSecond(B* b)
- {
- if (vb) vb->release();
- vb = b;
- }
- };
- } // namespace Framework
|