diff --git a/singleton.h b/singleton.h deleted file mode 100644 index 224f2fcb..00000000 --- a/singleton.h +++ /dev/null @@ -1,65 +0,0 @@ -///\file - -/****************************************************************************** -The MIT License(MIT) - -Embedded Template Library. - -Copyright(c) 2014 jwellbelove - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files(the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and / or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions : - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -******************************************************************************/ - -#ifndef __ETL_SINGLETON__ -#define __ETL_SINGLETON__ - -///\defgroup singleton singleton -/// Templated version of the singleton pattern. -///\ingroup etl - -namespace etl -{ - //************************************************************************* - /// Singleton pattern base class. - /// \ingroup singleton - //************************************************************************* - template - class singleton - { - public: - - //************************************************************************* - /// Returns a reference to the instance. - ///\return A reference to the instance. - //************************************************************************* - static T &instance() - { - static T the_instance; - return the_instance; - } - - private: - - // Disabled. - singleton(const singleton&); - singleton& operator =(const singleton&); - }; -} - -#endif diff --git a/test/test_singleton.cpp b/test/test_singleton.cpp deleted file mode 100644 index f2bac4cb..00000000 --- a/test/test_singleton.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/****************************************************************************** -The MIT License(MIT) - -Embedded Template Library. - -Copyright(c) 2014 jwellbelove - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files(the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and / or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions : - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -******************************************************************************/ - -#include - -#include "../singleton.h" - -class Test_Class -{ -public: - - Test_Class() - : i(0) - {} - - void Increment() - { - ++i; - } - - int i; -}; - -typedef etl::singleton Test_Singleton; - -namespace -{ - SUITE(test_singleton) - { - //************************************************************************* - TEST(test1) - { - Test_Class& ts = Test_Singleton::instance(); - - CHECK_EQUAL(0, ts.i); - - ts.Increment(); - - CHECK_EQUAL(1, ts.i); - - Test_Class* pts = &Test_Singleton::instance(); - - CHECK_EQUAL(1, ts.i); - CHECK_EQUAL(1, pts->i); - - pts->Increment(); - - CHECK_EQUAL(2, ts.i); - CHECK_EQUAL(2, pts->i); - } - } -} -