From 48aad934ae19a7cc937457957d37d04965159aec Mon Sep 17 00:00:00 2001 From: Sergey Yanovich Date: Sat, 13 Oct 2007 20:54:54 +0300 Subject: [PATCH] [base] Implement 'quote' --- abstract/base/aaIQuote.idl | 2 +- base/Makefile.am | 1 + base/aaBaseModule.cpp | 9 ++ base/aaQuote.cpp | 119 +++++++++++++++++++++++++++ abstract/base/aaIQuote.idl => base/aaQuote.h | 34 ++++++-- 5 files changed, 156 insertions(+), 9 deletions(-) create mode 100644 base/aaQuote.cpp copy abstract/base/aaIQuote.idl => base/aaQuote.h (60%) diff --git a/abstract/base/aaIQuote.idl b/abstract/base/aaIQuote.idl index 7c75255..3e30877 100644 --- a/abstract/base/aaIQuote.idl +++ b/abstract/base/aaIQuote.idl @@ -24,7 +24,7 @@ interface aaIObject; [scriptable, uuid(6b06cb14-aacd-4f12-816c-4db80c32115a)] -interface aaIQuote : nsISupports +interface aaIQuote : aaIDataNode { attribute aaIObject object; attribute PRTime time; diff --git a/base/Makefile.am b/base/Makefile.am index 654ffa5..584af49 100644 --- a/base/Makefile.am +++ b/base/Makefile.am @@ -24,6 +24,7 @@ MODULE_CPPSRC = \ aaFact.cpp \ aaState.cpp \ aaEvent.cpp \ + aaQuote.cpp \ aaTransaction.cpp if AA_ENABLE_TESTS diff --git a/base/aaBaseModule.cpp b/base/aaBaseModule.cpp index f6d7752..9419d22 100644 --- a/base/aaBaseModule.cpp +++ b/base/aaBaseModule.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include "aaEntity.h" #include "aaObject.h" @@ -42,6 +43,7 @@ #include "aaFact.h" #include "aaState.h" #include "aaEvent.h" +#include "aaQuote.h" #include "aaTransaction.h" NS_GENERIC_FACTORY_CONSTRUCTOR_PARAM(aaEntity) @@ -50,6 +52,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(aaFlow) NS_GENERIC_FACTORY_CONSTRUCTOR(aaFact) NS_GENERIC_FACTORY_CONSTRUCTOR(aaState) NS_GENERIC_FACTORY_CONSTRUCTOR(aaEvent) +NS_GENERIC_FACTORY_CONSTRUCTOR(aaQuote) NS_GENERIC_FACTORY_CONSTRUCTOR(aaTransaction) static const nsModuleComponentInfo components[] = @@ -91,6 +94,12 @@ static const nsModuleComponentInfo components[] = aaEventConstructor } ,{ + "Quote", + AA_QUOTE_CID, + AA_QUOTE_CONTRACT_ID, + aaQuoteConstructor + } + ,{ "Transaction", AA_TRANSACTION_CID, AA_TRANSACTION_CONTRACT_ID, diff --git a/base/aaQuote.cpp b/base/aaQuote.cpp new file mode 100644 index 0000000..a6d67e6 --- /dev/null +++ b/base/aaQuote.cpp @@ -0,0 +1,119 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim:set ts=2 sw=2 sts=2 et cindent tw=79 ft=cpp: */ +/* + * Copyright (C) 2007 Sergey Yanovich + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include + +#include "nsCOMPtr.h" + +/* Project includes */ +#include +#include +#include +#include "aaQuote.h" + +aaQuote::aaQuote() + :mHasTime(PR_FALSE) + +{ +} + +aaQuote::~aaQuote() +{ +} + +NS_IMPL_ISUPPORTS2(aaQuote, + aaIDataNode, + aaIQuote) +/* aaIDataNode */ +NS_IMETHODIMP +aaQuote::GetId(PRInt64 *aId) +{ + NS_ENSURE_ARG_POINTER(aId); + *aId = mId; + return NS_OK; +} +NS_IMETHODIMP +aaQuote::SetId(PRInt64 aId) +{ + mId = aId; + return NS_OK; +} + +NS_IMETHODIMP +aaQuote::Accept(aaIQuery* aQuery) +{ + NS_ENSURE_ARG_POINTER(aQuery); + return NS_ERROR_NOT_IMPLEMENTED;//aQuery->QueryQuote(this); +} + +NS_IMETHODIMP +aaQuote::GetEdited(PRBool* aEdited) +{ + NS_ENSURE_ARG_POINTER(aEdited); + *aEdited = PR_FALSE; + return NS_OK; +} + +/* aaIQuote */ +NS_IMETHODIMP +aaQuote::GetObject(aaIObject ** aObject) +{ + NS_ENSURE_ARG_POINTER(aObject); + NS_IF_ADDREF(*aObject = mObject); + return NS_OK; +} +NS_IMETHODIMP +aaQuote::SetObject(aaIObject * aObject) +{ + mObject = aObject; + return NS_OK; +} + +NS_IMETHODIMP +aaQuote::GetTime(PRTime *aTime) +{ + NS_ENSURE_TRUE( mHasTime, NS_ERROR_NOT_INITIALIZED); + NS_ENSURE_ARG_POINTER( aTime ); + *aTime = mTime; + return NS_OK; +} +NS_IMETHODIMP +aaQuote::SetTime(PRTime aTime) +{ + mTime = aTime; + mHasTime = PR_TRUE; + return NS_OK; +} + +NS_IMETHODIMP +aaQuote::GetRate(double *aRate) +{ + NS_ENSURE_ARG_POINTER(aRate); + *aRate = mRate; + return NS_OK; +} +NS_IMETHODIMP +aaQuote::SetRate(double aRate) +{ + mRate = aRate; + return NS_OK; +} + diff --git a/abstract/base/aaIQuote.idl b/base/aaQuote.h similarity index 60% copy from abstract/base/aaIQuote.idl copy to base/aaQuote.h index 7c75255..d3c6311 100644 --- a/abstract/base/aaIQuote.idl +++ b/base/aaQuote.h @@ -1,5 +1,5 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim:set ts=2 sw=2 sts=2 et cindent tw=79 ft=idl: */ +/* vim:set ts=2 sw=2 sts=2 et cindent tw=79 ft=cpp: */ /* * Copyright (C) 2007 Sergey Yanovich * @@ -19,15 +19,33 @@ * Boston, MA 02111-1307, USA. */ -#include "aaIDataNode.idl" +#ifndef AAQUOTE_H +#define AAQUOTE_H 1 -interface aaIObject; +#define AA_QUOTE_CID \ +{0xda135703, 0xc181, 0x4e7d, {0x9f, 0x97, 0xe4, 0x3c, 0x50, 0xa6, 0xb5, 0x1a}} +#define AA_QUOTE_CONTRACT_ID "@aasii.org/base/quote;1" -[scriptable, uuid(6b06cb14-aacd-4f12-816c-4db80c32115a)] -interface aaIQuote : nsISupports +class aaIFact; + +class aaQuote : public aaIQuote { - attribute aaIObject object; - attribute PRTime time; - attribute double rate; +public: + aaQuote(); + virtual ~aaQuote(); + NS_DECL_ISUPPORTS + NS_DECL_AAIDATANODE + NS_DECL_AAIQUOTE + +private: + friend class aaBaseTest; + + PRInt64 mId; + nsCOMPtr mObject; + PRTime mTime; + PRBool mHasTime; + double mRate; }; +#endif /* AAQUOTE_H */ + -- 2.11.4.GIT