Env类是tensorflow访问系统函数的接口,主要包含了大部分系统操作函数的封装。
整体上Env类提供了统一的接口(大量虚函数),但不能直接实例化,需要调用在不同系统上的子类实例化。class Env 定义在tensorflow/core/platform/env.h中,部分函数定义在同目录下的env.cc中,另外一部分在tensorflow/core/platform中不同平台(posix、windows、hadoop等有不同)目录下的env.cc中。即tensorflow在编译时,会指定编译哪个平台的版本,然后将这个平台的目录包括在编译目录中。
//主要提供tensorflow访问系统函数的接口,例如使用操作系统自带文件系统
class Env {
public:
Env();
virtual ~Env() = default;
/// \brief Returns a default environment suitable for the current operating
/// system.
///
/// Sophisticated users may wish to provide their own Env
/// implementation instead of relying on this default environment.
///
/// The result of Default() belongs to this library and must never be deleted.
static Env* Default();//注意这个函数,在不同系统下,会实例化不同子类对象,是一个单例
/// \brief Returns the FileSystem object to handle operations on the file
///