Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 5215 invoked from network); 30 May 2007 21:00:48 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 30 May 2007 21:00:48 -0000 Received: (qmail 28763 invoked by uid 500); 30 May 2007 21:00:41 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 28729 invoked by uid 500); 30 May 2007 21:00:41 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 28710 invoked by uid 99); 30 May 2007 21:00:40 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 May 2007 14:00:40 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 May 2007 14:00:34 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 0EFF61A981A; Wed, 30 May 2007 14:00:14 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r542931 - in /activemq/activemq-cpp/trunk/src/main/decaf/util: Date.cpp Date.h Date: Wed, 30 May 2007 21:00:13 -0000 To: commits@activemq.apache.org From: tabish@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070530210014.0EFF61A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: tabish Date: Wed May 30 14:00:11 2007 New Revision: 542931 URL: http://svn.apache.org/viewvc?view=rev&rev=542931 Log: http://issues.apache.org/activemq/browse/AMQCPP-103 Building Decaf lib Added: activemq/activemq-cpp/trunk/src/main/decaf/util/Date.cpp activemq/activemq-cpp/trunk/src/main/decaf/util/Date.h Added: activemq/activemq-cpp/trunk/src/main/decaf/util/Date.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/util/Date.cpp?view=auto&rev=542931 ============================================================================== --- activemq/activemq-cpp/trunk/src/main/decaf/util/Date.cpp (added) +++ activemq/activemq-cpp/trunk/src/main/decaf/util/Date.cpp Wed May 30 14:00:11 2007 @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#ifdef HAVE_SYS_TIME_H +#include +#endif + +#ifdef HAVE_SYS_TIMEB_H +#include +#endif + +#include + +using namespace stl; +using namespace decaf; +using namespace decaf::util; +using namespace decaf::lang::exceptions; + +//////////////////////////////////////////////////////////////////////////////// +long long Date::getCurrentTimeMilliseconds(){ + +#if defined (HAVE_GETTIMEOFDAY) + timeval tv; + gettimeofday (&tv, NULL); + return (tv.tv_sec * 1000LL) + (tv.tv_usec / 1000LL); +#elif defined (HAVE_TIME) + return time (NULL) * 1000LL; +#elif defined (HAVE_FTIME) + struct timeb t; + ftime (&t); + return (t.time * 1000LL) + t.millitm; +#else + + // This platform doesn't support any of the standard time methods + // ... should never get here. + #error "No current time function available on the local platform"; + +#endif +} + Added: activemq/activemq-cpp/trunk/src/main/decaf/util/Date.h URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/util/Date.h?view=auto&rev=542931 ============================================================================== --- activemq/activemq-cpp/trunk/src/main/decaf/util/Date.h (added) +++ activemq/activemq-cpp/trunk/src/main/decaf/util/Date.h Wed May 30 14:00:11 2007 @@ -0,0 +1,128 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _DECAF_UTIL_DATE_H_ +#define _DECAF_UTIL_DATE_H_ + +namespace activemq{ +namespace util{ + + /** + * Wrapper class around a time value in milliseconds. This + * class is comparable to Java's java.util.Date class. + */ + class Date + { + private: + + /** + * The underlying time value in milliseconds� + */ + long long time; + + public: + + /** + * Default constructor - sets time to now. + */ + Date(){ + time = getCurrentTimeMilliseconds(); + } + + /** + * Constructs the date with a given time value. + * @param milliseconds The time in milliseconds; + */ + Date( long long milliseconds ){ + this->time = milliseconds; + } + + /** + * Copy constructor. + */ + Date( const Date& source ){ + (*this) = source; + } + + virtual ~Date(){} + + /** + * Gets the underlying time. + * @return The underlying time value in milliseconds. + */ + long long getTime() const{ + return time; + } + + /** + * Sets the underlying time. + * @param milliseconds The underlying time value in + * milliseconds. + */ + void setTime( long long milliseconds ){ + this->time = milliseconds; + } + + /** + * Determines wether or not this date falls after the + * specified time. + * @param when The date to compare + * @return true if this date falls after when. + */ + bool after( Date& when ) const{ + return time > when.time; + } + + /** + * Determines wether or not this date falls before the + * specified time. + * @param when The date to compare + * @return true if this date falls before when. + */ + bool before( Date& when ) const{ + return time < when.time; + } + + /** + * Determines wether or not this date is equal to the + * specified time. + * @param when The date to compare + * @return true if this date is equal to when. + */ + bool equals( Date& when ) const{ + return time == when.time; + } + + /** + * Assignment operator. + */ + Date& operator =( const Date& source ){ + this->time = source.time; + return *this; + } + + /** + * Returns the current time in milliseconds. Comparable + * to Java's System.currentTimeMillis method. + * @return The current time in milliseconds. + */ + static long long getCurrentTimeMilliseconds(); + }; + +}} + +#endif /*_DECAF_UTIL_DATE_H_*/