[xpunit] Rename from 'cxxunit' and switch to mozbuild (bug #114)
[abstract.git] / base / aaTransaction.cpp
blob9da63f98445fb7a4726921401d62009a16c01bc5
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 sts=2 et cindent tw=79 ft=cpp: */
3 /*
4 * Copyright (C) 2007 Sergey Yanovich <ynvich@gmail.com>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public
17 * License along with this program; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
22 #include <abstract/aacore.h>
24 #include "nsCOMPtr.h"
25 #include "nsEmbedString.h"
27 /* Project includes */
28 #include <abstract/base/aaIFact.h>
29 #include <abstract/base/aaITransaction.h>
30 #include <abstract/base/aaIHandler.h>
31 #include "aaTransaction.h"
33 aaTransaction::aaTransaction()
34 :mTime(0),
35 mValue(0.0),
36 mEarnings(0.0),
37 mHasTime(PR_FALSE),
38 mHasEarnings(PR_FALSE),
39 mBroadcasting(PR_FALSE)
43 aaTransaction::~aaTransaction()
47 NS_IMPL_ISUPPORTS2(aaTransaction,
48 aaIDataNode,
49 aaITransaction)
51 /* aaIDataNode */
52 NS_IMETHODIMP
53 aaTransaction::GetId(PRInt64 *aId)
55 NS_ENSURE_ARG_POINTER(aId);
56 *aId = mId;
57 return NS_OK;
59 NS_IMETHODIMP
60 aaTransaction::SetId(PRInt64 aId)
62 mId = aId;
63 return NS_OK;
66 NS_IMETHODIMP
67 aaTransaction::Accept(aaIHandler* aQuery)
69 NS_ENSURE_ARG_POINTER(aQuery);
70 return aQuery->HandleTransaction(this);
73 NS_IMETHODIMP
74 aaTransaction::GetEdited(PRBool* aEdited)
76 NS_ENSURE_ARG_POINTER(aEdited);
77 *aEdited = PR_FALSE;
78 return NS_OK;
82 /* aaITransaction */
83 NS_IMETHODIMP
84 aaTransaction::GetFact(aaIFact * *aFact)
86 NS_ENSURE_ARG_POINTER( aFact );
87 NS_IF_ADDREF( *aFact = mFact );
88 return NS_OK;
90 NS_IMETHODIMP
91 aaTransaction::SetFact(aaIFact *aFact)
93 mFact = aFact;
94 return NS_OK;
96 aaIFact *
97 aaTransaction::PickFact()
99 return mFact;
102 NS_IMETHODIMP
103 aaTransaction::GetValue(double *aValue)
105 NS_ENSURE_ARG_POINTER( aValue );
106 *aValue = mValue;
107 return NS_OK;
109 NS_IMETHODIMP
110 aaTransaction::SetValue(double aValue)
112 mValue = aValue;
113 return NS_OK;
115 double
116 aaTransaction::PickValue()
118 return mValue;
121 NS_IMETHODIMP
122 aaTransaction::GetHasTime(PRBool *aHasTime)
124 NS_ENSURE_ARG_POINTER( aHasTime );
125 *aHasTime = mHasTime;
126 return NS_OK;
129 NS_IMETHODIMP
130 aaTransaction::GetTime(PRTime *aTime)
132 NS_ENSURE_TRUE( mHasTime, NS_ERROR_NOT_INITIALIZED);
133 NS_ENSURE_ARG_POINTER( aTime );
134 *aTime = mTime;
135 return NS_OK;
137 NS_IMETHODIMP
138 aaTransaction::SetTime(PRTime aTime)
140 mTime = aTime;
141 mHasTime = PR_TRUE;
142 return NS_OK;
145 NS_IMETHODIMP
146 aaTransaction::GetHasEarnings(PRBool *aHasEarnings)
148 NS_ENSURE_ARG_POINTER(aHasEarnings);
149 *aHasEarnings = mHasEarnings;
150 return NS_OK;
152 PRBool
153 aaTransaction::PickHasEarnings()
155 return mHasEarnings;
158 NS_IMETHODIMP
159 aaTransaction::GetEarnings(double *aEarnings)
161 NS_ENSURE_ARG_POINTER(aEarnings);
162 NS_ENSURE_TRUE(mHasEarnings, NS_ERROR_NOT_INITIALIZED);
163 *aEarnings = mEarnings;
164 return NS_OK;
166 NS_IMETHODIMP
167 aaTransaction::SetEarnings(double aEarnings)
169 mHasEarnings = PR_TRUE;
170 mEarnings = aEarnings;
171 return NS_OK;
173 double
174 aaTransaction::PickEarnings()
176 return mEarnings;