From 97746052df546fd0694117467251555199c03b9b Mon Sep 17 00:00:00 2001 From: Gabriel Corona Date: Mon, 30 May 2016 10:21:59 +0200 Subject: [PATCH] [s4u] Group fields at the end of the class --- include/simgrid/s4u/Activity.hpp | 17 ++++++----------- include/simgrid/s4u/comm.hpp | 31 ++++++++++++++----------------- include/simgrid/s4u/engine.hpp | 6 +++--- include/simgrid/s4u/file.hpp | 13 +++++-------- include/simgrid/s4u/storage.hpp | 16 ++++++++-------- 5 files changed, 36 insertions(+), 47 deletions(-) diff --git a/include/simgrid/s4u/Activity.hpp b/include/simgrid/s4u/Activity.hpp index 533a92d1f0..222c9320cb 100644 --- a/include/simgrid/s4u/Activity.hpp +++ b/include/simgrid/s4u/Activity.hpp @@ -32,12 +32,7 @@ XBT_PUBLIC_CLASS Activity { protected: Activity(); virtual ~Activity(); - -private: - simgrid::simix::Synchro *pimpl_ = NULL; -private: - e_s4u_activity_state_t state_ = inited; public: /** Starts a previously created activity. * @@ -56,9 +51,6 @@ public: /** Retrieve the current state of the activity */ e_s4u_activity_state_t getState() {return state_;} -private: - double remains_ = 0; -public: /** Get the remaining amount of work that this Activity entails. When it's 0, it's done. */ double getRemains(); /** Set the [remaining] amount of work that this Activity will entail @@ -66,13 +58,16 @@ public: * It is forbidden to change the amount of work once the Activity is started */ void setRemains(double remains); -private: - void *userData_ = NULL; -public: /** Put some user data onto the Activity */ void setUserData(void *data) {userData_=data;} /** Retrieve the user data of the Activity */ void *getUserData() { return userData_; } + +private: + simgrid::simix::Synchro *pimpl_ = nullptr; + e_s4u_activity_state_t state_ = inited; + double remains_ = 0; + void *userData_ = nullptr; }; // class }}; // Namespace simgrid::s4u diff --git a/include/simgrid/s4u/comm.hpp b/include/simgrid/s4u/comm.hpp index be969c2a6d..288e9c485e 100644 --- a/include/simgrid/s4u/comm.hpp +++ b/include/simgrid/s4u/comm.hpp @@ -38,18 +38,9 @@ public: void wait() override; void wait(double timeout) override; -private: - double rate_=-1; -public: /** Sets the maximal communication rate (in byte/sec). Must be done before start */ void setRate(double rate); -private: - void *dstBuff_ = NULL; - size_t dstBuffSize_ = 0; - void *srcBuff_ = NULL; - size_t srcBuffSize_ = sizeof(void*); -public: /** Specify the data to send */ void setSrcData(void * buff); /** Specify the size of the data to send */ @@ -65,16 +56,22 @@ public: size_t getDstDataSize(); -private: /* FIXME: expose these elements in the API */ +private: + double rate_ = -1; + void *dstBuff_ = nullptr; + size_t dstBuffSize_ = 0; + void *srcBuff_ = nullptr; + size_t srcBuffSize_ = sizeof(void*); + + /* FIXME: expose these elements in the API */ int detached_ = 0; - int (*matchFunction_)(void *, void *, smx_synchro_t) = NULL; - void (*cleanFunction_)(void *) = NULL; - void (*copyDataFunction_)(smx_synchro_t, void*, size_t) = NULL; + int (*matchFunction_)(void *, void *, smx_synchro_t) = nullptr; + void (*cleanFunction_)(void *) = nullptr; + void (*copyDataFunction_)(smx_synchro_t, void*, size_t) = nullptr; -private: - smx_process_t sender_ = NULL; - smx_process_t receiver_ = NULL; - Mailbox *mailbox_ = NULL; + smx_process_t sender_ = nullptr; + smx_process_t receiver_ = nullptr; + Mailbox *mailbox_ = nullptr; }; }} // namespace simgrid::s4u diff --git a/include/simgrid/s4u/engine.hpp b/include/simgrid/s4u/engine.hpp index ecd7f7db52..046eea7a17 100644 --- a/include/simgrid/s4u/engine.hpp +++ b/include/simgrid/s4u/engine.hpp @@ -52,14 +52,14 @@ public: /** @brief Retrieve the engine singleton */ static s4u::Engine *instance(); -private: - static s4u::Engine *instance_; -public: /** @brief Retrieve the root AS, containing all others */ simgrid::s4u::As *rootAs(); /** @brief Retrieve the AS of the given name (or nullptr if not found) */ simgrid::s4u::As *asByNameOrNull(const char *name); + +private: + static s4u::Engine *instance_ = nullptr; }; }} // namespace simgrid::s4u diff --git a/include/simgrid/s4u/file.hpp b/include/simgrid/s4u/file.hpp index 0e976337eb..809bd7829b 100644 --- a/include/simgrid/s4u/file.hpp +++ b/include/simgrid/s4u/file.hpp @@ -28,14 +28,10 @@ XBT_PUBLIC_CLASS File { public: File(const char *fullpath, void* userdata); ~File(); -private: - smx_file_t pimpl_; - const char *path_; -public: /** Retrieves the path to the file */ const char *path() { return path_;} -public: + /** Simulates a read action. Returns the size of data actually read * * FIXME: reading from a remotely mounted disk is not implemented yet. @@ -53,10 +49,7 @@ public: void setUserdata(void *data) {userdata_ = data;} /** Retrieves the previously stored data */ void* userdata() {return userdata_;} -private: - void *userdata_=NULL; -public: /** Retrieve the datasize */ sg_size_t size(); @@ -79,6 +72,10 @@ public: XBT_PUBLIC(msg_error_t) MSG_file_rmove(msg_file_t fd, msg_host_t host, const char* fullpath); */ +private: + smx_file_t pimpl_ = nullptr; + const char *path_ = nullptr; + void *userdata_ = nullptr; }; }} // namespace simgrid::s4u diff --git a/include/simgrid/s4u/storage.hpp b/include/simgrid/s4u/storage.hpp index 3d9dd19da2..4504bb8924 100644 --- a/include/simgrid/s4u/storage.hpp +++ b/include/simgrid/s4u/storage.hpp @@ -16,9 +16,12 @@ namespace simgrid { namespace s4u { XBT_PUBLIC_CLASS Storage { + friend s4u::Engine; + private: Storage(std::string name, smx_storage_t inferior); virtual ~Storage(); + public: /** Retrieve a Storage by its name. It must exist in the platform file */ static Storage &byName(const char* name); @@ -39,20 +42,17 @@ XBT_PUBLIC(const char *) MSG_storage_get_host(msg_storage_t storage); */ protected: smx_storage_t inferior(); -private: - friend s4u::Engine; - - static boost::unordered_map *storages_; - std::string name_; - smx_storage_t pimpl_; - public: void setUserdata(void *data) {userdata_ = data;} void *userdata() {return userdata_;} + private: - void *userdata_ = NULL; + static boost::unordered_map *storages_; + std::string name_; + smx_storage_t pimpl_ = nullptr; + void *userdata_ = nullptr; }; } /* namespace s4u */ -- 2.20.1