X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=example%2Fdbos%2Fworkdir%2Ffilesystem%2FAbstract.cpp;fp=example%2Fdbos%2Fworkdir%2Ffilesystem%2FAbstract.cpp;h=f30447061108d529d5b1c9389f97dd43b8f83043;hb=78be86969d2f26a9084b0c4af6ce43d5fa4ed3fd;hp=0000000000000000000000000000000000000000;hpb=a3b95648bd76140ef55e0b5941d423eee6c3856f;p=anna.git diff --git a/example/dbos/workdir/filesystem/Abstract.cpp b/example/dbos/workdir/filesystem/Abstract.cpp new file mode 100644 index 0000000..f304470 --- /dev/null +++ b/example/dbos/workdir/filesystem/Abstract.cpp @@ -0,0 +1,52 @@ +// ANNA - Anna is Not Nothingness Anymore // +// // +// (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo // +// // +// See project site at http://redmine.teslayout.com/projects/anna-suite // +// See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE // + + +#include "Abstract.hpp" + +using namespace std; +using namespace anna; +using namespace workdir; + +filesystem::Abstract::Abstract (const Abstract::ClassType::_v classType, const std::string& name) : + a_classType (classType), + a_name (name), a_parent (NULL) +{ + a_path = name; +} + +filesystem::Abstract::Abstract (const Abstract::ClassType::_v classType, filesystem::Abstract* parent, const std::string& name) : + a_classType (classType), + a_name (name), + a_parent (parent) +{ + a_parent->a_children.push_back (this); + a_path = calculePath (parent, name); +} + +/*virtual*/ +filesystem::Abstract::~Abstract () +{ + for (child_iterator ii = child_begin (), maxii = child_end (); ii != maxii; ii ++) + delete child (ii); + + a_children.clear (); +} + +/* static */ +string filesystem::Abstract::calculePath (const filesystem::Abstract* parent, const std::string& shortPath) + throw () +{ + string result; + + if (parent!= NULL) { + result = parent->a_path; + result += '/'; + } + + return result += shortPath; +}