Add a PromotionManager.
[tagua/yd.git] / src / components.h
blob28bb5837d5d38f741626795eb33c900973076fc7
1 /*
2 Copyright (c) 2007 Paolo Capriotti <p.capriotti@gmail.com>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8 */
10 #ifndef COMPONENTS_H
11 #define COMPONENTS_H
13 #include <memory>
14 #include <QMap>
16 #include "variant.h"
18 class IAnimator;
19 class IAnimatorFactory;
20 class IColor;
21 class IMoveSerializer;
22 class INamer;
23 class IPolicy;
24 class IState;
25 class IValidator;
26 class TaguaAPI;
27 class Variant;
29 /**
30 * @brief A utility class to simplify the interaction with variant components.
32 * A component object holds all official components of a variant, and exposes
33 * utility methods to retrieve them, or create them using the appropriate
34 * factories.
36 * Most methods return a component owned by the variant, but those that start
37 * with 'create' use a factory to instantiate a new component that will be
38 * owned by the caller.
40 class Components {
41 std::auto_ptr<Variant> m_variant;
43 IAnimatorFactory* m_animator_factory;
44 IState* m_state;
46 QMap<QString, IMoveSerializer*> m_move_serializers;
47 INamer* m_namer;
48 IPolicy* m_policy;
49 IValidator* m_validator;
50 QMap<int, IColor*> m_players;
51 public:
52 explicit Components(Variant*);
54 void setVariant(Variant*);
56 IAnimator* createAnimator(TaguaAPI* api) const;
57 IState* createState() const;
59 IMoveSerializer* moveSerializer(const QString& type);
60 INamer* namer();
61 IPolicy* policy();
62 IValidator* validator();
63 IColor* player(int index);
64 QMap<int, IColor*> players();
66 Variant* variant();
69 #endif // COMPONENTS_H