6 double initial_balance,
9 , name_(std::move(name))
10 , routing_tag_(std::move(routing_tag))
11 , balance_(initial_balance)
12 , initial_balance_(initial_balance)
13 , schedule_(schedule) {
59 if (target_account.empty()) {
68 if (amount <= 0)
return;
74 if (amount <= 0)
return;
SubscriptionId income_sub_
virtual void on_income(const IncomeEvent &event)
Called when an income event is routed to this account.
SubscriptionId expense_sub_
void reset() override
Reset model to initial state (for replay)
void deposit(SimTime time, double amount, const std::string &reason)
Deposit funds into the account.
bool should_handle_event(const std::string &target_account) const
void update(SimTime time) override
void emit(SimTime time, Args &&... args)
AccountBase(std::string id, std::string name, std::string routing_tag, double initial_balance=0.0, Schedule schedule=make_account_schedule())
virtual void on_expense(const ExpenseEvent &event)
Called when an expense event is routed to this account.
void withdraw(SimTime time, double amount, const std::string &reason)
Withdraw funds from the account.
void initialize(EventBus &bus) override
SubscriptionId subscribe(std::function< void(const EventType &)> callback)
void unsubscribe(SubscriptionId id)
Unsubscribe using subscription ID.
Event emitted when an expense occurs.
Event emitted when income is received.
double SimTime
Represents a point in simulation time (continuous, in days)