You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

runtime_context.h 1.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /**
  2. * Copyright 2020 Huawei Technologies Co., Ltd
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef MINDSPORE_CCSRC_MINDDATA_DATASET_ENGINE_RUNTIME_CONTEXT_H_
  17. #define MINDSPORE_CCSRC_MINDDATA_DATASET_ENGINE_RUNTIME_CONTEXT_H_
  18. #include <memory>
  19. #include <utility>
  20. #include "minddata/dataset/core/client.h"
  21. #include "minddata/dataset/engine/consumers/tree_consumer.h"
  22. namespace mindspore::dataset {
  23. class TreeConsumer;
  24. /// Class the represents single runtime instance which can consume data from a data pipeline
  25. class RuntimeContext {
  26. public:
  27. /// Default constructor
  28. RuntimeContext() = default;
  29. /// Initialize the runtime, for now we just call the global init
  30. /// \return Status error code
  31. Status Init() { return GlobalInit(); }
  32. /// Method to terminate the runtime, this will not release the resources
  33. /// \return Status error code
  34. virtual Status Terminate() { return Status::OK(); }
  35. /// Set the tree consumer
  36. /// \param tree_consumer to be assigned
  37. void AssignConsumer(std::unique_ptr<TreeConsumer> tree_consumer);
  38. /// Get the tree consumer
  39. /// \return Raw pointer to the tree consumer.
  40. TreeConsumer *GetConsumer() { return tree_consumer_.get(); }
  41. private:
  42. std::unique_ptr<TreeConsumer> tree_consumer_;
  43. };
  44. } // namespace mindspore::dataset
  45. #endif // MINDSPORE_CCSRC_MINDDATA_DATASET_ENGINE_RUNTIME_CONTEXT_H_