Skip to content

Commit

Permalink
Firestore project: Import of API interfaces.
Browse files Browse the repository at this point in the history
--
197713382 by zxu <zxu>:

Implement more on listener class and implement ListenerRegistration.

TESTED:
blaze test //sensored/testapp:testapp_build_test
blaze test //sensored/testapp:testapp_build_test --config=android_x86
blaze test //sensored/testapp:android_testapp_test --config=android_x86 --define firebase_build=stable
blaze test //sensored/cpp:firestore_kokoro
blaze test //sensored/cpp:listener_registration_test
--
196551381 by zxu <zxu>:

Implement more on listener class and implement the DocumentReference::AddSnapshotListener.

Also added a few test case and fixed a bug in DocumentReferenceInternal.

ListenerRegistration will be implemented in subsequent CL.

TESTED:
blaze test //sensored/testapp:testapp_build_test
blaze test //sensored/testapp:testapp_build_test --config=android_x86
blaze test //sensored/testapp:android_testapp_test --config=android_x86 --define firebase_build=stable
blaze test //sensored/cpp:firestore_kokoro
blaze test //sensored/cpp:firestore_test
--
196276752 by zxu <zxu>:

Implement the SnapshotMetadata with inline methods and (non-)Wrapper for Firestore C++.

TESTED:
blaze test //sensored/testapp:testapp_build_test
blaze test //sensored/testapp:testapp_build_test --config=android_x86
blaze test //sensored/testapp:android_testapp_test --config=android_x86 --experimental_one_version_enforcement=warning
blaze test //sensored/cpp:firestore_kokoro
blaze test //sensored/cpp:firestore_test
--
195841793 by zxu <zxu>:

Implement the wrapper class for callback (EventListener).

People unlike huge CL. So sending this short one for review. In subsequent CLs, I'll do:
*   cache/uncache or the CppEventListener class and the wiring of native method;
*   actually using this to implement DocumentReference::AddSnapshotListener;
*   update the testapp to run android_test with callback.
--
194112388 by zxu <zxu>:

Add Android-Wrapper for DocumentReference's non-callback methods.

Tested:
blaze test //sensored/testapp:testapp_build_test
blaze test //sensored/testapp:testapp_build_test --config=android_x86
blaze test //sensored/cpp:firestore_kokoro
blaze test //sensored/cpp:firestore_test
--
192445183 by zxu <zxu>:

Add Android-Wrapper for Firestore's remaining methods.
Tested:
blaze test //sensored/testapp:testapp_build_test
blaze test //sensored/testapp:testapp_build_test --config=android_x86
blaze test //sensored/cpp:firestore_kokoro
blaze test //sensored/cpp:firestore_test
--
190986604 by mcg <mcg>:

Manually import the public portion of

  - 22c226a C++ migration: make Timestamp class a part of public API ... by Konstantin Varlamov <var-const@users.noreply.github.com>

Note that this only imports the header, which otherewise won't come over with a
regular copybara run because we're currently excluding the public headers from
the Firestore import with cl/188810622.

The .cc implementation of this will come over with a regular copybara import,
coming shortly.
--
189013767 by zxu <zxu>:

Add Android-Wrapper for Firestore's method that does not involve other Firestore types.
Tested:
blaze test //sensored/testapp:testapp_build_test
blaze test //sensored/testapp:testapp_build_test --config=android_x86
blaze test //sensored/cpp:firestore_kokoro
--
188809445 by mcg <mcg>:

Import of firebase-ios-sdk from Github.

  - 07f4695 Updates Changelog for 4.5.0 release (firebase#908) by Zsika Phillip <protocol86@users.noreply.github.com>
  - 2b82a2e Allow serializing arbitrary length FieldValues (firebase#889) by rsgowman <rgowman>
  - 3e41f25 Fix test failures that occur during prod build (firebase#910) by rsgowman <rgowman>
  - f122cf7 Fix MutationQueue issue resulting in re-sending acknowled... by Michael Lehenbauer <mikelehen@gmail.com>
  - 7522314 Partial wrapping of pb_ostream_t (pt2) (firebase#903) by rsgowman <rgowman>
  - 0d3adb1 Partial wrapping of pb_ostream_t (pt1) (firebase#899) by rsgowman <rgowman>
  - e41f4b1 Merge Release 4.10.1 into Master (firebase#896) by zxu <zxu>
  - 2ae36f1 [De]Serialize FieldValue map_values ("Objects") (firebase#878) by rsgowman <rgowman>
  - 5930ad2 Factor out a universal build script (firebase#884) by Gil <mcg>
  - 8ef0f14 Adds Email link sign-in (firebase#882) by Paul Beusterien <paulbeusterien>
  - 0b8f216 Merge pull request firebase#880 from firebase/release-4.10.0 by Paul Beusterien <paulbeusterien>
  - 8311c64 port paths to FSTDocumentKey (firebase#877) by zxu <zxu>
  - 34ebf10 Add 10 second timeout waiting for connection before clien... by Michael Lehenbauer <mikelehen@gmail.com>
  - 1c40e7a add converters and port paths to FSTQuery (firebase#869) by zxu <zxu>
  - 9b5b4d8 Serialize (and deserialize) string values (firebase#864) by rsgowman <rgowman>
  - c6f73f7 Fix the issue completion handler is not triggered in subs... by Chen Liang <chliang>
  - 1ecf690 Add FieldValue.boolean_value() (firebase#862) by rsgowman <rgowman>
  - 3e7c062 replacing Auth by C++ auth implementation (firebase#802) by zxu <zxu>
  - 13aeb61 Eliminate TypedValue and serialize direct from FieldValue... by rsgowman <rgowman>
--
187049498 by mcg <mcg>:

Import of firebase-ios-sdk from Github.

  - f7d9f29 Fix lint warnings (firebase#840) by Gil <mcg>
  - b5c60ad Refactor [En|De]codeVarint to be symetric wrt tags (firebase#837) by rsgowman <rgowman>
  - ddc12c0 Merge pull request firebase#694 from morganchen12/auth-docs by Morgan Chen <morganchen12@gmail.com>
  - 442d46f Avoid warnings about failing to override a designated ini... by Gil <mcg>
  - 4dc63f8 Fix Firestore tests for M22 (firebase#834) by Gil <mcg>
  - 935f3ca  Avoid wrapping and rewrapping NSStrings when constructin... by Gil <mcg>
  - 6ce954a Serialize (and deserialize) int64 values (firebase#818) (firebase#829) by rsgowman <rgowman>
  - 41dcd4b Fix trivial mem leak in the test suite (firebase#828) by rsgowman <rgowman>
  - 50f9df9 Accept FIRTimestamp where NSDate is currently accepted as... by Konstantin Varlamov <var-const@users.noreply.github.com>
  - 67b068e Fix implicit retain self warnings (firebase#808) by rsgowman <rgowman>
  - 14ea068 Make FSTTimestamp into a public Firestore class (firebase#698) by Konstantin Varlamov <var-const@users.noreply.github.com>
  - de00de2 [En|De]codeUnsignedVarint -> [En|De]codeVarint (firebase#817) by rsgowman <rgowman>
  - 9bf73ab Fix two stream close issues (b/73167987, b/73382103). (firebase#8... by Michael Lehenbauer <mikelehen@gmail.com>
  - 7a4a2ea replacing FSTGetTokenResult by C++ Token implementation (... by zxu <zxu>
  - a9f3f35 Delete stale Firestore instances after FIRApp is deleted.... by Ryan Wilson <wilsonryan>
  - aa6f1ae Disable -Wrange-loop-analysis for abseil (firebase#807) by rsgowman <rgowman>
  - ef55eef Require official 1.4.0 for min CocoaPods version (firebase#806) by Paul Beusterien <paulbeusterien>
  - 7cddb97 Serialize (and deserialize) bool values (firebase#791) by rsgowman <rgowman>
  - 7a97f6c Enable -Wcomma for our build; disable it for abseil. (firebase#799) by rsgowman <rgowman>
  - 81ee594 DispatchQueue delayed callback improvements + testing (firebase#7... by Michael Lehenbauer <mikelehen@gmail.com>
  - fd9fd27 replacing Auth/FSTUser by C++ auth implementation (firebase#804) by zxu <zxu>
  - 6889850 Merge pull request firebase#801 from firebase/release-4.9.0 by Paul Beusterien <paulbeusterien>
  - e4be254 Fixed capitalization of init in test function. (firebase#797) by Ryan Wilson <wilsonryan>
  - 933be73 Improve documentation on auto-init property in FCM. (firebase#792) by Chen Liang <chliang>
  - 0f3c24b Actually ignore events on inactive streams, rather than j... by Greg Soltis <gsoltis>
  - fe19fca Serialize and deserialize null (firebase#783) by rsgowman <rgowman>
  - 95d0411 fix flaky test (firebase#788) by zxu <zxu>
  - b6613bd Cleaning up implicit retain for the RTDB and Storage by Sebastian Schmidt <mrschmidt>
  - 5f5f808 Keep track of number of queries in the query cache (firebase#776) by Greg Soltis <gsoltis>
  - c7c51a7 Fix double parsing on 32 bit devices. (firebase#787) by Ryan Wilson <wilsonryan>
  - 9504582 Port Firestore Document to C++ (firebase#777) by zxu <zxu>
  - adf9fb3 Update FieldValue of type Reference (firebase#775) by zxu <zxu>
  - 4afcfb1 Move to explicit nil check. (firebase#782) by Ryan Wilson <wilsonryan>
  - fd83e07 Strawman C++ API (firebase#763) by rsgowman <rgowman>
  - 8003348 C++ port: add C++ equivalent of FSTDocumentKey. (firebase#762) by Konstantin Varlamov <var-const@users.noreply.github.com>
  - 612d99c Fix Core CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF warnings (#... by Paul Beusterien <paulbeusterien>
  - bf45a15 port Firestore SnapshotVersion in C++ (firebase#767) by zxu <zxu>
  - d70c23e port Firestore Auth module in C++ (firebase#733) by zxu <zxu>
  - 633eb7b Let Travis run for `CMake` test and `lint.sh` (firebase#769) by zxu <zxu>
  - 274fe52 cmake build fixes (firebase#770) by rsgowman <rgowman>
--
184568931 by mcg <mcg>:

Import of firebase-ios-sdk from Github.

  - 32266c5 Make sure Firestore/core/include is in the podspec (firebase#748) by Gil <mcg>
  - 070c0ea Merge pull request firebase#746 from morganchen12/unguarded-block by Morgan Chen <morganchen12@gmail.com>
  - 13f572e Increase expectation timeout to 25 seconds. (firebase#744) by Michael Lehenbauer <mikelehen@gmail.com>
  - 47d81fd fix (firebase#739) by Chen Liang <chliang>
  - 515625c Remove predecessorKey,Object,Document, etc (firebase#735) by Gil <mcg>
  - ac30522 Start on ArraySortedMap in C++ (firebase#721) by Gil <mcg>
  - 729b8d1 Move all Firestore Objective-C to Objective-C++ (firebase#734) by Gil <mcg>
  - 693d064 Merge pull request firebase#732 from OleksiyA/FCM-subscribe-compl... by Oleksiy Ivanov <oleksiy@informationrd.com>
  - 3cbdbf2 Schema migrations for LevelDB (firebase#728) by Greg Soltis <gsoltis>
  - 6474a82 Firestore DatabaseId in C++ (firebase#727) by zxu <zxu>
  - 05ef5ae Add absl_strings to firebase_firestore_util_test dependen... by rsgowman <rgowman>
  - 03a0069 Add changelog entry for my last PR (oops) and also add a ... by Michael Lehenbauer <mikelehen@gmail.com>
  - 5a280ca  Import iterator_adaptors from google3 (firebase#718) by Gil <mcg>
  - 63a380b Use fixed-sized types (firebase#719) by Gil <mcg>
  - 6dc1373 Version updates to 4.8.2 (firebase#722) by Paul Beusterien <paulbeusterien>
  - a74d39f Fix a number of c++ build errors (firebase#715) by rsgowman <rgowman>
  - cceeec3 travis: check for copyright in sources (firebase#717) by Paul Beusterien <paulbeusterien>
  - 4d7c973 Fix b/72502745: OnlineState changes cause limbo document ... by Michael Lehenbauer <mikelehen@gmail.com>
  - af6976a normalize and port the rest of Firebase/Port code (firebase#713) by zxu <zxu>
  - 7226b4a port TargetIdGenerator to iOS (firebase#709) by zxu <zxu>
  - 5306474 adding unit test for auto init enable function (firebase#710) by Chen Liang <chliang>
  - 821fb90 implement `TargetIdGenerator` in C++ for Firestore (firebase#701) by zxu <zxu>
  - 5fdda3f normalize string_util (firebase#708) by zxu <zxu>
  - 15a2926 Update CHANGELOG for M21.1 release (firebase#679) by Ryan Wilson <wilsonryan>
  - f027214 Fix incorrect deprecation message (firebase#688) by Iulian Onofrei <6d0847b9@opayq.com>
  - bfa0e40 Implement the rest of FieldValue types for C++ (firebase#687) by zxu <zxu>
  - 1f77212 Properly publish Abseil sources as a part of the podspec ... by Gil <mcg>

ORIGINAL_AUTHOR=Firebase <firebase-noreply>
PiperOrigin-RevId: 197713382
  • Loading branch information
Firebase authored and zxu123 committed May 23, 2018
1 parent 2593e20 commit ec72ca8
Show file tree
Hide file tree
Showing 19 changed files with 650 additions and 89 deletions.
2 changes: 1 addition & 1 deletion Firestore/core/include/firebase/firestore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Hack to make the headers show up in IDEs
# feature to make the headers show up in IDEs
# (see https://stackoverflow.com/questions/27039019/ and open issue on CMake
# issue tracker: https://gitlab.kitware.com/cmake/cmake/issues/15234)
add_custom_target(firebase_firestore_types_ide SOURCES
Expand Down
98 changes: 98 additions & 0 deletions Firestore/core/include/firebase/firestore/collection_reference.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
* Copyright 2018 Google
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef FIRESTORE_CORE_INCLUDE_FIREBASE_FIRESTORE_COLLECTION_REFERENCE_H_
#define FIRESTORE_CORE_INCLUDE_FIREBASE_FIRESTORE_COLLECTION_REFERENCE_H_

namespace firebase {
namespace firestore {

class CollectionReferenceInternal;
class FirestoreInternal;

/**
* A CollectionReference refers to a collection of documents location in a
* Firestore database and can be used for adding documents, getting document
* references, and querying for documents.
*/
// TODO(zxu123): add more methods to complete the class and make it useful.
class CollectionReference {
public:
/**
* @brief Default constructor. This creates an invalid CollectionReference.
* Attempting to perform any operations on this reference will fail unless a
* valid CollectionReference has been assigned to it.
*/
CollectionReference();

/**
* @brief Copy constructor. It's totally okay (and efficient) to copy
* CollectionReference instances, as they simply point to the same location in
* the database.
*
* @param[in] reference CollectionReference to copy from.
*/
CollectionReference(const CollectionReference& reference);

/**
* @brief Move constructor. Moving is an efficient operation for
* CollectionReference instances.
*
* @param[in] reference CollectionReference to move data from.
*/
CollectionReference(CollectionReference&& reference);

/** @brief Required virtual destructor. */
virtual ~CollectionReference();

/**
* @brief Copy assignment operator. It's totally okay (and efficient) to copy
* CollectionReference instances, as they simply point to the same location in
* the database.
*
* @param[in] reference CollectionReference to copy from.
*
* @returns Reference to the destination CollectionReference.
*/
CollectionReference& operator=(const CollectionReference& reference);

/**
* @brief Move assignment operator. Moving is an efficient operation for
* CollectionReference instances.
*
* @param[in] reference CollectionReference to move data from.
*
* @returns Reference to the destination CollectionReference.
*/
CollectionReference& operator=(CollectionReference&& reference);

protected:
explicit CollectionReference(CollectionReferenceInternal* internal);

private:
friend class DocumentReference;
friend class DocumentReferenceInternal;
friend class FirestoreInternal;

// TODO(zxu123): investigate possibility to use std::unique_ptr or
// firebase::UniquePtr.
CollectionReferenceInternal* internal_ = nullptr;
};

} // namespace firestore
} // namespace firebase

#endif // FIRESTORE_CORE_INCLUDE_FIREBASE_FIRESTORE_COLLECTION_REFERENCE_H_
34 changes: 34 additions & 0 deletions Firestore/core/include/firebase/firestore/document_change.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright 2018 Google
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef FIRESTORE_CORE_INCLUDE_FIREBASE_FIRESTORE_DOCUMENT_CHANGE_H_
#define FIRESTORE_CORE_INCLUDE_FIREBASE_FIRESTORE_DOCUMENT_CHANGE_H_

namespace firebase {
namespace firestore {

/**
* A DocumentChange represents a change to the documents matching a query. It
* contains the document affected and the type of change that occurred (added,
* modified, or removed).
*/
// TODO(zxu123): add more methods to complete the class and make it useful.
class DocumentChange {};

} // namespace firestore
} // namespace firebase

#endif // FIRESTORE_CORE_INCLUDE_FIREBASE_FIRESTORE_DOCUMENT_CHANGE_H_
101 changes: 38 additions & 63 deletions Firestore/core/include/firebase/firestore/document_reference.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

// TODO(rsgowman): This file isn't intended to be used just yet. It's just an
// outline of what the API might eventually look like. Most of this was
// shamelessly stolen and modified from RTDB's header file, melded with the
// shamelessly stolen and modified from rtdb's header file, melded with the
// (java) firestore api.

#ifndef FIRESTORE_CORE_INCLUDE_FIREBASE_FIRESTORE_DOCUMENT_REFERENCE_H_
Expand All @@ -29,41 +29,30 @@
#include <functional>
#endif

#include "firebase/app.h"
#include "firebase/firestore/collection_reference.h"
#include "firebase/firestore/document_snapshot.h"
#include "firebase/firestore/event_listener.h"
#include "firebase/firestore/field_value.h"
#include "firebase/firestore/firestore.h"
#include "firebase/firestore/firestore_errors.h"
#include "firebase/firestore/listener_registration.h"
#include "firebase/firestore/set_options.h"
#include "firebase/future.h"

// TODO(rsgowman): Note that RTDB uses:
// #if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN
// to protect move operators from older compilers. But all our supported
// compilers support this, so we've skipped the #if guard. This TODO comment is
// here so we don't forget to mention this during the API review, and should be
// removed once this note has migrated to the API review doc.

// TODO(rsgowman): replace these forward decls with appropriate includes (once
// they exist)
namespace firebase {
class App;
template <typename T>
class Future;
} // namespace firebase

namespace firebase {
namespace firestore {

// TODO(rsgowman): replace these forward decls with appropriate includes (once
// they exist)
class FieldValue;
class DocumentSnapshot;
class DocumentReferenceInternal;
class Firestore;
class Error;
template <typename T>
class EventListener;
class ListenerRegistration;
class CollectionReference;
class DocumentListenOptions;
// TODO(rsgowman): not quite a forward decl, but required to make the default
// parameter to Set() "compile".
class SetOptions {
public:
SetOptions();
};
class FirestoreInternal;

// TODO(rsgowman): move this into the FieldValue header
#ifdef STLPORT
Expand All @@ -80,12 +69,19 @@ using MapFieldValue = std::unordered_map<std::string, FieldValue>;
*
* Create a DocumentReference via Firebase::Document(const string& path).
*
* NOT thread-safe: an instance should not be used from multiple threads
*
* Subclassing Note: Firestore classes are not meant to be subclassed except for
* use in test mocks. Subclassing is not supported in production code and new
* SDK releases may break code that does so.
*/
class DocumentReference {
public:
enum class MetadataChanges {
kExclude,
kInclude,
};

/**
* @brief Default constructor. This creates an invalid DocumentReference.
* Attempting to perform any operations on this reference will fail (and cause
Expand Down Expand Up @@ -269,28 +265,13 @@ class DocumentReference {
* this DocumentReference. (Ownership is not transferred; you are responsible
* for making sure that listener is valid as long as this DocumentReference is
* valid and the listener is registered.)
* @param[in] option The option whether to listen metadata-changes or not.
*
* @return A registration object that can be used to remove the listener.
*/
virtual ListenerRegistration AddSnapshotListener(
EventListener<DocumentSnapshot>* listener);

/**
* @brief Starts listening to the document referenced by this
* DocumentReference.
*
* @param[in] options The options to use for this listen.
* @param[in] listener The event listener that will be called with the
* snapshots, which must remain in memory until you remove the listener from
* this DocumentReference. (Ownership is not transferred; you are responsible
* for making sure that listener is valid as long as this DocumentReference is
* valid and the listener is registered.)
*
* @return A registration object that can be used to remove the listener.
*/
virtual ListenerRegistration AddSnapshotListener(
const DocumentListenOptions& options,
EventListener<DocumentSnapshot>* listener);
EventListener<DocumentSnapshot>* listener,
MetadataChanges option = MetadataChanges::kExclude);

#if defined(FIREBASE_USE_STD_FUNCTION) || defined(DOXYGEN)
/**
Expand All @@ -299,35 +280,29 @@ class DocumentReference {
*
* @param[in] callback function or lambda to call. When this function is
* called, exactly one of the parameters will be non-null.
* @param[in] option The option whether to listen metadata-changes or not.
*
* @return A registration object that can be used to remove the listener.
*
* @note This method is not available when using STLPort on Android, as
* std::function is not supported on STLPort.
*/
virtual ListenerRegistration AddSnapshotListener(
std::function<void(const DocumentSnapshot*, const Error*)> callback);

/**
* @brief Starts listening to the document referenced by this
* DocumentReference.
*
* @param[in] options The options to use for this listen.
* @param[in] callback function or lambda to call. When this function is
* called, exactly one of the parameters will be non-null.
*
* @return A registration object that can be used to remove the listener.
*
* @note This method is not available when using STLPort on Android, as
* std::function is not supported on STLPort.
*/
virtual ListenerRegistration AddSnapshotListener(
const DocumentListenOptions& options,
std::function<void(const DocumentSnapshot*, const Error*)> callback);
std::function<void(const DocumentSnapshot*, const Error*)> callback,
MetadataChanges option = MetadataChanges::kExclude);
#endif // defined(FIREBASE_USE_STD_FUNCTION) || defined(DOXYGEN)

protected:
explicit DocumentReference(DocumentReferenceInternal* internal);

private:
friend class FirestoreInternal;

// TODO(zxu123): investigate possibility to use std::unique_ptr or
// firebase::UniquePtr.
DocumentReferenceInternal* internal_ = nullptr;
};

// TODO(rsgowman): probably define and inline here.
bool operator==(const DocumentReference& lhs, const DocumentReference& rhs);

inline bool operator!=(const DocumentReference& lhs,
Expand Down Expand Up @@ -361,7 +336,7 @@ namespace std {
// C++ style guide. But we think this is probably ok in this case since:
// a) It's the standard way of doing this outside of Google (as the style guide
// itself points out), and
// b) This has a straightforward hash function anyway (just hash the path) so I
// b) This has a straightfoward hash function anyway (just hash the path) so I
// don't think the concerns in the style guide are going to bite us.
//
// Raise this concern during the API review.
Expand Down
38 changes: 38 additions & 0 deletions Firestore/core/include/firebase/firestore/document_snapshot.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright 2018 Google
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef FIRESTORE_CORE_INCLUDE_FIREBASE_FIRESTORE_DOCUMENT_SNAPSHOT_H_
#define FIRESTORE_CORE_INCLUDE_FIREBASE_FIRESTORE_DOCUMENT_SNAPSHOT_H_

namespace firebase {
namespace firestore {

/**
* A DocumentSnapshot contains data read from a document in your Firestore
* database. The data can be extracted with the data() method or by using
* FooValue() to access a specific field, where Foo is the type of that field.
*
* For a DocumentSnapshot that points to a non-existing document, any data
* access will raise assertion. You can use the exists() method to explicitly
* verify a documents existence.
*/
// TODO(zxu123): add more methods to complete the class and make it useful.
class DocumentSnapshot {};

} // namespace firestore
} // namespace firebase

#endif // FIRESTORE_CORE_INCLUDE_FIREBASE_FIRESTORE_DOCUMENT_SNAPSHOT_H_
9 changes: 4 additions & 5 deletions Firestore/core/include/firebase/firestore/event_listener.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,18 @@
#ifndef FIRESTORE_CORE_INCLUDE_FIREBASE_FIRESTORE_EVENT_LISTENER_H_
#define FIRESTORE_CORE_INCLUDE_FIREBASE_FIRESTORE_EVENT_LISTENER_H_

#include "firebase/firestore/firestore_errors.h"

namespace firebase {
namespace firestore {

// TODO(rsgowman): replace these forward decl's with appropriate includes (once
// they exist)
class Error;

/**
* @brief An interface for event listeners.
*/
template <typename T>
class EventListener {
public:
virtual ~EventListener() {}
/**
* @brief OnEvent will be called with the new value or the error if an error
* occurred.
Expand All @@ -44,7 +43,7 @@ class EventListener {
* @param value The value of the event. null if there was an error.
* @param error The error if there was error. null otherwise.
*/
void OnEvent(const T* value, const Error* error);
virtual void OnEvent(const T* value, const Error* error) = 0;
};

} // namespace firestore
Expand Down
Loading

0 comments on commit ec72ca8

Please sign in to comment.