Renamed AnimationSettings -> AnimationManager.
[tagua/yd.git] / src / components.h
blob04bca8ca73031bba36af2b54d3fbc608b191fa86
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 IStateFactory;
26 class IValidator;
27 class TaguaAPI;
28 class Variant;
30 /**
31 * @brief A utility class to simplify the interaction with variant components.
33 * A component object holds all official components of a variant, and exposes
34 * utility methods to retrieve them, or create them using the appropriate
35 * factories.
37 * Most methods return a component owned by the variant, but those that start
38 * with 'create' use a factory to instantiate a new component that will be
39 * owned by the caller.
41 class Components {
42 std::auto_ptr<Variant> m_variant;
44 IAnimatorFactory* m_animator_factory;
45 IStateFactory* m_state_factory;
47 QMap<QString, IMoveSerializer*> m_move_serializers;
48 INamer* m_namer;
49 IPolicy* m_policy;
50 IValidator* m_validator;
51 QMap<int, IColor*> m_players;
52 public:
53 explicit Components(Variant*);
55 void setVariant(Variant*);
57 IAnimator* createAnimator(TaguaAPI* api) const;
58 IState* createState() const;
60 IMoveSerializer* moveSerializer(const QString& type);
61 INamer* namer();
62 IPolicy* policy();
63 IValidator* validator();
64 IColor* player(int index);
65 QMap<int, IColor*> players();
67 Variant* variant();
70 #endif // COMPONENTS_H