AnimatLab  2
Test
TestClassFactory.cpp
1 // TestClassFactory.cpp: implementation of the TestClassFactory class.
2 //
4 
5 #include "stdafx.h"
6 #include "TestClassFactory.h"
7 #include "TestObject.h"
8 
9 
11 // Construction/Destruction
13 
14 TestClassFactory::TestClassFactory()
15 {
16 
17 }
18 
19 TestClassFactory::~TestClassFactory()
20 {
21 
22 }
23 
24 
25 // ************* IStdClassFactory functions ******************************
26 
27 CStdSerialize *TestClassFactory::CreateObject(std::string strClassType, std::string strObjectType, bool bThrowError)
28 {
29  CStdSerialize *lpObject=NULL;
30 
31  strClassType = Std_ToUpper(Std_Trim(strClassType));
32  strObjectType = Std_ToUpper(Std_Trim(strObjectType));
33 
34  if(strClassType == "TEST" && strObjectType == "TESTOBJECT")
35  {
36  lpObject = new TestObject;
37  return lpObject;
38  }
39 
40  lpObject = NULL;
41  if(bThrowError)
42  THROW_PARAM_ERROR(Std_Err_lInvalidClassType, Std_Err_strInvalidClassType, "ClassType", strClassType);
43 
44  return lpObject;
45 }
46 // ************* IStdClassFactory functions ******************************
47 
48 #ifdef _WINDOWS
49  extern "C" __declspec(dllexport) IStdClassFactory* __cdecl GetStdClassFactory()
50 #else
51  extern "C" IStdClassFactory *GetStdClassFactory()
52 #endif
53 {
54  IStdClassFactory *lpFactory = new TestClassFactory;
55  return lpFactory;
56 }
Standard class factory.
std::string Std_Trim(std::string strVal)
Trims a string.
virtual CStdSerialize * CreateObject(std::string strClassType, std::string strObjectType, bool bThrowError=true)
Creates an object of the specified class and object types.
Standard serialize class.
Definition: StdSerialize.h:20
std::string Std_ToUpper(std::string strVal)
Converts a string to upper case.