glc_rep.cpp

Go to the documentation of this file.
00001 /****************************************************************************
00002 
00003  This file is part of the GLC-lib library.
00004  Copyright (C) 2005-2008 Laurent Ribon (laumaya@users.sourceforge.net)
00005  Version 2.0.0 Beta 1, packaged on April 2010.
00006 
00007  http://glc-lib.sourceforge.net
00008 
00009  GLC-lib is free software; you can redistribute it and/or modify
00010  it under the terms of the GNU General Public License as published by
00011  the Free Software Foundation; either version 2 of the License, or
00012  (at your option) any later version.
00013 
00014  GLC-lib is distributed in the hope that it will be useful,
00015  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  GNU General Public License for more details.
00018 
00019  You should have received a copy of the GNU General Public License
00020  along with GLC-lib; if not, write to the Free Software
00021  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00022 
00023  *****************************************************************************/
00024 
00025 #include "glc_rep.h"
00026 
00027 // Default constructor
00028 GLC_Rep::GLC_Rep()
00029 : m_pIsLoaded(new bool(false))
00030 , m_pNumberOfRepresentation(new int(1))
00031 , m_pFileName(new QString())
00032 , m_pName(new QString())
00033 , m_pDateTime(new QDateTime)
00034 {
00035 
00036 }
00037 
00038 // Copy Constructor
00039 GLC_Rep::GLC_Rep(const GLC_Rep& rep)
00040 : m_pIsLoaded(rep.m_pIsLoaded)
00041 , m_pNumberOfRepresentation(rep.m_pNumberOfRepresentation)
00042 , m_pFileName(rep.m_pFileName)
00043 , m_pName(rep.m_pName)
00044 , m_pDateTime(rep.m_pDateTime)
00045 {
00046         ++(*m_pNumberOfRepresentation);
00047 }
00048 
00049 // Assignement operator
00050 GLC_Rep& GLC_Rep::operator=(const GLC_Rep& rep)
00051 {
00052         if (this != &rep)
00053         {
00054                 // Clear this representation
00055                 clear();
00056                 m_pIsLoaded= rep.m_pIsLoaded;
00057                 m_pNumberOfRepresentation= rep.m_pNumberOfRepresentation;
00058                 ++(*m_pNumberOfRepresentation);
00059                 m_pFileName= rep.m_pFileName;
00060                 m_pName= rep.m_pName;
00061                 m_pDateTime= rep.m_pDateTime;
00062         }
00063 
00064         return *this;
00065 }
00066 
00067 // Destructor
00068 GLC_Rep::~GLC_Rep()
00069 {
00070         // Clear this representation
00071         clear();
00072 }
00073 
00074 
00076 // private services functions
00078 // Clear current representation
00079 void GLC_Rep::clear()
00080 {
00081         Q_ASSERT(NULL != m_pNumberOfRepresentation);
00082         if ((--(*m_pNumberOfRepresentation)) == 0)
00083         {
00084                 delete m_pIsLoaded;
00085                 m_pIsLoaded= NULL;
00086                 delete m_pNumberOfRepresentation;
00087                 m_pNumberOfRepresentation= NULL;
00088                 delete m_pFileName;
00089                 m_pFileName= NULL;
00090                 delete m_pName;
00091                 m_pName= NULL;
00092                 delete m_pDateTime;
00093                 m_pDateTime= NULL;
00094         }
00095 }

SourceForge.net Logo

©2005 Laurent Ribon