/** ** Copyright (c) 2007-2009 Illumina, Inc. ** ** This software is covered by the "Illumina Genome Analyzer Software ** License Agreement" and the "Illumina Source Code License Agreement", ** and certain third party copyright/licenses, and any user of this ** source file is bound by the terms therein (see accompanying files ** Illumina_Genome_Analyzer_Software_License_Agreement.pdf and ** Illumina_Source_Code_License_Agreement.pdf and third party ** copyright/license notices). ** ** This file is part of the Consensus Assessment of Sequence And VAriation ** (CASAVA) software package. ** ** \file RegistryName.cpp ** ** Management of the registry names for the cppunit tests. ** ** \author Come Raczy **/ #include "RegistryName.hh" #include #include #include #include const boost::filesystem::path getFilePath() {return "RegistryNames.txt";} std::vector initializeNameList() { std::vector nameList; if(boost::filesystem::exists(getFilePath())) { std::ifstream is(getFilePath().string().c_str()); std::string name; while (getline(is, name)) { if (!name.empty() && nameList.end() == std::find(nameList.begin(), nameList.end(), name)) { nameList.push_back(name); } } } return nameList; } const std::vector &getRegistryNameList() { static const std::vector nameList = initializeNameList(); return nameList; } std::string registryName(const std::string &name) throw (std::invalid_argument) { const std::vector nameList = getRegistryNameList(); const std::vector::const_iterator found = std::find(nameList.begin(), nameList.end(), name); if (found != nameList.end()) return name; else throw std::invalid_argument(std::string("Not a registryName: ") + name + std::string(" [check that ") + getFilePath().string() + std::string(" constains '") + name + std::string("']")); }