mercredi 3 juillet 2019

looping enums in classes

I wanted to know if this is the best way to do this

It just seems like alot of classes, there has gotta be a cleaner shorter way maybe without vectors?

I posted about this before but changed how im doing it ................

class bones{
public:
    std::vector<int> ALL() { return _All; }
    std::vector<int> _All;
};

class RightArm : public bones{
public:
    enum : int{
        CLAVICLE = 10,
        UPPERARM = 11,
        FOREARM = 12,
        HAND = 13
    };

    RightArm() { _All = { CLAVICLE, UPPERARM, FOREARM, HAND }; }
};

class RightFoot : public bones{
public:
    enum : int{
        THIGH = 19,
        CALF = 20,
        FOOT = 21
    };

    RightFoot() { _All = { THIGH, CALF, FOOT }; }
};

class skeleton : public Singleton<skeleton>{
public:

    skeleton(){
        _All = {
            _RightArm,
            _RightFoot
            ....
        };
    }

    std::vector<bones> ALL() { return _All; }

private:
    RightArm _RightArm;
    RightFoot _RightFoot;
    ....
    std::vector<bones> _All;
};

for (auto s : skeleton::Get().ALL()){
    for (auto b : s.ALL()){

    }
}

Aucun commentaire:

Enregistrer un commentaire