00001 /*MT* 00002 00003 MediaTomb - http://www.mediatomb.cc/ 00004 00005 cached_url.cc - this file is part of MediaTomb. 00006 00007 Copyright (C) 2005 Gena Batyan <bgeradz@mediatomb.cc>, 00008 Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc> 00009 00010 Copyright (C) 2006-2010 Gena Batyan <bgeradz@mediatomb.cc>, 00011 Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc>, 00012 Leonhard Wimmer <leo@mediatomb.cc> 00013 00014 MediaTomb is free software; you can redistribute it and/or modify 00015 it under the terms of the GNU General Public License version 2 00016 as published by the Free Software Foundation. 00017 00018 MediaTomb is distributed in the hope that it will be useful, 00019 but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00021 GNU General Public License for more details. 00022 00023 You should have received a copy of the GNU General Public License 00024 version 2 along with MediaTomb; if not, write to the Free Software 00025 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. 00026 00027 $Id: cached_url.cc 2081 2010-03-23 20:18:00Z lww $ 00028 */ 00029 00031 00032 #ifdef HAVE_CONFIG_H 00033 #include "autoconfig.h" 00034 #endif 00035 00036 #include <time.h> 00037 00038 #include "cached_url.h" 00039 #include "tools.h" 00040 00041 using namespace zmm; 00042 00043 CachedURL::CachedURL(int object_id, zmm::String url) 00044 { 00045 this->object_id = object_id; 00046 this->url = url; 00047 this->creation_time = time(NULL); 00048 if (this->creation_time == -1) 00049 { 00050 throw _Exception(_("Failed to get current time: ") + 00051 mt_strerror(errno)); 00052 } 00053 this->last_access_time = creation_time; 00054 mutex = Ref<Mutex>(new Mutex(false)); // non recursive mutex 00055 } 00056 00057 int CachedURL::getObjectID() 00058 { 00059 return object_id; 00060 } 00061 00062 String CachedURL::getURL() 00063 { 00064 AUTOLOCK(mutex); 00065 last_access_time = time(NULL); 00066 if (last_access_time == -1) 00067 { 00068 throw _Exception(_("Failed to get current time: ") + 00069 mt_strerror(errno)); 00070 } 00071 return url; 00072 } 00073 00074 time_t CachedURL::getCreationTime() 00075 { 00076 return creation_time; 00077 } 00078 00080 time_t CachedURL::getLastAccessTime() 00081 { 00082 AUTOLOCK(mutex); 00083 return last_access_time; 00084 }
1.6.1