2007-09-17 05:47:22 +02:00
|
|
|
/*
|
2009-07-19 05:47:36 +02:00
|
|
|
ASSET-DIAGNOSTICS.hpp - collection of test and debug helpers
|
2010-12-17 23:28:49 +01:00
|
|
|
|
2008-03-10 04:25:03 +01:00
|
|
|
Copyright (C) Lumiera.org
|
|
|
|
|
2008, Hermann Vosseler <Ichthyostega@web.de>
|
2010-12-17 23:28:49 +01:00
|
|
|
|
2007-09-17 05:47:22 +02:00
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License as
|
2010-12-17 23:28:49 +01:00
|
|
|
published by the Free Software Foundation; either version 2 of
|
|
|
|
|
the License, or (at your option) any later version.
|
|
|
|
|
|
2007-09-17 05:47:22 +02:00
|
|
|
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.
|
2010-12-17 23:28:49 +01:00
|
|
|
|
2007-09-17 05:47:22 +02:00
|
|
|
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.
|
2010-12-17 23:28:49 +01:00
|
|
|
|
2007-09-17 05:47:22 +02:00
|
|
|
*/
|
|
|
|
|
|
2009-07-19 05:47:36 +02:00
|
|
|
/** @file asset-diagnostics.hpp
|
|
|
|
|
** Small helper and diagnostic functions related to Asset and AssetManager
|
2007-09-17 05:47:22 +02:00
|
|
|
**
|
|
|
|
|
** @see assetmanager.hpp
|
|
|
|
|
** @see CreateAsset_test
|
|
|
|
|
** @see IdentityOfAssets_test
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2009-07-19 05:47:36 +02:00
|
|
|
#ifndef ASSET_ASSET_DIAGNOSTICS_H
|
|
|
|
|
#define ASSET_ASSET_DIAGNOSTICS_H
|
2007-09-17 05:47:22 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "proc/assetmanager.hpp"
|
2013-09-01 17:36:05 +02:00
|
|
|
#include "lib/format-string.hpp"
|
2009-12-29 04:39:27 +01:00
|
|
|
#include "lib/util-foreach.hpp"
|
2008-12-18 04:47:41 +01:00
|
|
|
#include "lib/util.hpp"
|
2007-09-17 05:47:22 +02:00
|
|
|
|
2014-04-03 22:42:48 +02:00
|
|
|
#include <functional>
|
2007-09-17 05:47:22 +02:00
|
|
|
#include <iostream>
|
|
|
|
|
|
2007-11-26 04:27:27 +01:00
|
|
|
using util::contains;
|
2007-09-17 05:47:22 +02:00
|
|
|
using util::for_each;
|
2013-09-01 17:36:05 +02:00
|
|
|
using util::_Fmt;
|
2014-04-03 22:42:48 +02:00
|
|
|
using std::placeholders::_1;
|
|
|
|
|
using std::bind;
|
2007-09-17 05:47:22 +02:00
|
|
|
using std::string;
|
|
|
|
|
using std::cout;
|
|
|
|
|
|
|
|
|
|
|
2011-12-02 17:50:44 +01:00
|
|
|
namespace proc {
|
2011-01-15 14:43:50 +01:00
|
|
|
namespace asset {
|
|
|
|
|
|
2007-11-26 04:27:27 +01:00
|
|
|
inline void
|
|
|
|
|
dump (PcAsset& aa)
|
2011-01-15 14:43:50 +01:00
|
|
|
{
|
|
|
|
|
if (!aa)
|
|
|
|
|
cout << "Asset(NULL)\n";
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-09-01 17:36:05 +02:00
|
|
|
_Fmt fmt("%s %|50T.| id=%s adr=%p smart-ptr=%p use-count=%u");
|
2011-01-15 14:43:50 +01:00
|
|
|
cout << fmt % str(aa) % aa->getID() % aa.get() % &aa % (aa.use_count() - 1) << "\n";
|
|
|
|
|
} }
|
|
|
|
|
|
|
|
|
|
|
2007-11-26 04:27:27 +01:00
|
|
|
inline void
|
|
|
|
|
dumpAssetManager ()
|
2011-01-15 14:43:50 +01:00
|
|
|
{
|
|
|
|
|
list<PcAsset> assets (AssetManager::instance().listContent());
|
|
|
|
|
cout << "----all-registered-Assets----\n";
|
|
|
|
|
for_each (assets, bind (&dump, _1));
|
|
|
|
|
}
|
2007-11-26 04:27:27 +01:00
|
|
|
|
|
|
|
|
|
2008-04-05 07:26:54 +02:00
|
|
|
template<class CHI, class PAR>
|
2007-11-26 04:27:27 +01:00
|
|
|
inline bool
|
2015-07-02 19:16:46 +02:00
|
|
|
dependencyCheck (lib::P<CHI> child, lib::P<PAR> parent)
|
2011-01-15 14:43:50 +01:00
|
|
|
{
|
|
|
|
|
return (child == parent)
|
|
|
|
|
|| (0 < child->getParents().size()
|
|
|
|
|
&& (parent == child->getParents()[0])
|
|
|
|
|
&& (contains (parent->getDependant(), child)))
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-12-02 16:10:03 +01:00
|
|
|
}} // namespace proc::asset
|
2007-09-17 05:47:22 +02:00
|
|
|
#endif
|