1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- #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;
- }
- };
- }
|