artifact_impl.cpp

Go to the documentation of this file.
00001 
00004 #include "artifact_impl.hpp"
00005 #include "variables.hpp"
00006 
00007 artifact_impl::artifact_impl()
00008 : ref_count_(1), name_(), mod_time_(static_cast<time_t>(-1)), variables_(0)
00009 {}
00010 
00011 artifact_impl::artifact_impl(std::string const& name)
00012 : ref_count_(1), name_(name), mod_time_(get_mod_time()), variables_(0)
00013 {}
00014 
00015 artifact_impl::~artifact_impl()
00016 {
00017    delete variables_;
00018 }
00019 
00020 void artifact_impl::add_ref()
00021 {
00022    ++ref_count_;
00023 }
00024 
00025 void artifact_impl::delete_ref()
00026 {
00027    --ref_count_;
00028    if (ref_count_ == 0)
00029      delete this;
00030 }
00031 
00032 std::string const& artifact_impl::name()
00033 const
00034 {
00035   return name_;
00036 }
00037 
00038 std::time_t artifact_impl::mod_time()
00039 const
00040 {
00041   return mod_time_;
00042 }
00043 
00044 std::string artifact_impl::expand(std::string str)
00045 const
00046 {
00047    return ::expand(str, variables_);
00048 }
00049 
00050 void artifact_impl::build()
00051 {}
00052 
00053 std::time_t artifact_impl::get_mod_time()
00054 {
00055     // Real programs should get this information from the
00056     // operating system. This program returns the current time.
00057     return std::time(0);
00058 }
00059 
00060 void artifact_impl::store_variable(std::string const& name,
00061                                    std::string const& value)
00062 {
00063    if (variables_ == 0)
00064       variables_ = new variable_map;
00065    (*variables_)[name] = value;
00066 }

Generated on Sun Nov 30 09:53:22 2008 for Exploring C++ - Final Forms of Key Examples by  doxygen 1.5.3