[accounting] Add 'load chart' query (bug 86)
[abstract.git] / base / aaTransaction.cpp
blobf4368cd9cd733e83eaafcc4721d9f9dc2e8d7b0f
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 "xpcom-config.h"
24 #include "nsCOMPtr.h"
25 #include "nsEmbedString.h"
27 /* Project includes */
28 #include "aaIFact.h"
29 #include "aaIHandler.h"
30 #include "aaTransaction.h"
32 aaTransaction::aaTransaction()
33 :mTime(0),
34 mValue(0.0),
35 mEarnings(0.0),
36 mHasTime(PR_FALSE),
37 mHasEarnings(PR_FALSE),
38 mBroadcasting(PR_FALSE)
42 aaTransaction::~aaTransaction()
46 NS_IMPL_ISUPPORTS2(aaTransaction,
47 aaIDataNode,
48 aaITransaction)
50 /* aaIDataNode */
51 NS_IMETHODIMP
52 aaTransaction::GetId(PRInt64 *aId)
54 NS_ENSURE_ARG_POINTER(aId);
55 *aId = mId;
56 return NS_OK;
58 NS_IMETHODIMP
59 aaTransaction::SetId(PRInt64 aId)
61 mId = aId;
62 return NS_OK;
65 NS_IMETHODIMP
66 aaTransaction::Accept(aaIHandler* aQuery)
68 NS_ENSURE_ARG_POINTER(aQuery);
69 return aQuery->HandleTransaction(this);
72 NS_IMETHODIMP
73 aaTransaction::GetEdited(PRBool* aEdited)
75 NS_ENSURE_ARG_POINTER(aEdited);
76 *aEdited = PR_FALSE;
77 return NS_OK;
81 /* aaITransaction */
82 NS_IMETHODIMP
83 aaTransaction::GetFact(aaIFact * *aFact)
85 NS_ENSURE_ARG_POINTER( aFact );
86 NS_IF_ADDREF( *aFact = mFact );
87 return NS_OK;
89 NS_IMETHODIMP
90 aaTransaction::SetFact(aaIFact *aFact)
92 mFact = aFact;
93 return NS_OK;
95 aaIFact *
96 aaTransaction::PickFact()
98 return mFact;
101 NS_IMETHODIMP
102 aaTransaction::GetValue(double *aValue)
104 NS_ENSURE_ARG_POINTER( aValue );
105 *aValue = mValue;
106 return NS_OK;
108 NS_IMETHODIMP
109 aaTransaction::SetValue(double aValue)
111 mValue = aValue;
112 return NS_OK;
114 double
115 aaTransaction::PickValue()
117 return mValue;
120 NS_IMETHODIMP
121 aaTransaction::GetHasTime(PRBool *aHasTime)
123 NS_ENSURE_ARG_POINTER( aHasTime );
124 *aHasTime = mHasTime;
125 return NS_OK;
128 NS_IMETHODIMP
129 aaTransaction::GetTime(PRTime *aTime)
131 NS_ENSURE_TRUE( mHasTime, NS_ERROR_NOT_INITIALIZED);
132 NS_ENSURE_ARG_POINTER( aTime );
133 *aTime = mTime;
134 return NS_OK;
136 NS_IMETHODIMP
137 aaTransaction::SetTime(PRTime aTime)
139 mTime = aTime;
140 mHasTime = PR_TRUE;
141 return NS_OK;
144 NS_IMETHODIMP
145 aaTransaction::GetHasEarnings(PRBool *aHasEarnings)
147 NS_ENSURE_ARG_POINTER(aHasEarnings);
148 *aHasEarnings = mHasEarnings;
149 return NS_OK;
151 PRBool
152 aaTransaction::PickHasEarnings()
154 return mHasEarnings;
157 NS_IMETHODIMP
158 aaTransaction::GetEarnings(double *aEarnings)
160 NS_ENSURE_ARG_POINTER(aEarnings);
161 NS_ENSURE_TRUE(mHasEarnings, NS_ERROR_NOT_INITIALIZED);
162 *aEarnings = mEarnings;
163 return NS_OK;
165 NS_IMETHODIMP
166 aaTransaction::SetEarnings(double aEarnings)
168 mHasEarnings = PR_TRUE;
169 mEarnings = aEarnings;
170 return NS_OK;
172 double
173 aaTransaction::PickEarnings()
175 return mEarnings;