// ABCSClassFactory.cpp: implementation of the ABCSClassFactory class. // ////////////////////////////////////////////////////////////////////// #include "ABCCommon.h" #include "ABCSClassFactory.h" #include "ABCBook.h" #include "ABCMagazine.h" ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// ABCSClassFactory::ABCSClassFactory() : m_pBook (NULL) { } ABCSClassFactory::~ABCSClassFactory() { } rtr_status_t ABCSClassFactory::CreateRTRApplicationMessage( rtr_const_msgbuf_t pmsgCallersData, rtr_msglen_t msglCallersDataLength, RTRApplicationMessage *&pApplicationMessage ) { /* Determine what kind of serialized object we are receiving. The ABC company protocol defines the first integer of the message to represents the type of the object we are receiving. Book = ABC_BOOK Magazine = ABC_MAGAZINE */ unsigned int uiClassType = *(unsigned int*)pmsgCallersData; switch (uiClassType) { case ABC_BOOK : pApplicationMessage = new ABCBook(); break; case ABC_MAGAZINE : pApplicationMessage = new ABCMagazine(); break; default: /* If we ever get here then the client is sending us data that we can't recognize. For some applications this may not be an issue. For the ABC company this should be impossible. */ assert(false); } /* Make sure we are passing back a valid address */ if (NULL == pApplicationMessage) return RTR_STS_INSVIRMEM; return ABCSuccess; }