extract asset iostream display into separate header
This commit is contained in:
parent
a70376dc4b
commit
240c5ac232
5 changed files with 83 additions and 35 deletions
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include "proc/asset.hpp"
|
||||
#include "proc/assetmanager.hpp"
|
||||
#include "proc/asset/asset-format.hpp"
|
||||
#include "lib/util-foreach.hpp"
|
||||
#include "lib/util.hpp"
|
||||
|
||||
|
|
|
|||
53
src/proc/asset/asset-format.hpp
Normal file
53
src/proc/asset/asset-format.hpp
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
ASSET-FORMAT.hpp - helpers for display of asset entities
|
||||
|
||||
Copyright (C) Lumiera.org
|
||||
2011, Hermann Vosseler <Ichthyostega@web.de>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ASSET_ASSET_FORMAT_H
|
||||
#define ASSET_ASSET_FORMAT_H
|
||||
|
||||
#include "proc/asset.hpp"
|
||||
#include "proc/asset/category.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
||||
|
||||
namespace asset {
|
||||
|
||||
|
||||
inline std::ostream&
|
||||
operator<< (std::ostream& os, Category const& cat)
|
||||
{
|
||||
return os << string(cat);
|
||||
}
|
||||
|
||||
inline std::ostream&
|
||||
operator<< (std::ostream& os, Asset::Ident const& idi)
|
||||
{
|
||||
return os << string(idi);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace asset
|
||||
#endif
|
||||
|
|
@ -27,7 +27,6 @@
|
|||
#include "lib/symbol.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <boost/functional/hash.hpp>
|
||||
|
||||
|
||||
|
|
@ -101,12 +100,6 @@ namespace asset {
|
|||
};
|
||||
|
||||
|
||||
inline ostream&
|
||||
operator<< (ostream& os, Category const& cat)
|
||||
{
|
||||
return os << string(cat);
|
||||
}
|
||||
|
||||
inline size_t
|
||||
hash_value (Category const& cat)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
#include "lib/util.hpp"
|
||||
|
||||
#include "proc/asset/category.hpp"
|
||||
#include "proc/asset/asset-format.hpp"
|
||||
|
||||
#include <boost/format.hpp>
|
||||
#include <iostream>
|
||||
|
|
|
|||
|
|
@ -50,42 +50,42 @@ using std::string;
|
|||
using std::cout;
|
||||
|
||||
|
||||
namespace asset
|
||||
{
|
||||
|
||||
namespace asset {
|
||||
|
||||
inline void
|
||||
dump (PcAsset& aa)
|
||||
{
|
||||
if (!aa)
|
||||
cout << "Asset(NULL)\n";
|
||||
else
|
||||
{
|
||||
format fmt("%s %|50T.| id=%s adr=%p smart-ptr=%p use-count=%u");
|
||||
cout << fmt % str(aa) % aa->getID() % aa.get() % &aa % (aa.use_count() - 1) << "\n";
|
||||
} }
|
||||
|
||||
{
|
||||
if (!aa)
|
||||
cout << "Asset(NULL)\n";
|
||||
else
|
||||
{
|
||||
format fmt("%s %|50T.| id=%s adr=%p smart-ptr=%p use-count=%u");
|
||||
cout << fmt % str(aa) % aa->getID() % aa.get() % &aa % (aa.use_count() - 1) << "\n";
|
||||
} }
|
||||
|
||||
|
||||
inline void
|
||||
dumpAssetManager ()
|
||||
{
|
||||
list<PcAsset> assets (AssetManager::instance().listContent());
|
||||
cout << "----all-registered-Assets----\n";
|
||||
for_each (assets, bind (&dump, _1));
|
||||
}
|
||||
{
|
||||
list<PcAsset> assets (AssetManager::instance().listContent());
|
||||
cout << "----all-registered-Assets----\n";
|
||||
for_each (assets, bind (&dump, _1));
|
||||
}
|
||||
|
||||
|
||||
template<class CHI, class PAR>
|
||||
inline bool
|
||||
dependencyCheck (P<CHI> child, P<PAR> parent)
|
||||
{
|
||||
return (child == parent)
|
||||
|| (0 < child->getParents().size()
|
||||
&& (parent == child->getParents()[0])
|
||||
&& (contains (parent->getDependant(), child)))
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
{
|
||||
return (child == parent)
|
||||
|| (0 < child->getParents().size()
|
||||
&& (parent == child->getParents()[0])
|
||||
&& (contains (parent->getDependant(), child)))
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace asset
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in a new issue