1515#ifndef FIRESTORE_CORE_INTERFACEFORSWIFT_API_PIPELINE_RESULT_H_
1616#define FIRESTORE_CORE_INTERFACEFORSWIFT_API_PIPELINE_RESULT_H_
1717
18+ #include < atomic>
19+ #include < iostream>
1820#include < memory>
1921
2022namespace firebase {
@@ -28,16 +30,55 @@ namespace api {
2830class Firestore ;
2931class DocumentReference ;
3032
33+ extern std::atomic<int > next_id;
34+
3135class PipelineResult {
3236 public:
3337 PipelineResult (std::shared_ptr<Firestore> firestore,
3438 std::shared_ptr<Timestamp> execution_time,
3539 std::shared_ptr<Timestamp> update_time,
3640 std::shared_ptr<Timestamp> create_time);
3741
42+ // Copy constructor
43+ PipelineResult (const PipelineResult& other)
44+ : id_(next_id.fetch_add(1 )),
45+ firestore_ (other.firestore_),
46+ execution_time_(other.execution_time_),
47+ update_time_(other.update_time_),
48+ create_time_(other.create_time_) {
49+ std::cout << " zzyzx PipelineResult[" << id_ << " ]@"
50+ << reinterpret_cast <std::uintptr_t >(this )
51+ << " (const PipelineResult&) other.id=" << other.id_ << std::endl;
52+ long n = execution_time_.use_count ();
53+ std::cout << " Calling copy ctor when refer count is:" << n << std::endl;
54+ }
55+
56+ // Copy assignment operator
57+ PipelineResult& operator =(const PipelineResult& other) {
58+ std::cout << " zzyzx PipelineResult[" << id_ << " ]@"
59+ << reinterpret_cast <std::uintptr_t >(this )
60+ << " .operator=(const PipelineResult&) other.id_=" << other.id_
61+ << std::endl;
62+ if (this != &other) {
63+ firestore_ = other.firestore_ ;
64+ execution_time_ = other.execution_time_ ;
65+ update_time_ = other.update_time_ ;
66+ create_time_ = other.create_time_ ;
67+ }
68+ return *this ;
69+ }
70+
3871 static PipelineResult GetTestResult (std::shared_ptr<Firestore> firestore);
3972
40- private:
73+ ~PipelineResult () {
74+ std::cout << " zzyzx PipelineResult[" << id_ << " ]@"
75+ << reinterpret_cast <std::uintptr_t >(this ) << " ~PipelineResult()"
76+ << std::endl;
77+ long n = execution_time_.use_count ();
78+ std::cout << " Calling destructor when refer count is:" << n << std::endl;
79+ }
80+
81+ int id_;
4182 std::shared_ptr<Firestore> firestore_;
4283 std::shared_ptr<Timestamp> execution_time_;
4384 std::shared_ptr<Timestamp> update_time_;
0 commit comments