mail[Wesnoth-commits] r43488 - in /trunk/src: persist_context.cpp persist_context.hpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by upthorn on June 16, 2010 - 15:47:
Author: upthorn
Date: Wed Jun 16 15:47:53 2010
New Revision: 43488

URL: http://svn.gna.org/viewcvs/wesnoth?rev=43488&view=rev
Log:
Minor changes to initialization order and better separation of member types 
(object/data/function) in persist_context class and member structs. 

Modified:
    trunk/src/persist_context.cpp
    trunk/src/persist_context.hpp

Modified: trunk/src/persist_context.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/persist_context.cpp?rev=43488&r1=43487&r2=43488&view=diff
==============================================================================
--- trunk/src/persist_context.cpp (original)
+++ trunk/src/persist_context.cpp Wed Jun 16 15:47:53 2010
@@ -92,28 +92,16 @@
        load_persist_data(namespace_.root_,cfg_,false);
 }
 
-persist_context::persist_context(const std::string &name_space) :
-namespace_(name_space),
-cfg_(),
-valid_(namespace_.valid()),
-root_node_(namespace_.root_,this,cfg_),
-active_(&root_node_)
+persist_context::persist_context(const std::string &name_space) 
+       : cfg_()
+       , namespace_(name_space)
+       , root_node_(namespace_.root_,this,cfg_)
+       , active_(&root_node_)
+       , valid_(namespace_.valid())
 {
        load();
        root_node_.init();
        active_ = &(root_node_.child(namespace_.next()));
-}
-
-persist_context::~persist_context() {
-//     collected_ = true;
-//     if (parent_ != NULL) {
-//             if (!parent_->collected_)
-//                     delete parent_;
-//     }
-//     for (persist_context::child_map::iterator i = children_.begin(); i != 
children_.end(); i++) {
-//             if (!i->second->collected_)
-//                     delete i->second;
-//     }
 }
 
 bool persist_context::clear_var(std::string &global)
@@ -166,7 +154,7 @@
        return ret;
 }
 
-config persist_context::get_var(const std::string &global)
+config persist_context::get_var(const std::string &global) const
 {
        config ret;
 //     if (cfg_.empty()) {

Modified: trunk/src/persist_context.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/persist_context.hpp?rev=43488&r1=43487&r2=43488&view=diff
==============================================================================
--- trunk/src/persist_context.hpp (original)
+++ trunk/src/persist_context.hpp Wed Jun 16 15:47:53 2010
@@ -30,6 +30,7 @@
                std::string lineage_;
                std::string descendants_;
                bool valid_;
+
                bool valid() const {
                        return valid_;
                }
@@ -93,22 +94,21 @@
                                descendants_ = 
namespace_.substr(namespace_.find_first_of(".") + 1);
                }
        };
-       // TODO: transaction support (needed for MP)
-       name_space namespace_;
-       config cfg_;
        struct node {
                typedef std::map<std::string,node*> child_map;
+
                std::string name_;
                persist_context *root_;
-               config &cfg_;
                node *parent_;
                child_map children_;
+               config &cfg_;
+
                node(std::string name, persist_context *root, config & cfg, 
node *parent = NULL)
                        : name_(name)
                        , root_(root)
-                       , cfg_(cfg)
                        , parent_(parent)
                        , children_()
+                       , cfg_(cfg)
                {
                }
 
@@ -140,30 +140,34 @@
                                cfg_.add_child("variables");
                }
        };
-       bool valid_;
+
+       config cfg_;
+       name_space namespace_;
        node root_node_;
        node *active_;
+       bool valid_;
+
+       // TODO: transaction support (needed for MP)
        void load();
        void init();
        bool save_context();
        persist_context()
-               : namespace_()
-               , cfg_()
-               , valid_(false)
+               : cfg_()
+               , namespace_()
                , root_node_("",this,cfg_)
                , active_(&root_node_)
+               , valid_(false)
        {};
 
        static persist_context invalid;
        persist_context &add_child(const std::string &key);
 public:
        persist_context(const std::string &name_space);
-       ~persist_context();
        bool clear_var(std::string &);
-       config get_var(const std::string &);
+       config get_var(const std::string &) const;
        bool set_var(const std::string &, const config &);
        bool valid() const { return valid_; };
-       bool dirty() const {
+       bool dirty() const { 
                return true;
        };
        operator bool() { return valid_; }




Related Messages


Powered by MHonArc, Updated Wed Jun 16 16:00:23 2010