Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 552


Ignore:
Timestamp:
Dec 17, 2007, 1:11:28 AM (17 years ago)
Author:
landauf
Message:

removed stupid hack

Location:
code/branches/FICN/src/orxonox/core
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/FICN/src/orxonox/core/Factory.cc

    r551 r552  
    3838namespace orxonox
    3939{
    40     Factory* Factory::pointer1_s;
    41     Factory* Factory::pointer2_s;
    42     Factory* Factory::pointer3_s;
    43     Factory* Factory::pointer4_s;
    44     Factory* Factory::pointer5_s = NULL; // Set the static member variable pointer5_s to zero
    45 
    46     /**
    47         @brief Checks if the pointer to the only Factory-object exists and creates it, if not.
    48     */
    49     void Factory::checkPointer()
    50     {
    51         if ((!pointer5_s) || (pointer1_s != pointer2_s) || (pointer2_s != pointer3_s) || (pointer3_s != pointer4_s) || (pointer4_s != pointer5_s))
    52         {
    53             std::cout << pointer1_s << std::endl;
    54             std::cout << pointer2_s << std::endl;
    55             std::cout << pointer3_s << std::endl;
    56             std::cout << pointer4_s << std::endl;
    57             std::cout << pointer5_s << std::endl;
    58             pointer1_s = pointer2_s = pointer3_s = pointer4_s = pointer5_s = new Factory;
    59             std::cout << pointer1_s << std::endl;
    60             std::cout << pointer2_s << std::endl;
    61             std::cout << pointer3_s << std::endl;
    62             std::cout << pointer4_s << std::endl;
    63             std::cout << pointer5_s << std::endl;
    64         }
    65     }
     40    Factory* Factory::pointer_s = NULL; // Set the static member variable pointer_s to zero
    6641
    6742    /**
     
    7348        Factory::checkPointer();
    7449
    75         return pointer1_s->identifierStringMap_[name];
     50        return pointer_s->identifierStringMap_[name];
    7651    }
    7752
     
    8459        Factory::checkPointer();
    8560
    86         return pointer1_s->identifierNetworkIDMap_[id];
     61        return pointer_s->identifierNetworkIDMap_[id];
    8762    }
    8863
     
    9671        Factory::checkPointer();
    9772
    98         pointer1_s->identifierStringMap_[name] = identifier;
    99         pointer1_s->identifierNetworkIDMap_[identifier->getNetworkID()] = identifier;
     73        pointer_s->identifierStringMap_[name] = identifier;
     74        pointer_s->identifierNetworkIDMap_[identifier->getNetworkID()] = identifier;
    10075    }
    10176
     
    11085        Factory::checkPointer();
    11186
    112         pointer1_s->identifierNetworkIDMap_.erase(oldID);
    113         pointer1_s->identifierNetworkIDMap_[newID] = identifier;
     87        pointer_s->identifierNetworkIDMap_.erase(oldID);
     88        pointer_s->identifierNetworkIDMap_[newID] = identifier;
    11489    }
    11590
     
    12398        COUT(4) << "*** Factory -> Create class-hierarchy\n";
    12499        std::map<std::string, Identifier*>::iterator it;
    125         it = pointer1_s->identifierStringMap_.begin();
    126         (*pointer1_s->identifierStringMap_.begin()).second->startCreatingHierarchy();
    127         for (it = pointer1_s->identifierStringMap_.begin(); it != pointer1_s->identifierStringMap_.end(); ++it)
     100        it = pointer_s->identifierStringMap_.begin();
     101        (*pointer_s->identifierStringMap_.begin()).second->startCreatingHierarchy();
     102        for (it = pointer_s->identifierStringMap_.begin(); it != pointer_s->identifierStringMap_.end(); ++it)
    128103        {
    129104            // To create the new branch of the class-hierarchy, we create a new object and delete it afterwards.
     
    131106            delete temp;
    132107        }
    133         (*pointer1_s->identifierStringMap_.begin()).second->stopCreatingHierarchy();
     108        (*pointer_s->identifierStringMap_.begin()).second->stopCreatingHierarchy();
    134109        COUT(4) << "*** Factory -> Finished class-hierarchy creation\n";
    135110    }
  • code/branches/FICN/src/orxonox/core/Factory.h

    r551 r552  
    4242            Factory(const Factory& factory) {}      // don't copy
    4343            ~Factory() {}                           // don't delete
    44             static void checkPointer();
    4544
    46             static Factory* pointer1_s;                                         //!< The 1st pointer to the singleton
    47             static Factory* pointer2_s;                                         //!< The 2nd pointer to the singleton
    48             static Factory* pointer3_s;                                         //!< The 3rd pointer to the singleton
    49             static Factory* pointer4_s;                                         //!< The 4th pointer to the singleton
    50             static Factory* pointer5_s;                                         //!< The 5th pointer to the singleton
     45            /**
     46                @brief Checks if the pointer to the only Factory-object exists and creates it, if not.
     47            */
     48            inline static void checkPointer()
     49            {
     50                if (!pointer_s)
     51                    pointer_s = new Factory;
     52            }
     53
     54            static Factory* pointer_s;                                          //!< The pointer to the singleton
    5155            std::map<std::string, Identifier*> identifierStringMap_;            //!< The map, mapping the name with the Identifier
    5256            std::map<unsigned int, Identifier*> identifierNetworkIDMap_;        //!< The map, mapping the network ID with the Identifier
Note: See TracChangeset for help on using the changeset viewer.