- xmlfoundationsrc.zip
- XMLFoundation
- Bin
- Errors
- english
- Examples
- c++
- ExATLCOM
- ExCORBA
- ExIndexObjects
- ExObjsFromXML
- Docs
- DynamicObjectsfromXML.html
- ExATLCOM.html
- ExCORBA.html
- Images
- ArrowLeft.gif
- ArrowRight.gif
- ExATLC1.gif
- ExATLC2.gif
- ExATLC3.gif
- gears.gif
- Index.6.gif
- objects.jpg
- ObjFromXML1.jpg
- ObjFromXML10.jpg
- ObjFromXML11.jpg
- ObjFromXML12.jpg
- ObjFromXML13.jpg
- ObjFromXML14.jpg
- ObjFromXML2.jpg
- ObjFromXML3.jpg
- ObjFromXML4.jpg
- ObjFromXML5.jpg
- ObjFromXML6.jpg
- ObjFromXML7.jpg
- ObjFromXML8.jpg
- ObjFromXML9.jpg
- SourceXML.jpg
- vssver.scc
- Java
- ExXMLObjects
- Library
- Build
- makefile.linux
- makefile.sun
- XMLFoundationLib.dsp
- XMLFoundationLib.plg
- inc
- src
- ReadMe.txt
- Tools
- JavaFoundation
- VCppUseThis.dsw
- VCppUseThis.opt
|
// --------------------------------------------------------------------------
// www.UnitedBusinessTechnologies.com
// Copyright (c) 1998 - 2002 All Rights Reserved.
//
// Source in this file is released to the public under the following license:
// --------------------------------------------------------------------------
// This toolkit may be used free of charge for any purpose including corporate
// and academic use. For profit, and Non-Profit uses are permitted.
//
// This source code and any work derived from this source code must retain
// this copyright at the top of each source file.
//
// UBT welcomes any suggestions, improvements or new platform ports.
// email to: XMLFoundation@UnitedBusinessTechnologies.com
// --------------------------------------------------------------------------
#include "MemberDescriptor.h"
#include "FactoryManager.h"
#include "FrameworkAuditLog.h"
#include "xmlObject.h"
#include "GProfile.h"
#include <stdio.h> // for: sprintf()
#include <string.h> // for: strlen() strcpy()
#ifdef _WIN32
#define strcasecmp stricmp
#endif
int XMLObjectFactoryManager::m_UIDCounter = 0;
XMLObjectFactoryManager::XMLObjectFactoryManager()
{
}
XMLObjectFactoryManager::~XMLObjectFactoryManager()
{
GListIterator Iter(&m_factoryList);
while (Iter())
{
MemberDescriptor *p = (MemberDescriptor *)Iter++;
delete[] (char *)((p->m_Member).pClassName);
delete p;
}
}
//*********************************************************
// Description:
// called by macro REG_FACTORY to register this object and it's factory
//
// Preconditions:
// .
//
// Postconditions:
// .
//
//*********************************************************
void XMLObjectFactoryManager::Add( ObjectFactory pFactory, const char * szTag, const char * szClassName)
{
MemberDescriptor *pMD = GetRootableMapEntry(szTag);
if ( pMD )
{
char szTemp[128];
sprintf(szTemp, "Object <%s> and <%s> both map to tag <%s>. <%s> takes precesedence.",
(const char *)pMD->m_Member.pClassName, szClassName, szTag, (const char *)pMD->m_Member.pClassName);
if ( GetProfile().GetBool("Debug", "MultiMapWarnings", false))
{
TRACE_WARNING(szTemp);
}
}
else
{
char *pHeapedClassName = new char[strlen(szClassName) + 1];
strcpy(pHeapedClassName,szClassName);
m_factoryList.AddLast(new MemberDescriptor(0, szTag,pFactory,pHeapedClassName));
}
}
// called by macro IMP_BOL_RELATION to register this interface
void XMLObjectFactoryManager::Add(
IFaceFactory Iff,
ObjectFactory Of,
const char *iFaceClassName ,
const char *BusObjClassName)
{
structIFaceCreate *sIFC = new structIFaceCreate();
sIFC->Iff = Iff;
sIFC->Of = Of;
sIFC->strBusObjClassName = BusObjClassName;
sIFC->strIFaceObjClassName = iFaceClassName;
m_IFacefactoryList.AddLast(sIFC);
}
XMLObjectFactoryManager::structIFaceCreate *XMLObjectFactoryManager::FindIFaceInfo( const char *pzBOLClassName )
{
GListIterator Iter (&m_IFacefactoryList);
while (Iter())
{
structIFaceCreate *pIFC = (structIFaceCreate *)Iter++;
if( strcmp(pzBOLClassName,(const char *)pIFC->strBusObjClassName) == 0 )
{
// we found a match
return pIFC;
}
}
return 0;// no match
}
//*********************************************************
// Description:
// Check all the objects registered with REG_FACTORY using tag name as search key
//
// Preconditions:
// .
//
// Postconditions:
// .
//
//*********************************************************
MemberDescriptor *XMLObjectFactoryManager::GetRootableMapEntry(const char * pzTag)
{
GListIterator Iter (&m_factoryList);
while (Iter())
{
MemberDescriptor *pRootable = (MemberDescriptor *)Iter++;
if( strcasecmp((const char *)pRootable->strTagName, pzTag) == 0 )
{
// we found a match
return pRootable;
}
}
return 0;/*No Root element matches pzTag*/
}
ObjectFactory XMLObjectFactoryManager::GetFactory(const char * pzTag)
{
GListIterator Iter (&m_factoryList);
while (Iter())
{
MemberDescriptor *pRootable = (MemberDescriptor *)Iter++;
if( strcasecmp((const char *)pRootable->strTagName, pzTag) == 0 )
{
// we found a match
return pRootable->m_pfnFactoryCreate;
}
}
return 0;/*No Root element matches pzTag*/
}
const char *XMLObjectFactoryManager::GetSDKClassName(const char * pzTag)
{
GListIterator Iter (&m_factoryList);
while (Iter())
{
MemberDescriptor *pRootable = (MemberDescriptor *)Iter++;
if( strcasecmp((const char *)pRootable->strTagName, pzTag) == 0 )
{
// we found a match
return pRootable->m_Member.pClassName;
}
}
return 0;/*No Root element matches pzTag*/
}
//*********************************************************
// Description:
// Check all the objects registered with REG_FACTORY
// using factory function as search key
//
// Preconditions:
// .
//
// Postconditions:
// .
//
//*********************************************************
MemberDescriptor *XMLObjectFactoryManager::GetRootableMapEntry(ObjectFactory pFn)
{
GListIterator Iter (&m_factoryList);
while (Iter())
{
MemberDescriptor *pRootable = (MemberDescriptor *)Iter++;
if(pRootable->m_pfnFactoryCreate == pFn)
{
// we found a match
return pRootable;
}
}
return 0;/*No Root element matches pFn*/
}
const char *XMLObjectFactoryManager::GetTag(ObjectFactory pFn)
{
GListIterator Iter (&m_factoryList);
while (Iter())
{
MemberDescriptor *pRootable = (MemberDescriptor *)Iter++;
if(pRootable->m_pfnFactoryCreate == pFn)
{
// we found a match
return (const char *)pRootable->strTagName;
}
}
return 0;/*No Root element matches pFn*/
}
RegisterBusinessObject::RegisterBusinessObject( ObjectFactory Of,
const char * szXMLTagIdentifier,
const char * szBusObjClassName)
{
XMLObjectFactoryManager &r = XMLObjectFactoryManager::getFactoryManager();
r.Add( Of, szXMLTagIdentifier, szBusObjClassName);
}
RegisterInterface::RegisterInterface( IFaceFactory If,
ObjectFactory Of,
const char * szIFaceClassName,
const char * szBusObjClassName)
{
XMLObjectFactoryManager &r = XMLObjectFactoryManager::getFactoryManager();
r.Add( If,
Of,
szIFaceClassName,
szBusObjClassName);
}
XMLObjectFactoryManager &XMLObjectFactoryManager::getFactoryManager()
{
static XMLObjectFactoryManager factoryManager;
return factoryManager;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here