class ComProperty

all COM property classes must be drived from base class IProperty. In order to use the existed property classes, class ComProperty derives from IProperty and property class.
                     Property
                        |
      IProperty   Property calss
          |             |
          ---------------
                 |
            ComProperty
ComProperty use property class as a template parameter.
template <class Tp>
class ComProperty : public IProperty, private Tp
{
...
because exception can not come out of a COM method, so exceptions in property classes must be catched in ComProperty and transfered to error code.
        virtual HRESULT STDMETHODCALLTYPE get_rho(value_type __RPC_FAR *val) {
		try {							
			(*val) = Tp::get_rho();			
		} catch(PropertyNotImplement&) {			
			return E_NOTIMPL;				
		} catch(...) {						
			return E_FAIL;					
		}							
		return S_OK;						
	}
then it is easy to get a COM property class from property class.
	typedef ComProperty<water_steam<double> > com_water_steam;

[code][home]


allan xu, 2002-10-18