Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template <class C>
- class Singleton {
- /*! class Singleton
- * brief Singleton Template
- */
- public:
- /*!
- * brief Public access interface
- * return Singleton instance
- */
- static C *getInstance (){
- // Create new instance if not initialised
- if (_singleton == NULL){
- _singleton = new C;
- }
- return (static_cast<C*> (_singleton));
- }
- /*!
- * brief Public access destructor
- */
- static void kill(){
- // Clean Singleton object and free memory
- if (_singleton != NULL){
- delete _singleton;
- _singleton = NULL;
- }
- }
- protected:
- /*!
- * brief Empty constructor
- */
- Singleton() = default;
- /*!
- * brief Destructor
- */
- virtual ~Singleton() = default;
- private:
- static C *_singleton; /*!< Unique instance */
- };
- template <class C>
- C *Singleton<C>::_singleton = NULL;
- class TextureManager : public Singleton<TextureManager> {
- friend class Singleton<TextureManager>;
- /*! class TextureManager
- * brief Textures Container
- */
- public:
- protected:
- /*!
- * brief Empty constructor
- */
- TextureManager();
- /*!
- * brief Destructor
- */
- ~TextureManager() override;
- private:
- };
- build/main.o: In function `Singleton<TextureManager>::getInstance()':
- main.cpp (.text._ZN9SingletonI14TextureManagerE11getInstanceEv[_ZN9SingletonI14TextureManagerE11getInstanceEv]+0x24): undefined reference to `TextureManager::TextureManager()'
- TextureManager::TextureManager() = default;
- TextureManager::~TextureManager() = default;
- INCLUDE = -I/usr/X11R6/include/
- LIBDIR = -L/usr/X11R6/lib
- SRCDIR := sources
- BUILDDIR := build
- TARGET := bin/game
- SRCEXT := cpp
- SOURCES := $(shell find $(SRCDIR) -type f -name *.$(SRCEXT))
- OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.o))
- FLAGS = -std=c++11 -Wall
- CC = g++
- CFLAGS = $(FLAGS) $(INCLUDE)
- LIBS = -lglut -lGL -lGLU -lGLEW -lm
- $(TARGET): $(OBJECTS)
- @echo "Linking..."
- @echo "$(CC) $(CFLAGS) $^ -o $@ $(LIBDIR) $< $(LIBS)"; $(CC) $(CFLAGS) -o $@ $(LIBDIR) $< $(LIBS)
- $(BUILDDIR)/%.o: $(SRCDIR)/%.$(SRCEXT)
- @mkdir -p $(@D)
- @echo "$(CC) $(CFLAGS) -o $@ $(LIBDIR) $< $(LIBS)"; $(CC) $(CFLAGS) -c -o $@ $(LIBDIR) $< $(LIBS)
- clean:
- @echo "Cleaning..."
- @echo "$(RM) -r $(BUILDDIR) $(TARGET)"; $(RM) -r $(BUILDDIR) $(TARGET)
- .PHONY: clean
Add Comment
Please, Sign In to add comment