IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C++ Discussion :

petit problème avec gcc-4.7


Sujet :

C++

  1. #1
    Membre expérimenté

    Homme Profil pro
    Étudiant
    Inscrit en
    Novembre 2011
    Messages
    685
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Ain (Rhône Alpes)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Novembre 2011
    Messages : 685
    Points : 1 418
    Points
    1 418
    Par défaut petit problème avec gcc-4.7
    Bonjour à tous,

    vous trouverez ci-dessous le contenu de mon invite de commande et quelques commentaires qui résument bien la situation. J'aimerais avoir votre avis sur cette étrangeté...

    C:\Program Files (x86)\CodeBlocks\Projets\FAST>g++ -std=c++11 Automaton.hpp Buil
    der.hpp main.cpp State.hpp TestBuilder.hpp TestBuilder.cpp Transition.hpp

    C:\Program Files (x86)\CodeBlocks\Projets\FAST>a.exe
    duree sequence1 (10000000 elements) : 20.0161 secondes
    temps moyen par etat : 2.00161 micro-secondes
    C:\Program Files (x86)\CodeBlocks\Projets\FAST>a.exe
    duree sequence1 (10000000 elements) : 19.7941 secondes
    temps moyen par etat : 1.97941 micro-secondes

    *** là je passe à 1 million d'element au lieu de 10M

    C:\Program Files (x86)\CodeBlocks\Projets\FAST>g++ -std=c++11 Automaton.hpp Buil
    der.hpp main.cpp State.hpp TestBuilder.hpp TestBuilder.cpp Transition.hpp

    C:\Program Files (x86)\CodeBlocks\Projets\FAST>a.exe
    duree sequence1 (10000000 elements) : 1.98611 secondes
    temps moyen par etat : 0.198611 micro-secondes

    *** le nb (#define NB ...) d'element est l'ancien et du coup le temps moyen (tpsTot/NB) est altere...
    ***je relance l'exe...

    C:\Program Files (x86)\CodeBlocks\Projets\FAST>a.exe
    duree sequence1 (10000000 elements) : 1.95411 secondes
    temps moyen par etat : 0.195411 micro-secondes

    ***toujours la même erreur...
    ***je compile une deuxième fois...

    C:\Program Files (x86)\CodeBlocks\Projets\FAST>g++ -std=c++11 Automaton.hpp Buil
    der.hpp main.cpp State.hpp TestBuilder.hpp TestBuilder.cpp Transition.hpp

    C:\Program Files (x86)\CodeBlocks\Projets\FAST>a.exe
    duree sequence1 (1000000 elements) : 2.07912 secondes
    temps moyen par etat : 2.07912 micro-secondes
    C:\Program Files (x86)\CodeBlocks\Projets\FAST>

    ***tout est redevenu normal...

    ! Vous auriez une explication ?

    Merci d'avance.

    Edit : sinon, niveau performances, vous trouvez-ça comment au niveau des variations ? Je devrais peut-être faire un autre topic, mais je crois que j'ai un léger problème niveau perf, le CPU monte à 50%...

    la mémoire elle reste à 876Ko au départ puis à 880Ko quelques secondes après.
    Nullius in verba

  2. #2
    Invité
    Invité(e)
    Par défaut
    Bonjour,

    Ce n'est pas vraiment une réponse à ta question mais en tout cas, il ne faut pas compiler les en-tetes, donc pas besoin de les passer comme argument à g++. Si ils sont dans un (ou des) dossier(s) spécial (-aux), tu peux l'indiquer à g++ avec la commande -I.

  3. #3
    Membre expérimenté

    Homme Profil pro
    Étudiant
    Inscrit en
    Novembre 2011
    Messages
    685
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Ain (Rhône Alpes)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Novembre 2011
    Messages : 685
    Points : 1 418
    Points
    1 418
    Par défaut
    Citation Envoyé par Joe Dralliam Voir le message
    Bonjour,

    Ce n'est pas vraiment une réponse à ta question mais en tout cas, il ne faut pas compiler les en-tetes, donc pas besoin de les passer comme argument à g++. Si ils sont dans un (ou des) dossier(s) spécial (-aux), tu peux l'indiquer à g++ avec la commande -I.
    je sais mais si je les met pas il utilise les headers précompilés qu'il trouve (donc les versions sans la modif) et du coup ne prend pas en compte les nouvelles modifications.
    Nullius in verba

  4. #4
    Membre expert
    Avatar de Klaim
    Homme Profil pro
    Développeur de jeux vidéo
    Inscrit en
    Août 2004
    Messages
    1 717
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur de jeux vidéo
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Août 2004
    Messages : 1 717
    Points : 3 344
    Points
    3 344
    Par défaut
    Sans le code, je ne vois pas bien comment on peut commenter ces resultats...

  5. #5
    Membre expérimenté

    Homme Profil pro
    Étudiant
    Inscrit en
    Novembre 2011
    Messages
    685
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Ain (Rhône Alpes)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Novembre 2011
    Messages : 685
    Points : 1 418
    Points
    1 418
    Par défaut
    Citation Envoyé par Klaim Voir le message
    Sans le code, je ne vois pas bien comment on peut commenter ces resultats...
    si ça avait été un bug connu pas besoin de code, et vu la taille de mon code, et que je suis quasi-sur que cela vient pas de ça, je n'ai rien mis. Entre les deux compilations tout ce qui change c'est la valeur d'un #define :/

    Si tu parlais juste niveau perfs, alors oui, désolé ce sera mieux avec le code

    Bon, bah la pièce jointe ça marche pas des masses...

    main.cpp
    Code : 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
     
    #include "TestBuilder.hpp"
    #include <chrono>
    #include <iostream>
     
    using namespace std;
     
    int main()
    {
        auto time1 = chrono::system_clock::now();
        FAST::Sample::TestBuilder T;
        bool sequenceSucceed = T.Sequence1();
        auto time2 = chrono::system_clock::now();
     
        chrono::duration<double, micro> micro = (time2 - time1);
        chrono::duration<double> s = (time2 - time1);
        cout << "duree sequence1 (" << NB << " elements) : " << s.count() << " secondes" << endl;
        double nb = NB;
        cout << "temps moyen par etat : " << micro.count()/nb << " micro-secondes";
        return 0;
    }
    Automaton.hpp
    Code : 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
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
     
    ////////////////////////////////////////////////////////////
    //
    // FAST - Free Automatons with States and Transitions
    // Copyright (C) 2009-2012 Crim'17++ (crim17plusplus@gmail.com)
    //
    // This software is provided 'as-is', without any express or implied warranty.
    // In no event will the authors be held liable for any damages arising from the use of this software.
    //
    // Permission is granted to anyone to use this software for any purpose,
    // including commercial applications, and to alter it and redistribute it freely,
    // subject to the following restrictions:
    //
    // 1. The origin of this software must not be misrepresented;
    //    you must not claim that you wrote the original software.
    //    If you use this software in a product, an acknowledgment
    //    in the product documentation would be appreciated but is not required.
    //
    // 2. Altered source versions must be plainly marked as such,
    //    and must not be misrepresented as being the original software.
    //
    // 3. This notice may not be removed or altered from any source distribution.
    //
    ////////////////////////////////////////////////////////////
     
    #ifndef AUTOMATON_HPP
    #define AUTOMATON_HPP
     
    #include <memory>
    #include <vector>
    #include "State.hpp"
     
    namespace FAST
    {
     
        template<typename Type, typename Label>
        class Automaton
        {
            public :
                typedef std::vector<State<Type,Label>*> T_statesVector;
     
                Automaton(const Label& label, const T_statesVector& statesVector = std::vector<State<Type,Label>*>());
                ~Automaton();
     
                void NewState(State<Type,Label>* state);
     
                void UpdateState(Transition<Type,Label>* transition);
     
                void NewTransitionForCurrentState(Transition<Type,Label>* transition, State<Type,Label>* stateReached);
                void NewTransitionForState(const Label& label, Transition<Type,Label>* transition, State<Type,Label>* stateReached);
     
                const State<Type,Label>* GetStateByLabel(const Label& label) const;
                State<Type,Label>* GetStateByLabel(const Label& label);
     
     
                const Label& GetLabel() const;
                Label& GetLabel();
                void SetLabel(const Label& label);
     
     
                State<Type,Label>* currentState;
     
            private :
                T_statesVector statesVector;
                Label label;
     
     
        };
     
        template<typename Type, typename Label>
        Automaton<Type,Label>::Automaton(const Label& label, const T_statesVector& statesVector) :
        statesVector(statesVector),
        label(label),
        currentState(nullptr)
        {
            //Nothing to do
        }
     
        template<typename Type, typename Label>
        Automaton<Type,Label>::~Automaton()
        {
            delete currentState;
        }
     
        template<typename Type, typename Label>
        void Automaton<Type,Label>::NewState(State<Type,Label>* state)
        {
            statesVector.push_back(state);
            if (currentState == nullptr)
                currentState = state;
        }
     
        template<typename Type, typename Label>
        const State<Type,Label>* Automaton<Type,Label>::GetStateByLabel(const Label& label) const
        {
            for(auto s : statesVector)
                if ( s->GetLabel() == label)
                    return s;
     
            return nullptr;
        }
     
        template<typename Type, typename Label>
        State<Type,Label>* Automaton<Type,Label>::GetStateByLabel(const Label& label)
        {
            for( auto s : statesVector )
                if ( s->GetLabel() == label)
                    return s;
     
            return nullptr;
        }
     
        template<typename Type, typename Label>
        void Automaton<Type,Label>::UpdateState(Transition<Type,Label>* transition)
        {
            if (currentState->GetTransitionByLabel(transition->GetLabel()) != nullptr)
                currentState = currentState->GetStateReachedByTransition(transition->GetLabel());
        }
     
        template<typename Type, typename Label>
        void Automaton<Type,Label>::NewTransitionForCurrentState(Transition<Type,Label>* transition, State<Type,Label>* stateReached)
        {
            currentState->NewTransition(transition, stateReached);
        }
     
        template<typename Type, typename Label>
        void Automaton<Type,Label>::NewTransitionForState(const Label& label, Transition<Type,Label>* transition, State<Type,Label>* stateReached)
        {
            for( auto s : statesVector )
                if ( s->GetLabel() == label )
                    s->NewTransition(transition, stateReached);
     
        }
     
        template<typename Type, typename Label>
        const Label& Automaton<Type,Label>::GetLabel() const
        {
            return label;
        }
     
        template<typename Type, typename Label>
        Label& Automaton<Type,Label>::GetLabel()
        {
            return label;
        }
     
        template<typename Type, typename Label>
        void Automaton<Type,Label>::SetLabel(const Label& label)
        {
            label = label;
        }
     
     
     
    }
     
     
    #endif
    State.hpp
    Code : 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
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
     
    ////////////////////////////////////////////////////////////
    //
    // FAST - Free Automatons with States and Transitions
    // Copyright (C) 2009-2012 Crim'17++ (crim17plusplus@gmail.com)
    //
    // This software is provided 'as-is', without any express or implied warranty.
    // In no event will the authors be held liable for any damages arising from the use of this software.
    //
    // Permission is granted to anyone to use this software for any purpose,
    // including commercial applications, and to alter it and redistribute it freely,
    // subject to the following restrictions:
    //
    // 1. The origin of this software must not be misrepresented;
    //    you must not claim that you wrote the original software.
    //    If you use this software in a product, an acknowledgment
    //    in the product documentation would be appreciated but is not required.
    //
    // 2. Altered source versions must be plainly marked as such,
    //    and must not be misrepresented as being the original software.
    //
    // 3. This notice may not be removed or altered from any source distribution.
    //
    ////////////////////////////////////////////////////////////
     
     
    #ifndef STATE_HPP
    #define STATE_HPP
     
    #include <map>
    #include "Transition.hpp"
     
    using namespace std;
    namespace FAST
    {
     
        namespace StateType
        {
            enum class T_type{initialState, intermediaryState, finalState};
        }
     
        template<typename Type, typename Label>
        class State
        {
          public :
     
            typedef std::map< Transition<Type,Label>*, State<Type,Label>*> T_transitionsMap;
     
            State(const Label& label, const T_transitionsMap& transitionsMap , const StateType::T_type& type = StateType::T_type::intermediaryState);
            State(const Label& label, const StateType::T_type& type, const T_transitionsMap& transitionsMap = T_transitionsMap());
            ~State();
     
     
            const Label& GetLabel() const;
            Label& GetLabel();
            void SetLabel(const Label& label);
     
            const Transition<Type,Label>* GetTransitionByLabel(const Label& label) const;
            Transition<Type,Label>* GetTransitionByLabel(const Label& label);
            void NewTransition(Transition<Type,Label>* transition, State<Type,Label>* stateReached);
     
            const State<Type,Label>* GetStateReachedByTransition(const Label& label) const;
            State<Type,Label>* GetStateReachedByTransition(const Label& label);
     
            const StateType::T_type& GetType() const;
            StateType::T_type& GetType();
            void SetType(const StateType::T_type& type);
     
     
          private :
            Label label;
            T_transitionsMap transitionsMap;
            StateType::T_type type;
        };
     
     
     
        template<typename Type, typename Label>
        State<Type,Label>::State(const Label& label, const T_transitionsMap& transitionsMap , const StateType::T_type& type) :
        label(label),
        transitionsMap(transitionsMap),
        type(type)
        {
            //nothing to do
        }
     
        template<typename Type, typename Label>
        State<Type,Label>::State(const Label& label,  const StateType::T_type& type, const T_transitionsMap& transitionsMap) :
        label(label),
        transitionsMap(transitionsMap),
        type(type)
        {
     
        }
     
        template<typename Type, typename Label>
        State<Type, Label>::~State()
        {
     
        }
     
     
        template<typename Type, typename Label>
        const Label& State<Type,Label>::GetLabel() const
        {
            return label;
        }
     
        template<typename Type, typename Label>
        Label& State<Type,Label>::GetLabel()
        {
            return label;
        }
     
        template<typename Type, typename Label>
        void State<Type,Label>::SetLabel(const Label& label)
        {
            label = label;
        }
     
        template<typename Type, typename Label>
        const Transition<Type,Label>* State<Type,Label>::GetTransitionByLabel(const Label& label) const
        {
            for ( auto t : transitionsMap )
                if (t.first->GetLabel() == label)
                    return t.first;
     
            return nullptr;
        }
     
     
        template<typename Type,typename Label>
        Transition<Type,Label>* State<Type, Label>::GetTransitionByLabel(const Label& label)
        {
            for ( auto t : transitionsMap )
                if (t.first->GetLabel() == label)
                    return t.first;
     
            return nullptr;
        }
     
     
        template<typename Type, typename Label>
        void State<Type,Label>::NewTransition(Transition<Type,Label>* transition, State<Type,Label>* stateReached)
        {
            transitionsMap[transition]=stateReached;
        }
     
        template<typename Type, typename Label>
        const State<Type,Label>* State<Type,Label>::GetStateReachedByTransition(const Label& label) const
        {
            for ( auto t : transitionsMap )
                if (t.first->GetLabel() == label)
                    return t.second;
     
            return nullptr;
        }
     
        template<typename Type, typename Label>
        State<Type,Label>* State<Type,Label>::GetStateReachedByTransition(const Label& label)
        {
     
            for (auto t : transitionsMap)
                if (t.first->GetLabel() == label)
                    return t.second;
     
            return nullptr;
        }
     
     
     
     
        template<typename Type, typename Label>
        const StateType::T_type& State<Type,Label>::GetType() const
        {
            return type;
        }
     
        template<typename Type, typename Label>
        StateType::T_type& State<Type,Label>::GetType()
        {
            return type;
        }
     
        template<typename Type, typename Label>
        void State<Type,Label>::SetType(const StateType::T_type& type)
        {
            type = type;
        }
     
     
    }
     
     
    #endif
    Transition.hpp
    Code : 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
     
    ////////////////////////////////////////////////////////////
    //
    // FAST - Free Automatons with States and Transitions
    // Copyright (C) 2009-2012 Crim'17++ (crim17plusplus@gmail.com)
    //
    // This software is provided 'as-is', without any express or implied warranty.
    // In no event will the authors be held liable for any damages arising from the use of this software.
    //
    // Permission is granted to anyone to use this software for any purpose,
    // including commercial applications, and to alter it and redistribute it freely,
    // subject to the following restrictions:
    //
    // 1. The origin of this software must not be misrepresented;
    //    you must not claim that you wrote the original software.
    //    If you use this software in a product, an acknowledgment
    //    in the product documentation would be appreciated but is not required.
    //
    // 2. Altered source versions must be plainly marked as such,
    //    and must not be misrepresented as being the original software.
    //
    // 3. This notice may not be removed or altered from any source distribution.
    //
    ////////////////////////////////////////////////////////////
     
     
    #ifndef TRANSITION_HPP
    #define TRANSITION_HPP
     
    namespace FAST
    {
     
        template<typename Type, typename Label>
        class Transition
        {
     
            public:
                Transition(const Type& value, const Label& label);
                ~Transition();
     
                const Type& GetValue() const;
                Type& GetValue();
                void SetValue(const Type& value);
     
                const Label& GetLabel() const;
                Label& GetLabel();
                void SetLabel(const Label& name);
     
            private :
                Type value;
                Label label;
        };
     
        template<typename Type, typename Label>
        Transition<Type,Label>::Transition(const Type& value, const Label& label) :
        value(value),
        label(label)
        {
            //nothing to do
        }
     
        template<typename Type, typename Label>
        Transition<Type,Label>::~Transition()
        {
            //nothing to do
        }
     
        template<typename Type, typename Label>
        const Type& Transition<Type,Label>::GetValue() const
        {
            return value;
        }
     
        template<typename Type, typename Label>
        Type& Transition<Type,Label>::GetValue()
        {
            return value;
        }
     
        template<typename Type,typename Label>
        void Transition<Type,Label>::SetValue(const Type& value)
        {
            value = value;
        }
     
        template<typename Type, typename Label>
        const Label& Transition<Type,Label>::GetLabel() const
        {
            return label;
        }
     
        template<typename Type, typename Label>
        Label& Transition<Type,Label>::GetLabel()
        {
            return label;
        }
     
        template<typename Type, typename Label>
        void Transition<Type, Label>::SetLabel(const Label& label)
        {
            label = label;
        }
     
     
    }
    #endif
    TestBuilder.hpp
    Code : 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
     
    ////////////////////////////////////////////////////////////
    //
    // FAST - Free Automatons with States and Transitions
    // Copyright (C) 2009-2012 Crim'17++ (crim17plusplus@gmail.com)
    //
    // This software is provided 'as-is', without any express or implied warranty.
    // In no event will the authors be held liable for any damages arising from the use of this software.
    //
    // Permission is granted to anyone to use this software for any purpose,
    // including commercial applications, and to alter it and redistribute it freely,
    // subject to the following restrictions:
    //
    // 1. The origin of this software must not be misrepresented;
    //    you must not claim that you wrote the original software.
    //    If you use this software in a product, an acknowledgment
    //    in the product documentation would be appreciated but is not required.
    //
    // 2. Altered source versions must be plainly marked as such,
    //    and must not be misrepresented as being the original software.
    //
    // 3. This notice may not be removed or altered from any source distribution.
    //
    ////////////////////////////////////////////////////////////
     
     
    #ifndef TESTBUILDER_HPP
    #define TESTBUILDER_HPP
     
    #include "Builder.hpp"
    #include <string>
     
    #define NB 10000000
     
    using namespace std;
     
    namespace FAST
    {
        namespace Sample
        {
            class TestBuilder : public Builder<string, string>
            {
                private :
                    typedef State<string,string> SString;
                    typedef Transition<string, string> TString;
     
                public :
                    TestBuilder();
                    ~TestBuilder();
                    void Construct();
                    bool Sequence1();
     
            };
        }
    }
     
     
    #endif
    TestBuilder.cpp
    Code : 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
     
    ////////////////////////////////////////////////////////////
    //
    // FAST - Free Automatons with States and Transitions
    // Copyright (C) 2009-2012 Crim'17++ (crim17plusplus@gmail.com)
    //
    // This software is provided 'as-is', without any express or implied warranty.
    // In no event will the authors be held liable for any damages arising from the use of this software.
    //
    // Permission is granted to anyone to use this software for any purpose,
    // including commercial applications, and to alter it and redistribute it freely,
    // subject to the following restrictions:
    //
    // 1. The origin of this software must not be misrepresented;
    //    you must not claim that you wrote the original software.
    //    If you use this software in a product, an acknowledgment
    //    in the product documentation would be appreciated but is not required.
    //
    // 2. Altered source versions must be plainly marked as such,
    //    and must not be misrepresented as being the original software.
    //
    // 3. This notice may not be removed or altered from any source distribution.
    //
    ////////////////////////////////////////////////////////////
     
    #include "TestBuilder.hpp"
     
    #define KO 1
    #define OK 0
     
    namespace FAST
    {
        namespace Sample
        {
     
            TestBuilder::TestBuilder()
            {
                Construct();
            }
     
            TestBuilder::~TestBuilder()
            {
                //nothing to do
            }
     
            void TestBuilder::Construct()
            {
     
                up_automaton = std::unique_ptr<Automaton<std::string, std::string>>(new Automaton<std::string, std::string>("Automate 1"));
     
                up_automaton->NewState(new SString("Etat Initial", StateType::T_type::initialState));
                up_automaton->NewState(new SString("Etat 2",       StateType::T_type::intermediaryState));
                up_automaton->NewState(new SString("Etat 3",       StateType::T_type::intermediaryState));
                up_automaton->NewState(new SString("Etat 4",       StateType::T_type::intermediaryState));
                up_automaton->NewState(new SString("Etat 5",       StateType::T_type::finalState));
     
                up_automaton->NewTransitionForState("Etat Initial", new TString("touche haut","transition vers l'etat numero 2"),   up_automaton->GetStateByLabel("Etat 2"));
                up_automaton->NewTransitionForState("Etat Initial", new TString("touche bas","transition vers l'etat numero 3"),    up_automaton->GetStateByLabel("Etat 3"));
                up_automaton->NewTransitionForState("Etat 2",       new TString("touche gauche","transition vers l'etat numero 4"), up_automaton->GetStateByLabel("Etat 4"));
                up_automaton->NewTransitionForState("Etat 3",       new TString("touche droite","transition vers l'etat numero 5"), up_automaton->GetStateByLabel("Etat 5"));
                up_automaton->NewTransitionForState("Etat 4",       new TString("touche gauche","transition vers l'etat numero 5"), up_automaton->GetStateByLabel("Etat 5"));
                up_automaton->NewTransitionForState("Etat 4",       new TString("touche bas","transition vers l'etat numero 1"),    up_automaton->GetStateByLabel("Etat Initial"));
     
     
            }
     
            bool TestBuilder::Sequence1()
            {
                int compteur = 0;
                while(up_automaton->currentState->GetType() != StateType::T_type::finalState)
                {
                    const std::string& currentStateLabel = std::string(up_automaton->currentState->GetLabel());
                    if (currentStateLabel == "Etat Initial")
                    {
                        compteur++;
                        if (compteur==NB)
                            up_automaton->UpdateState(up_automaton->currentState->GetTransitionByLabel("transition vers l'etat numero 3"));
                        else
                            up_automaton->UpdateState(up_automaton->currentState->GetTransitionByLabel("transition vers l'etat numero 2"));
                    }
                    else if (currentStateLabel == "Etat 2")
                        up_automaton->UpdateState(up_automaton->currentState->GetTransitionByLabel("transition vers l'etat numero 4"));
                    else if (currentStateLabel == "Etat 3")
                        up_automaton->UpdateState(up_automaton->currentState->GetTransitionByLabel("transition vers l'etat numero 5"));
                    else if (currentStateLabel == "Etat 4")
                        up_automaton->UpdateState(up_automaton->currentState->GetTransitionByLabel("transition vers l'etat numero 1"));
                    else return KO;
                }
     
                return OK;
            }
        }
    }
    Voilà le code.
    Fichiers attachés Fichiers attachés
    Nullius in verba

  6. #6
    screetch
    Invité(e)
    Par défaut
    c'est parce que tu compiles tes en tetes que ca foire. Lors de la compilation il utilise un fichier precompilé vieux (donc avec l'ancienne version du define) pour créer un desfichiers precompilés

    en gros tu as A.hpp => A.pch qui utilise B.h
    puis tu as B.hpp => B.pch

    lorsque tu recompiles, tu changes un define, tu as
    A.hpp => A.pch qui utilise B.pch au lieu de B.h qui a changé
    puis B.hpp => B.pch qui genere le bon pch pour B.
    Lors d'une autre compilation, le B.pch sera cette fois ci a jour.



    retire tous les pch du repertoire, et enlève les hpp de la ligne de commande.

  7. #7
    Membre expérimenté

    Homme Profil pro
    Étudiant
    Inscrit en
    Novembre 2011
    Messages
    685
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Ain (Rhône Alpes)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Novembre 2011
    Messages : 685
    Points : 1 418
    Points
    1 418
    Par défaut
    Citation Envoyé par screetch Voir le message
    c'est parce que tu compiles tes en tetes que ca foire. Lors de la compilation il utilise un fichier precompilé vieux (donc avec l'ancienne version du define) pour créer un desfichiers precompilés

    en gros tu as A.hpp => A.pch qui utilise B.h
    puis tu as B.hpp => B.pch

    lorsque tu recompiles, tu changes un define, tu as
    A.hpp => A.pch qui utilise B.pch au lieu de B.h qui a changé
    puis B.hpp => B.pch qui genere le bon pch pour B.
    Lors d'une autre compilation, le B.pch sera cette fois ci a jour.



    retire tous les pch du repertoire, et enlève les hpp de la ligne de commande.
    Merci.
    J'essaierais ce soir mais cela doit être ça.
    Sujet Résolu.

    Cordialement,
    Nullius in verba

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Petit problème avec GCC pour l'Unicode...
    Par Nico*3-3 dans le forum Autres éditeurs
    Réponses: 6
    Dernier message: 29/01/2006, 17h12
  2. Un petit problème avec pop
    Par Paulinho dans le forum C++
    Réponses: 4
    Dernier message: 13/11/2005, 20h57
  3. Petit problème avec Line Input
    Par GrosQuicK dans le forum VB 6 et antérieur
    Réponses: 2
    Dernier message: 14/09/2005, 12h47
  4. (Petit ?) problème avec une page contenant du Flash
    Par ologram dans le forum Balisage (X)HTML et validation W3C
    Réponses: 2
    Dernier message: 01/09/2005, 18h45
  5. Petit problème avec SDL
    Par Nyarlathotep dans le forum C
    Réponses: 10
    Dernier message: 01/07/2005, 09h10

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo