ConfigVarHandler.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright (C) 2022 The V-Gears Team
  3. *
  4. * This file is part of V-Gears
  5. *
  6. * V-Gears is free software: you can redistribute it and/or modify it under
  7. * terms of the GNU General Public License as published by the Free Software
  8. * Foundation, version 3.0 (GPLv3) of the License.
  9. *
  10. * V-Gears is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #include <cstdint>
  16. #include "ConfigVarHandler.h"
  17. /**
  18. * Configuration variable manager singleton.
  19. */
  20. template<>ConfigVarHandler *Ogre::Singleton<ConfigVarHandler>::msSingleton = nullptr;
  21. ConfigVarHandler::ConfigVarHandler(){
  22. // TODO: Properly cast this.
  23. if (reinterpret_cast<std::uintptr_t>(&ConfigVar::static_config_var_list_) != 0xffffffff){
  24. for (ConfigVar* cvar = ConfigVar::static_config_var_list_; cvar; cvar = cvar->previous_)
  25. config_vars_.push_back(cvar);
  26. // TODO: Properly cast this.
  27. ConfigVar::static_config_var_list_ = reinterpret_cast<ConfigVar*>(0xffffffff);
  28. }
  29. }
  30. ConfigVar* ConfigVarHandler::Find(const Ogre::String& name) const{
  31. for (size_t i = 0; i < config_vars_.size(); ++ i)
  32. if (config_vars_[i]->GetName() == name) return config_vars_[i];
  33. return nullptr;
  34. }
  35. unsigned int ConfigVarHandler::GetConfigVarNumber() const{return config_vars_.size();}
  36. ConfigVar* ConfigVarHandler::GetConfigVar(const unsigned int i) const{
  37. if (i < config_vars_.size()) return config_vars_[i]; return nullptr;
  38. }