Salut je possède une classe avec des fonction template comme ceci :
Code cpp : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
 
#ifndef UPS_State_PARAMETER_H
#define UPS_State_PARAMETER_H
#include "any.h"
#include <string>
/**
 *\namespace odfaeg
 * the namespace of the Opensource Development Framework Adapted for Every Games.
 */
namespace odfaeg {
    namespace core {
        /**
        * \file stateParameter.h
        * \class StateManager
        * \brief A parameter, this class is used to set parameters to the states.
        * \author Duroisin.L
        * \version 1.0
        * \date 1/02/2014
        */
        class ODFAEG_CORE_API StateParameter {
 
            private :
                any value; /**> the value of the parameter. (can be of any type)*/
                std::string name; /**> the name of the parameter.*/
 
            public :
                /** \fn StateParameter (T value, std::string name)
                *    \brief constructor.
                *    \param T value : the value of the parameter.
                *    \param std::string name : the name of the parameter.
                */
                template <typename T> StateParameter (T value, std::string name) :
                     name (name), value (std::forward<T>(value)) {
                }
                /**  \fn T getValue ()
                *    \brief get the value of the parameter.
                *    \return T : the value of the parameter.
                */
                template <typename T> T getValue () const {
                    return value.get<T>();
                }
                /**  \fn void setValue (T value)
                *    \brief set the value of a parameter.
                *    \return the value of the parameter.
                */
                template <typename T>  void setValue (T value) {
                    value.set (std::forward<T>(value));
                }
                /** \fn std::string getName() const
                *   \return the name of the parameter.
                */
                std::string getName() const {
                    return name;
                }
                /** \fn void setName()
                *   \brief std::string name : set the name of a parameter.
                *   \param std::string name : the name of the parameter.
                */
                void setName(std::string name) {
                    this->name = name;
                }
                /** \fn ~StateParameter()
                *   \brief destructor.
                */
                ~StateParameter() {
 
                }
        };
    }
}
#endif
Une autre classe qui contient tout les paramètres :
Code cpp : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
 
#ifndef State_H
#define State_H
#include <vector>
#include "erreur.h"
#include <sstream>
#include "stateParameter.h"
#include <memory>
/**
 *\namespace odfaeg
 * the namespace of the Opensource Development Framework Adapted for Every Games.
 */
namespace odfaeg {
        namespace core {
        class StateExecutor;
        /**
        * \file state.h
        * \class State
        * \brief holds a particular state of the application. (Or of an entity)
        * \author Duroisin.L
        * \version 1.0
        * \date 1/02/2014
        */
        class ODFAEG_CORE_API State {
 
 
            private :
                std::string name; /**> std::string name the name of the state*/
                StateExecutor* stateExec; /**> a state executor to apply and unapply the state.*/
                /** \fn State& operator= (const State &p);
                *   \brief affector
                *   \param const State &p : affect the current state.
                *   \return State& the affected state.
                */
                std::vector<StateParameter*> parameters; /**> parameters of the states.*/
                static int nbStates; /**> nb states created. */
            public :
                /**\fn  State (std::string name, StateExecutor *stateExec);
                *  \brief create a state with the given state executor which apply and unapply the state.
                *  \param std::string name : the name of the state.
                *  \param StateExecutor stateExec : a pointer to a StateExecutor which apply and unapply a state.
                */
                State (std::string name, StateExecutor *stateExec);
                std::string getName () const;
                void setName (std::string name);
                template <typename T> bool addParameter (std::string name, T value) {
 
                    StateParameter* p = new StateParameter (value, name);
 
                    for (unsigned int i = 0; i < parameters.size(); i++) {
                        if (parameters[i]->getName() == name) {
                            delete p;
                            return false;
                        }
                    }
 
                    parameters.push_back(p);
                    return true;
                }
                /**\fn  bool removeParameter (std::string name)
                *  \brief remove a parameter to the state.
                *  \param std::string name : the name of the parameter.
                */
                bool removeParameter (std::string name);
                StateParameter& getParameter (const std::string name) throw (Erreur) {
                        for (unsigned int i = 0; i < parameters.size(); i++) {
                            if (parameters[i]->getName() == name) {
 
                                return *parameters[i];
                            }
                        }
                        throw Erreur(5, "No such parameter for this State : " + name, 2);
                }
                /**\fn  bool changeParameter (std::string name, T* value)
                *  \brief change the value of a parameter.
                *  \param std::string name : the name of the parameter.
                *  \param T* value : the value of the parameter.
                */
                template <typename T> void changeParameter (const std::string name, T value) {
                    StateParameter& parameter = getParameter(name);
                    parameter.setValue(value);
                }
                /**\fn void setExecutor (StateExecutor *exec)
                *  \brief set the executor to apply or unapply the state.
                *  \param StateExecutor *exec : the executor.
                */
                void setExecutor (StateExecutor* exec) {
                    this->stateExec = exec;
                }
                /**\fn bool doActionState ()
                *  \brief apply the state.
                *  \return true if the state has been correctly applied.
                */
                bool doActionState ();
                /**\fn bool undoActionState ()
                *  \brief unapply the state.
                *  \return true if the state has been correctly applied.
                */
                bool undoActionState ();
                static int getNbStates () {
                    return nbStates;
                }
                /**\fn ~State()
                *  \brief destructor.
                */
                ~State () {
                    for (unsigned int i = 0; i < parameters.size(); i++) {
                        delete parameters[i];
                    }
                    parameters.clear();
                    nbStates--;
                }
        };
    }
}
#endif

Et la classe Entity pour ajouter des paramètres perso aux entités :
Code cpp : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 
/** \fn void addAttribute (std::string name, T value)
                *   \brief add an attribute to the entity.
                *   \param std::string the name of the attribute.
                *   \param T the value of the attribute.
                *   \return if the attribute has been correctly added.
                */
                template <typename T> bool addAttribute (std::string name, T value) {
                    return entityState.addParameter(name, value);
                }
                /** \fn const StateParameter& getAttribute (const std::string name)
                *   \brief get an attribute of the entity.
                *   \param std::string name : the name of the attribute of the entity.
                *   \return StateParameter& : the attribute of the entity.
                */
                const core::StateParameter& getAttribute (const std::string name) throw (core::Erreur) {
                       return entityState.getParameter(name);
                }
                /** \fn void changeAttribute (const std::string name)
                *   \brief change the value of the attribute of the entity.
                *   \param std::string name : the name of the attribute of the entity.
                *   \param T value : the value of the attribute.
                */
                template <typename T> void changeAttribute (const std::string name, T value) {
                    entityState.changeParameter(name, value);
                }

Le problème est lorsque j'appelle la méthode changeAttribute ici :
Code cpp : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
 
if (!addAttribute("isAlive",Application::app->getClock("TimeClock").getElapsedTime().asMicroseconds()))
                changeAttribute("isAlive",Application::app->getClock("TimeClock").getElapsedTime().asMicroseconds());

Il me met cette erreur-ci

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
 
||=== Build: Debug in ODFAEG-CLIENT (compiler: GNU GCC Compiler) ===|
/home/laurent/Développement/Projets-c++/ODFAEG-CLIENT/application.cpp|415|warning: "/*" within comment [-Wcomment]|
/home/laurent/Développement/Projets-c++/ODFAEG-CLIENT/application.cpp||In member function ‘virtual void sorrok::MyAppli::onExec()’:|
/home/laurent/Développement/Projets-c++/ODFAEG-CLIENT/application.cpp|640|warning: comparison between signed and unsigned integer expressions [-Wsign-compare]|
/home/laurent/Développement/Projets-c++/ODFAEG-CLIENT/application.cpp|759|warning: comparison between signed and unsigned integer expressions [-Wsign-compare]|
/home/laurent/Développement/Projets-c++/ODFAEG-CLIENT/application.cpp|797|warning: comparison between signed and unsigned integer expressions [-Wsign-compare]|
/usr/local/include/odfaeg/Core/stateParameter.h||In instantiation of ‘void odfaeg::core::StateParameter::setValue(T) [with T = long long int]’:|
/usr/local/include/odfaeg/Core/state.h|80|required from ‘void odfaeg::core::State::changeParameter(std::string, T) [with T = long long int; std::string = std::basic_string<char>]’|
/usr/local/include/odfaeg/Graphics/entity.h|253|required from ‘void odfaeg::graphic::Entity::changeAttribute(std::string, T) [with T = long long int; std::string = std::basic_string<char>]’|
/home/laurent/Développement/Projets-c++/ODFAEG-CLIENT/caracter.cpp|107|required from here|
/usr/local/include/odfaeg/Core/stateParameter.h|46|error: request for member ‘set’ in ‘value’, which is of non-class type ‘long long int’|
||=== Build failed: 1 error(s), 8 warning(s) (0 minute(s), 10 second(s)) ===|
Je ne comprend pas très bien cette erreur : request for member 'set' in 'value', which is of non-class type 'long long int'|

Requis pour membre set dans value qui n'est pas de type long long int ?

Pourtant le paramètre "isAlive" est de type sf::Int64 qui est un long long int.