What is the best way to implement a custom class object using comet (i.e.
one that is not an implementation of IClassFactory)?
I'm trying to implement the IParseDisplayName interface which takes the
place of IClassFactory to return object instances by name. In other
words, this must be implemented by the class object rather than the
instances. What is the best to do this using comet?
I've tried the following code but I get an ambigious conversion error "
error C2594: 'return' : ambiguous conversions from
'coclass_implementation<RealDispenser> *' to 'IUnknown *' see
comet\server.h:1349". The comment above this line of server.h warns that
this might happen if the class factory implements more than one interface.
The one below does. Can we change the server.h code to use a proper
QueryInterface call?
Many thanks.
Alex
namespace comet {
/**
* A coclass variant that allows implementing from non-comet
* implementation classes.
*/
template<
typename T, typename U,
enum thread_model::thread_model_t TM = thread_model::Apartment,
COMET_LIST_TEMPLATE>
struct ATL_NO_VTABLE custom_coclass :
public impl::simple_object_aux<
typelist::append<
typename make_list<COMET_LIST_ARG_1>::result,
typename make_list<IProvideClassInfoImpl<T>
>::result > >
{
typedef custom_coclass coclass_type;
enum { factory_type = impl::ft_standard };
enum { thread_model = TM };
static const TCHAR* get_progid() { return 0; }
};
enum my_factory_type_t { ft_static = 10 };
namespace impl {
/**
* A factory builder that uses the class itself as the factory rather
* than a default implementation of IClassFactory.
*/
template<typename CLASS, bool LOCK_MODULE>
struct factory_builder_aux<ft_static, CLASS, LOCK_MODULE>
{
typedef CLASS is_factory;
};
} // namespace impl
} // namespace comet
template<>
class coclass_implementation<RealDispenser> :
public comet::custom_coclass<
RealDispenser, swish::provider::dispenser::CDispenser,
comet::thread_model::Both>
{
public:
enum { factory_type = ft_static };
};