diff --git a/Firestore/core/src/api/firestore.cc b/Firestore/core/src/api/firestore.cc index 70cb975cc71..23152b5c444 100644 --- a/Firestore/core/src/api/firestore.cc +++ b/Firestore/core/src/api/firestore.cc @@ -227,6 +227,10 @@ void Firestore::SetClientLanguage(std::string language_token) { GrpcConnection::SetClientLanguage(std::move(language_token)); } +PipelineSource Firestore::pipeline() { + return {shared_from_this()}; +} + std::unique_ptr Firestore::AddSnapshotsInSyncListener( std::unique_ptr> listener) { EnsureClientConfigured(); diff --git a/Firestore/core/src/api/firestore.h b/Firestore/core/src/api/firestore.h index 9323b0a4e81..752c4fa568e 100644 --- a/Firestore/core/src/api/firestore.h +++ b/Firestore/core/src/api/firestore.h @@ -29,6 +29,7 @@ #include "Firestore/core/src/model/database_id.h" #include "Firestore/core/src/util/byte_stream.h" #include "Firestore/core/src/util/status_fwd.h" +#include "Firestore/core/swift/include/pipeline_source.h" namespace firebase { namespace firestore { @@ -125,6 +126,8 @@ class Firestore : public std::enable_shared_from_this { */ static void SetClientLanguage(std::string language_token); + PipelineSource pipeline(); + private: void EnsureClientConfigured(); core::DatabaseInfo MakeDatabaseInfo() const; diff --git a/Firestore/core/swift/include/FirebaseFirestoreCpp.h b/Firestore/core/swift/include/FirebaseFirestoreCpp.h index dd769230b8f..7738009bda2 100644 --- a/Firestore/core/swift/include/FirebaseFirestoreCpp.h +++ b/Firestore/core/swift/include/FirebaseFirestoreCpp.h @@ -17,6 +17,11 @@ #ifndef FIREBASE_FIREBASEFIRESTORECPP_H #define FIREBASE_FIREBASEFIRESTORECPP_H +#import "collection_stage.h" +#import "firestore_pipeline.h" +#import "pipeline.h" +#import "pipeline_source.h" +#import "stage.h" #import "used_by_swift.h" #endif // FIREBASE_FIREBASEFIRESTORECPP_H diff --git a/Firestore/core/swift/include/collection_stage.h b/Firestore/core/swift/include/collection_stage.h new file mode 100644 index 00000000000..2ffac6a132e --- /dev/null +++ b/Firestore/core/swift/include/collection_stage.h @@ -0,0 +1,29 @@ +// +// Created by Cheryl Lin on 2024-12-11. +// + +#ifndef FIREBASE_COLLECTION_GROUP_STAGE_H +#define FIREBASE_COLLECTION_GROUP_STAGE_H + +#include +#include "stage.h" + +namespace firebase { +namespace firestore { + +namespace api { + +class Collection : public Stage { + public: + Collection(std::string collection_path); + + private: + std::string collection_path_; +}; + +} // namespace api + +} // namespace firestore +} // namespace firebase + +#endif // FIREBASE_COLLECTION_GROUP_STAGE_H diff --git a/Firestore/core/swift/include/firestore_pipeline.h b/Firestore/core/swift/include/firestore_pipeline.h new file mode 100644 index 00000000000..6695d6a1b5f --- /dev/null +++ b/Firestore/core/swift/include/firestore_pipeline.h @@ -0,0 +1,25 @@ +// +// Created by Cheryl Lin on 2024-12-10. +// + +#ifndef FIREBASE_FIRESTORE_PIPELINE_H +#define FIREBASE_FIRESTORE_PIPELINE_H + +#include "pipeline_source.h" + +namespace firebase { +namespace firestore { + +namespace api { +class Firestore; + +class FirestorePipeline { + public: + PipelineSource pipeline(std::shared_ptr firestore); +}; + +} // namespace api +} // namespace firestore +} // namespace firebase + +#endif // FIREBASE_FIRESTORE_PIPELINE_H diff --git a/Firestore/core/swift/include/pipeline.h b/Firestore/core/swift/include/pipeline.h new file mode 100644 index 00000000000..4519d5371e1 --- /dev/null +++ b/Firestore/core/swift/include/pipeline.h @@ -0,0 +1,32 @@ +// +// Created by Cheryl Lin on 2024-12-11. +// + +#ifndef FIREBASE_PIPELINE_H +#define FIREBASE_PIPELINE_H + +#include +#include "stage.h" + +namespace firebase { +namespace firestore { + +namespace api { + +class Firestore; + +class Pipeline { + public: + Pipeline(std::shared_ptr firestore, Stage stage); + + private: + std::shared_ptr firestore_; + Stage stage_; +}; + +} // namespace api + +} // namespace firestore +} // namespace firebase + +#endif // FIREBASE_PIPELINE_H diff --git a/Firestore/core/swift/include/pipeline_source.h b/Firestore/core/swift/include/pipeline_source.h new file mode 100644 index 00000000000..a9d2d6f850a --- /dev/null +++ b/Firestore/core/swift/include/pipeline_source.h @@ -0,0 +1,35 @@ +// +// Created by Cheryl Lin on 2024-12-09. +// + +#ifndef FIREBASE_PIPELINE_SOURCE_H +#define FIREBASE_PIPELINE_SOURCE_H + +#include +#include +#include "pipeline.h" + +namespace firebase { +namespace firestore { + +namespace api { + +class Firestore; +class DocumentReference; + +class PipelineSource { + public: + PipelineSource(std::shared_ptr firestore); + + Pipeline GetCollection(std::string collection_path); + + private: + std::shared_ptr firestore_; +}; + +} // namespace api + +} // namespace firestore +} // namespace firebase + +#endif // FIREBASE_PIPELINE_SOURCE_H diff --git a/Firestore/core/swift/include/stage.h b/Firestore/core/swift/include/stage.h new file mode 100644 index 00000000000..3ff02f7ff4f --- /dev/null +++ b/Firestore/core/swift/include/stage.h @@ -0,0 +1,23 @@ +// +// Created by Cheryl Lin on 2024-12-11. +// + +#ifndef FIREBASE_STAGE_H +#define FIREBASE_STAGE_H + +namespace firebase { +namespace firestore { + +namespace api { + +class Stage { + public: + Stage(); +}; + +} // namespace api + +} // namespace firestore +} // namespace firebase + +#endif // FIREBASE_STAGE_H diff --git a/Firestore/core/swift/src/collection_stage.cc b/Firestore/core/swift/src/collection_stage.cc new file mode 100644 index 00000000000..cf05216b067 --- /dev/null +++ b/Firestore/core/swift/src/collection_stage.cc @@ -0,0 +1,17 @@ +#include "Firestore/core/swift/include/collection_stage.h" +#include + +namespace firebase { +namespace firestore { + +namespace api { + +Collection::Collection(std::string collection_path) + : collection_path_(collection_path) { + std::cout << "Calling Pipeline Collection ctor" << std::endl; +}; + +} // namespace api + +} // namespace firestore +} // namespace firebase \ No newline at end of file diff --git a/Firestore/core/swift/src/firestore_pipeline.cc b/Firestore/core/swift/src/firestore_pipeline.cc new file mode 100644 index 00000000000..f1711d8725d --- /dev/null +++ b/Firestore/core/swift/src/firestore_pipeline.cc @@ -0,0 +1,16 @@ +#include "Firestore/core/swift/include/firestore_pipeline.h" +#include "Firestore/core/src/api/firestore.h" + +namespace firebase { +namespace firestore { + +namespace api { + +PipelineSource FirestorePipeline::pipeline( + std::shared_ptr firestore) { + return firestore->pipeline(); +} + +} // namespace api +} // namespace firestore +} // namespace firebase \ No newline at end of file diff --git a/Firestore/core/swift/src/pipeline.cc b/Firestore/core/swift/src/pipeline.cc new file mode 100644 index 00000000000..070cb635d3a --- /dev/null +++ b/Firestore/core/swift/src/pipeline.cc @@ -0,0 +1,17 @@ +#include "Firestore/core/swift/include/pipeline.h" +#include +#include "Firestore/core/src/api/firestore.h" + +namespace firebase { +namespace firestore { + +namespace api { + +Pipeline::Pipeline(std::shared_ptr firestore, Stage stage) + : firestore_(firestore), stage_(stage) { +} + +} // namespace api + +} // namespace firestore +} // namespace firebase \ No newline at end of file diff --git a/Firestore/core/swift/src/pipeline_source.cc b/Firestore/core/swift/src/pipeline_source.cc new file mode 100644 index 00000000000..2157b001132 --- /dev/null +++ b/Firestore/core/swift/src/pipeline_source.cc @@ -0,0 +1,23 @@ + +#include "Firestore/core/swift/include/pipeline_source.h" +#include "Firestore/core/src/api/document_reference.h" +#include "Firestore/core/src/api/firestore.h" +#include "Firestore/core/swift/include/collection_stage.h" + +namespace firebase { +namespace firestore { + +namespace api { + +PipelineSource::PipelineSource(std::shared_ptr firestore) + : firestore_(firestore) { +} + +Pipeline PipelineSource::GetCollection(std::string collection_path) { + return {firestore_, Collection{collection_path}}; +} + +} // namespace api + +} // namespace firestore +} // namespace firebase \ No newline at end of file diff --git a/Firestore/core/swift/src/stage.cc b/Firestore/core/swift/src/stage.cc new file mode 100644 index 00000000000..f5d387655a0 --- /dev/null +++ b/Firestore/core/swift/src/stage.cc @@ -0,0 +1,14 @@ +#include "Firestore/core/swift/include/stage.h" + +namespace firebase { +namespace firestore { + +namespace api { + +Stage::Stage() { +} + +} // namespace api + +} // namespace firestore +} // namespace firebase \ No newline at end of file diff --git a/Package.swift b/Package.swift index 5a2b73deccf..49ad22fd3be 100644 --- a/Package.swift +++ b/Package.swift @@ -1408,9 +1408,17 @@ func firestoreWrapperTarget() -> Target { func firebaseFirestoreCppTarget() -> Target { return .target( name: "FirebaseFirestoreCpp", + dependencies: [ + "FirebaseAppCheckInterop", + "FirebaseCore", + "leveldb", + .product(name: "nanopb", package: "nanopb"), + ], path: "Firestore/core/swift", publicHeadersPath: "include", // Path to the public headers cxxSettings: [ + .headerSearchPath("../../../"), + .headerSearchPath("../../Protos/nanopb"), .headerSearchPath("include"), // Ensure the header search path is correct ] ) @@ -1449,6 +1457,7 @@ func firestoreTargets() -> [Target] { "core/CMakeLists.txt", "core/src/util/config_detected.h.in", "core/test/", + "core/swift/", "fuzzing/", "test.sh", // Swift PM doesn't recognize hpp files, so we're relying on search paths