Home » Community » Forums » » Creating a Generic Object Factory
  Intel sponsors gamedev.net search:   
[Control Panel] [Register] [Bookmarks] [Who's Online] [Active Topics] [Stats] [FAQ] [Search]

Add Forum to Favorites |  Send Topic To a Friend | View Forum FAQ | Track this topic

Page:   1 2 »»

 Last Thread Next Thread 
 Creating a Generic Object Factory
Post Reply 
It would be a good idea to refer to Design Patterns (GOF) and possibly Modern C++ Design (Andrei Alexandrescu) if that is where you have taken these ideas from.

 User Rating: 1015    Report this Post to a Moderator | Link

Very good article. I think it's good as an intro text to the topic though, so I would say it would be more appropriate to link to the other two articles at the end. They are more specific and hard to understand IMO, I would definatly advice a beginner to read this article first.

 User Rating: 1049   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

this might be a nice link too;
Industrial Strength Pluggable Factories


 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

quote:
Original post by Anonymous Poster
It would be a good idea to refer to Design Patterns (GOF) and possibly Modern C++ Design (Andrei Alexandrescu) if that is where you have taken these ideas from.

Actually, despiste the fact that my object factory implementation resembles the one from MC++D the idea was taken from Why Pluggable Factories Rock My Multiplayer World and subsequently Idustrial Strength Pluggable Factories, which I linked in the begining of my article.

It wasn't until my implementation was nearly feature complete that I saw Alexandrescu's implementation. Which is strange considering I've had that book for quite a while before I noticed that chapter.


- Houdini



 User Rating: 1111   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

A small suggestion would be to use string hashes instead of strings themselves. You get the same clean interface without all the memory and performance penalties.

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

quote:
Original post by Ecko
A small suggestion would be to use string hashes instead of strings themselves. You get the same clean interface without all the memory and performance penalties.

Well, strings are generally only used when you need to supply the unique identifier from an outside source, like a file or console. In these instances, the IO speed itself isn't exactly lightning fast, nor is instantiating objects for that matter, so I don't think it makes a big deal using normal strings.

You could of course use a hash map instead of std::map internally to speed things up, but hash maps are not part of the standard thus are nor portable.

For performance critical code, using integers as the unique identifier is the way to go.


- Houdini

 User Rating: 1111   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

One semi-unrelated issue that I thought needed some attention (i.e. a sentence or two) was memory management - the client creating objects with the factory is responsible for cleaning them up, i.e. delete'ing them. Otherwise, you could have some bad memory leaks if you called object_factory.Create(foo) too freely.

 User Rating: 1181   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

I am probably going to look like an idiot by asking this, but why are these pluggable factories necessary. After skimming through the article and looking at the sample code I realised that Example 1 can be reproduced with the following few lines of code:

Monster *monster1 = new OgreMonster(83.0f, 14.2f, 54.4f);
Monster *monster2 = new GoblinMonster(34.5f, 63.0f, 7.7f);
delete monster1;
delete monster2;

It basically does exactly the same thing as far as I can tell. So what is the whole pluggable factory needed for? It's not like the sample application doesn't know about the two derived monster classes. If it didn't then the above four lines wouldn't compile. Isn't that supposed to be the whole purpose of pluggable factories? You know allowing you to create objects that the application doesn't know about.

I don't know anything about pluggable factories, but when I look at this example, it just seems like a lot of work for something that can be done with just four lines of code. Can anyone explain to me why they are necessary, perhaps with an example that cannot be reproduced in the above fashion?

P.S. Can anyone tell me how to put code inside that special code window thing?

 User Rating: 230   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Mods, when I click the discuss this article in the forums button in the Object Factory doc it won't redirect to here :/

(It links to:http://www.gamedev.net/community/forums/topic.asp?key=featart&uid=2097&forum_id=35&Topic_Title=Creating+a+Generic+Object+Factory)

Anyway, I really liked the object factory idea, but all the macroing to implement it(Neccesary for the multiple parameters, right?) should be unneccesary.

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

The need for pluggable factories is quite easy to understand with an example:

you're developing a game engine that will be used for multiple games, each in a different genre but they all contain 'monsters' i.e. classes derived from a base class. So first off you don't want to make any explicit mention of OgreMonster in your engine as it won't be used by every game. Solution: pluggable factory. You simply describe in your level file that you want a Monster of type "ogre", so to instantiate an OgreMonster you call the factory with "ogre" and it returns a pointer to the base class Monster, but it is actually a OgreMonster.

Example 1 is simply designed really to show how the factory is used, of course it could be done simpler, but expanding the system to use 100 monsters would be tedious to say the least.

 User Rating: 1263   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

quote:
Original post by sandy
I am probably going to look like an idiot by asking this, but why are these pluggable factories necessary. After skimming through the article and looking at the sample code I realised that Example 1 can be reproduced with the following few lines of code:

Monster *monster1 = new OgreMonster(83.0f, 14.2f, 54.4f);
Monster *monster2 = new GoblinMonster(34.5f, 63.0f, 7.7f);
delete monster1;
delete monster2;

It basically does exactly the same thing as far as I can tell. So what is the whole pluggable factory needed for? It's not like the sample application doesn't know about the two derived monster classes. If it didn't then the above four lines wouldn't compile. Isn't that supposed to be the whole purpose of pluggable factories? You know allowing you to create objects that the application doesn't know about.

I don't know anything about pluggable factories, but when I look at this example, it just seems like a lot of work for something that can be done with just four lines of code. Can anyone explain to me why they are necessary, perhaps with an example that cannot be reproduced in the above fashion?

Yes, as jamessharpe pointed out, the object factory is perfect to specify in your maps to create monsters/items as specific locations.

Example 2 gives a very primitive (but very easy to code) example of the popular 'Quake Console'. It could also be useful for debugging you game. Say if you are in the game and want to test your ogre monster you could type in the console "create_ogre 83.0f, 14.2f, 54.4f" and it would dynamically create the ogre at those coordinates.

quote:
Original post by Nerusai
Anyway, I really liked the object factory idea, but all the macroing to implement it(Neccesary for the multiple parameters, right?) should be unneccesary.

Well, it's not technically neccesary . You could rewrite and almost exact duplicate (each with extra parameters) 15 times and not use marcros at all. But then if you make a bug fix or implement a new feature you'll need to make changes to ALL variations which can lead to hidden bugs.

Of course, it's possible to get rid of the entire class macro by using something similar to the boost proprocessor library. Using this, you could also just write one class and use the preprocessor library to automatically expand the function parameters to the correct size. You'd still be using macros, of course, but it's better than the large class macro in my example.

My original version of the object_factory used the boost preprocessor library, but I didn't want my example files dependant on boost or any other 3rd party library.

Anyways, as a user of the class you don't need to mess with the macro at all, it's all done behind scenes, which is nice. I personally can't stand having to use macros in my code to use classes, as some object factory implementations require.


- Houdini



 User Rating: 1111   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

quote:
Original post by Nerusai
Mods, when I click the discuss this article in the forums button in the Object Factory doc it won't redirect to here :/

(It links to:http://www.gamedev.net/community/forums/topic.asp?key=featart&uid=2097&forum_id=35&Topic_Title=Creating+a+Generic+Object+Factory)

I'm unable to duplicate this problem. It's working correctly for me, in both versions of the article. The above link should be correct for this thread.

 User Rating: 2088   |  Rate This User  Send Private MessageView ProfileView Journal Report this Post to a Moderator | Link

quote:

Example 2 gives a very primitive (but very easy to code) example of the popular 'Quake Console'. It could also be useful for debugging you game. Say if you are in the game and want to test your ogre monster you could type in the console "create_ogre 83.0f, 14.2f, 54.4f" and it would dynamically create the ogre at those coordinates.



I still think that using a pluggable factory is an overkill, even in this example too.

When the user enters the "create_ogre" command, the internal code is obviously going to have to check the command to see which class the object factory needs to create. In other words it would do something like this (semi-pseudo code), right?

Monster *monster;
if "create_ogre" then
   monster = objectFactory.Create( MONSTER_OGRE, 83.0f, 14.2f, 54.4f );
if "create_goblin" then
   monster = objectFactory.Create( MONSTER_GOBLIN, 83.0f, 14.2f, 54.4f );


However, this same functionality can be achieved with just:

Monster *monster;
if "create_ogre" then
   monster = new MonsterOgre( 83.0f, 14.2f, 54.4f );
if "create_goblin" then
   monster = new MonsterGoblin( 83.0f, 14.2f, 54.4f );


 User Rating: 230   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

@sandy:

Sure your code does the same as the object factory. But with an object factory you can add very quick new types of classes. So you dont need to make deeper changes in the source.

E.g.:

ObjectFactory<Shape> shape_factory;

shape_factory.Register(TRIANGLE, &CreateObject<Shape, Triangle>);
shape_factory.Register(SQUARE, &CreateObject<Shape, Square>);


I would recommend you to read the article again.

I will use an object factory for resource managment.

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Well... create_ogre doesn't seem to me like a typpical console command.

Let's call the command just "create" and it would look very different.

>create "ogre" 1.4 3.5 8.5 .....

void cmd_create()
{
foo = Factory.Create(par[1]);
foo.SetPosition(...);
}

Also, with pluggable factories you could write addons for your game, like a .dll with ne weapon or monster types in it without rewriting the whole code, but just by declaring new Class IDs and putting them in the map files.

--::[Madhed]::--

 User Rating: 1151   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

A nice improvement would be support for intel compiler. A friend of me is using it and he gets some errors when compiling:

--------------------Konfiguration: ObjectFactory - Win32 Release--------------------
Kompilierung läuft...
main.cpp
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): warning #54: too few arguments in macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): error: expected a ")"
  MACRO_REPEAT(16, OBJECT_FACTORY)
                                  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): error: improperly terminated macro invocation
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): error: expected an identifier
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\ObjectFactory.h(152): error: expected a ";"
  MACRO_REPEAT(16, OBJECT_FACTORY)
  ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\errno.h(118): error: expected a declaration
  }
  ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(37): error: reverse_iterator is not a template
   typedef reverse_iterator<iterator, value_type,
           ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(37): error: identifier "iterator" is undefined
   typedef reverse_iterator<iterator, value_type,
                            ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(37): error: identifier "value_type" is undefined
   typedef reverse_iterator<iterator, value_type,
                                      ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(38): error: identifier "reference" is undefined
    reference, pointer, difference_type>
    ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(38): error: identifier "pointer" is undefined
    reference, pointer, difference_type>
               ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(38): error: identifier "difference_type" is undefined
    reference, pointer, difference_type>
                        ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(40): error: "explicit" is not allowed
   explicit basic_string(const _A& _Al = _A())
   ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(40): error: identifier "_A" is undefined
   explicit basic_string(const _A& _Al = _A())
                               ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(40): error: identifier "_A" is undefined
   explicit basic_string(const _A& _Al = _A())
                                         ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(41): error: expected a "{"
    : allocator(_Al) {_Tidy(); }
    ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(41): error: identifier "_Tidy" is undefined
    : allocator(_Al) {_Tidy(); }
                      ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(42): error: identifier "_Myt" is undefined
   basic_string(const _Myt& _X)
                      ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(42): error: function "basic_string" has already been defined
   basic_string(const _Myt& _X)
   ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(43): error: expected a "{"
    : allocator(_X.allocator)
    ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(44): error: identifier "_Tidy" is undefined
    {_Tidy(), assign(_X, 0, npos); }
     ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(44): error: identifier "assign" is undefined
    {_Tidy(), assign(_X, 0, npos); }
              ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(44): error: identifier "npos" is undefined
    {_Tidy(), assign(_X, 0, npos); }
                            ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(45): error: identifier "_Myt" is undefined
   basic_string(const _Myt& _X, size_type _P, size_type _M,
                      ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(45): error: identifier "size_type" is undefined
   basic_string(const _Myt& _X, size_type _P, size_type _M,
                                ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(45): error: identifier "size_type" is undefined
   basic_string(const _Myt& _X, size_type _P, size_type _M,
                                              ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(46): error: identifier "_A" is undefined
    const _A& _Al = _A())
          ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(46): error: identifier "_A" is undefined
    const _A& _Al = _A())
                    ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(47): error: expected a "{"
    : allocator(_Al) {_Tidy(), assign(_X, _P, _M); }
    ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(47): error: identifier "_Tidy" is undefined
    : allocator(_Al) {_Tidy(), assign(_X, _P, _M); }
                      ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(47): error: identifier "assign" is undefined
    : allocator(_Al) {_Tidy(), assign(_X, _P, _M); }
                               ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(48): error: identifier "_E" is undefined
   basic_string(const _E *_S, size_type _N,
                      ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(48): error: identifier "size_type" is undefined
   basic_string(const _E *_S, size_type _N,
                              ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(49): error: identifier "_A" is undefined
    const _A& _Al = _A())
          ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(49): error: identifier "_A" is undefined
    const _A& _Al = _A())
                    ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(50): error: expected a "{"
    : allocator(_Al) {_Tidy(), assign(_S, _N); }
    ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(50): error: identifier "_Tidy" is undefined
    : allocator(_Al) {_Tidy(), assign(_S, _N); }
                      ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(50): error: identifier "assign" is undefined
    : allocator(_Al) {_Tidy(), assign(_S, _N); }
                               ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(51): error: identifier "_E" is undefined
   basic_string(const _E *_S, const _A& _Al = _A())
                      ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(51): error: identifier "_A" is undefined
   basic_string(const _E *_S, const _A& _Al = _A())
                                    ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(51): error: identifier "_A" is undefined
   basic_string(const _E *_S, const _A& _Al = _A())
                                              ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(52): error: expected a "{"
    : allocator(_Al) {_Tidy(), assign(_S); }
    ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(52): error: identifier "_Tidy" is undefined
    : allocator(_Al) {_Tidy(), assign(_S); }
                      ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(52): error: identifier "assign" is undefined
    : allocator(_Al) {_Tidy(), assign(_S); }
                               ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(53): error #77: this declaration has no storage class or type specifier
   basic_string(size_type _N, _E _C, const _A& _Al = _A())
   ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(53): error: declaration is incompatible with overloaded function "basic_string" (declared at line 40)
   basic_string(size_type _N, _E _C, const _A& _Al = _A())
   ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(53): error: identifier "size_type" is undefined
   basic_string(size_type _N, _E _C, const _A& _Al = _A())
                ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(53): error: expected a ")"
   basic_string(size_type _N, _E _C, const _A& _Al = _A())
                          ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(54): error: expected a ";"
    : allocator(_Al) {_Tidy(), assign(_N, _C); }
    ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(56): error #77: this declaration has no storage class or type specifier
   basic_string(_It _F, _It _L, const _A& _Al = _A())
   ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(56): error: variable "basic_string" has already been defined
   basic_string(_It _F, _It _L, const _A& _Al = _A())
   ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(56): error: identifier "_It" is undefined
   basic_string(_It _F, _It _L, const _A& _Al = _A())
                ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(56): error: expected a ")"
   basic_string(_It _F, _It _L, const _A& _Al = _A())
                    ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(57): error: expected a ";"
    : allocator(_Al) {_Tidy(); assign(_F, _L); }
    ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(61): error: identifier "_A" is undefined
   typedef _A allocator_type;
           ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(63): error: "size_type" is not a type name
   static const size_type npos;
                ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(64): error: identifier "_Myt" is undefined
   _Myt& operator=(const _Myt& _X)
   ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(64): error: "operator=" must be a member function
   _Myt& operator=(const _Myt& _X)
         ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(64): error: identifier "_Myt" is undefined
   _Myt& operator=(const _Myt& _X)
                         ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(65): error: identifier "assign" is undefined
    {return (assign(_X)); }
             ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(66): error: identifier "_Myt" is undefined
   _Myt& operator=(const _E *_S)
   ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(66): error: "operator=" must be a member function
   _Myt& operator=(const _E *_S)
         ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(66): error: identifier "_E" is undefined
   _Myt& operator=(const _E *_S)
                         ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(67): error: identifier "assign" is undefined
    {return (assign(_S)); }
             ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(68): error: identifier "_Myt" is undefined
   _Myt& operator=(_E _C)
   ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(68): error: "operator=" must be a member function
   _Myt& operator=(_E _C)
         ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(68): error: identifier "_E" is undefined
   _Myt& operator=(_E _C)
                   ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(69): error: identifier "assign" is undefined
    {return (assign(1, _C)); }
             ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(70): error: identifier "_Myt" is undefined
   _Myt& operator+=(const _Myt& _X)
   ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(70): error: identifier "_Myt" is undefined
   _Myt& operator+=(const _Myt& _X)
                          ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(70): error: too few parameters for this operator function
   _Myt& operator+=(const _Myt& _X)
         ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(70): error: nonmember operator requires a parameter with class or enum type
   _Myt& operator+=(const _Myt& _X)
         ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(71): error: identifier "append" is undefined
    {return (append(_X)); }
             ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(72): error: identifier "_Myt" is undefined
   _Myt& operator+=(const _E *_S)
   ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(72): error: identifier "_E" is undefined
   _Myt& operator+=(const _E *_S)
                          ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(72): error: too few parameters for this operator function
   _Myt& operator+=(const _E *_S)
         ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(72): error: nonmember operator requires a parameter with class or enum type
   _Myt& operator+=(const _E *_S)
         ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(73): error: identifier "append" is undefined
    {return (append(_S)); }
             ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(74): error: identifier "_Myt" is undefined
   _Myt& operator+=(_E _C)
   ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(74): error: identifier "_E" is undefined
   _Myt& operator+=(_E _C)
                    ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(74): error: too few parameters for this operator function
   _Myt& operator+=(_E _C)
         ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(74): error: nonmember operator requires a parameter with class or enum type
   _Myt& operator+=(_E _C)
         ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(75): error: identifier "append" is undefined
    {return (append(1, _C)); }
             ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(76): error: identifier "_Myt" is undefined
   _Myt& append(const _Myt& _X)
   ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(76): error: identifier "_Myt" is undefined
   _Myt& append(const _Myt& _X)
                      ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(78): error: identifier "_Myt" is undefined
   _Myt& append(const _Myt& _X, size_type _P, size_type _M)
   ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(78): error: identifier "_Myt" is undefined
   _Myt& append(const _Myt& _X, size_type _P, size_type _M)
                      ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(78): error: "size_type" is not a type name
   _Myt& append(const _Myt& _X, size_type _P, size_type _M)
                                ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(78): error: "size_type" is not a type name
   _Myt& append(const _Myt& _X, size_type _P, size_type _M)
                                              ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(80): error: identifier "_Xran" is undefined
     _Xran();
     ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(81): error: expected a ";"
    size_type _N = _X.size() - _P;
              ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(82): error: identifier "_N" is undefined
    if (_N < _M)
        ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(84): error: identifier "_Len" is undefined
    if (npos - _Len <= _M)
               ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(85): error: identifier "_Xlen" is undefined
     _Xlen();
     ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(86): error: identifier "_Grow" is undefined
    if (0 < _M && _Grow(_N = _Len + _M))
                  ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(87): error: name followed by "::" must be a class or namespace name
     {_Tr::copy(_Ptr + _Len, &_X.c_str()[_P], _M);
      ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(87): error: identifier "_Ptr" is undefined
     {_Tr::copy(_Ptr + _Len, &_X.c_str()[_P], _M);
                ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(88): error: identifier "_Eos" is undefined
     _Eos(_N); }
     ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(89): error: "this" may only be used inside a nonstatic member function
    return (*this); }
             ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(90): error: identifier "_Myt" is undefined
   _Myt& append(const _E *_S, size_type _M)
   ^
C:\Programme\Microsoft Visual Studio\VC98\INCLUDE\xstring(90): error: identifier "_E" is undefined
   _Myt& append(const _E *_S, size_type _M)
                      ^
compilation aborted for C:\Dokumente und Einstellungen\Administrator\Desktop\ObjectFactory\ObjectFactory\main.cpp (code 4)
Fehler beim Ausführen von xicl6.exe.

ObjectFactory.exe - 100 Fehler, 113 Warnung(en)


There is some german in it, but you dont need exactly what it means.

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Oh and support for dynamic parameters would be fine.

   ObjectFactory3 monster_factory;


   // Register monsters with the object factory class
   monster_factory.Register(OGRE_MONSTER, Type2Type());
   monster_factory.Register(GOBLIN_MONSTER, Type2Type());


   // We can instantiated the proper monster class, just by referencing its
   // unique identifier
   Monster *monster1 = monster_factory.Create(GOBLIN_MONSTER, 34.5f, 63.0f, NULL);
 


I got it working with seting one paramter to NULL and added this:
class GoblinMonster : public Monster
{
public:
   GoblinMonster(float x, float y, float z = 0.0f)
 


Greets, Christian

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

quote:
Original post by Myopic Rhino
quote:
Original post by Nerusai
Mods, when I click the discuss this article in the forums button in the Object Factory doc it won't redirect to here :/

(It links to:http://www.gamedev.net/community/forums/topic.asp?key=featart&uid=2097&forum_id=35&Topic_Title=Creating+a+Generic+Object+Factory)

I'm unable to duplicate this problem. It's working correctly for me, in both versions of the article. The above link should be correct for this thread.

I'm not sure this belongs in the discussion thread, but it doesn't work for me either. None of the discussion thread links work, they all go to a thread page with no forum title, with only the statement "No topics have been found, or topic has been deleted"

 User Rating: 1130   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

quote:
Original post by sandy
quote:

Example 2 gives a very primitive (but very easy to code) example of the popular 'Quake Console'. It could also be useful for debugging you game. Say if you are in the game and want to test your ogre monster you could type in the console "create_ogre 83.0f, 14.2f, 54.4f" and it would dynamically create the ogre at those coordinates.



I still think that using a pluggable factory is an overkill, even in this example too.

When the user enters the "create_ogre" command, the internal code is obviously going to have to check the command to see which class the object factory needs to create. In other words it would do something like this (semi-pseudo code), right?

Monster *monster;
if "create_ogre" then
   monster = objectFactory.Create( MONSTER_OGRE, 83.0f, 14.2f, 54.4f );
if "create_goblin" then
   monster = objectFactory.Create( MONSTER_GOBLIN, 83.0f, 14.2f, 54.4f );



However, this same functionality can be achieved with just:

Monster *monster;
if "create_ogre" then
   monster = new MonsterOgre( 83.0f, 14.2f, 54.4f );
if "create_goblin" then
   monster = new MonsterGoblin( 83.0f, 14.2f, 54.4f );




Take a look at the second example in the source. You wouldn't execute like this:

Monster *monster;
if "create_ogre" then
   monster = objectFactory.Create( MONSTER_OGRE, 83.0f, 14.2f, 54.4f );
if "create_goblin" then
   monster = objectFactory.Create( MONSTER_GOBLIN, 83.0f, 14.2f, 54.4f );

But instead like this:

Monster *monster = objectFactory.Create(monster_string, 83.0f, 14.2f, 54.4f );



That's it. You can add new monsters simply by calling:

objectFactory.Register<NewMonsterClass>("my new monster name");

That's the whole idea of the object factory. To not have to put in those if/else statements to create new objects.


- Houdini


[edited by - Houdini on May 22, 2004 12:47:19 AM]

[edited by - Houdini on May 22, 2004 12:48:19 AM]

 User Rating: 1111   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

quote:
Original post by Austrian Coder
A nice improvement would be support for intel compiler. A friend of me is using it and he gets some errors when compiling

Well, the problem is this requires a fairly compliant compiler to use constructor parameters in the object factory class. This is why I had to create a specific version for VC6.

If you remove the capability of passing constructor parameters then it would be quite trivial to get it to compile on just about any compiler.


- Houdini

 User Rating: 1111   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

quote:
Original post by Madhed
Well... create_ogre doesn't seem to me like a typpical console command.

Let's call the command just "create" and it would look very different.

>create "ogre" 1.4 3.5 8.5 .....

void cmd_create()
{
foo = Factory.Create(par[1]);
foo.SetPosition(...);
}


Quite true. It was just a contrived example. For a simple console based commands it would probably be best to create and use a base Command class, like in my second example. All derived Command classes would be required accept a stream as a constructor parameter, ie:

while (!stream.eof)
{
   // Retrieve first word found in the stream.  This would be the command class we pass to the object factory for it to create.

   ...
 
   object_factory.Create(command_name, stream);
}


In the sample above we retrieve each command and pass this to the object factory so it could create the proper command class. Then we'd pass the stream itself as a constructor parameter to that command class. This would give each command class a chance to read expected/required parameters directly off the stream itself. This would also have the side effect of leaving the position of the stream at the beginning of the next command line.

For example, the above code would be able to handle these commands just fine:

walk_forward
create_ogre 45.6 74.3 2.5
talk "Hi, what's up???"

The walk_forward command class wouldn't need to read any parameters off the stream, so it would just return. The create_ogre command would read in 3 floats, and the talk command would read in a string from the stream.


- Houdini

 User Rating: 1111   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

-Houdini

Monster *monster = objectFactory.Create(monster_string, 83.0f, 14.2f, 54.4f );


This would not work as you cannot pass a string for the name of the class. The compiler needs a class id in order to create the class. This means you would have to pass in an integer value that matches each monster class id from the enumeration. If you wanted to reference a class by its name (using a string) then you would need some if statements again in order to determine what the user passed in via the string, so that the system can interpret it into a class id.

I know this may seem picky, but I am still struggling to find an example where a pluggable factory proves to be the most effective solution.

 User Rating: 230   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Sandy, I sincerely recommend you read the article and code a few more times...

// from listing 4

template<typename BaseClassType, typename Param1Type, typename UniqueIdType>
class ObjectFactory<BaseClassType (Param1Type), UniqueIdType>
{
...
   BaseClassType Create(UniqueIdType unique_id, Param1Type param1)
   {
      ...
      return ((*iter).second)(param1);
   }
};


As you can see, the last template parameter is what is going to be used as an identifier. And in that string example, guess what the UniqueIdType would be? std::string, probably...

}-- Programmer/Gamer/Dreamer --{
I didn't choose to code, coding choose me.

 User Rating: 1352   |  Rate This User  Send Private MessageView ProfileView Journal Report this Post to a Moderator | Link

Yes, I am aware of that Seriema. However, when was the last time you got C++ to create a class based on a string as the class id? Go to the code and try and pass in a std::string as the class id. It won't compile. My point is that the class id has to be an integer value (at least I'm pretty sure as I have never seen it any other way). If you wanted to use a string then the system would have to translate the text into the appropriate integer value, which defeats the purpose of pluggable factories. The solution would be to pass an integer value, but then you don't know what value represents what class, which decreases useability.

I think the implementation of a pluggable factory is unjustified as I have not seen a problem yet that can't be solved without them, and the solution that doesn't use them is a lot simpler.

 User Rating: 230   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link
Page:   1 2 »»
All times are ET (US)

Post Reply
 Last Thread Next Thread 
Forum Rules:
You may not post new threads
You may post replies
You may not edit your posts
You may not use HTML in your posts
Jump To:
Administrative Options: