LUMIERA.clone/src/proc/mobject/placement-index.hpp

110 lines
2.9 KiB
C++
Raw Normal View History

/*
PLACEMENT-INDEX.hpp - tracking individual Placements and their relations
Copyright (C) Lumiera.org
2009, 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.
*/
2009-05-09 17:32:29 +02:00
/** @file placement-index.hpp
**
2009-05-09 17:32:29 +02:00
** @see PlacementRef
** @see PlacementIndex_test
**
*/
2009-05-09 17:32:29 +02:00
#ifndef MOBJECT_PLACEMENT_INDEX_H
#define MOBJECT_PLACEMENT_INDEX_H
//#include "pre.hpp"
//#include "proc/mobject/session/locatingpin.hpp"
//#include "proc/asset/pipe.hpp"
#include "proc/mobject/placement.hpp"
2009-05-13 03:46:08 +02:00
#include "proc/mobject/placement-ref.hpp"
#include <tr1/memory>
#include <boost/scoped_ptr.hpp>
2009-05-13 03:46:08 +02:00
#include <vector>
namespace mobject {
using std::tr1::shared_ptr;
using boost::scoped_ptr;
2009-05-13 03:46:08 +02:00
using std::vector;
2009-06-02 03:31:52 +02:00
class MObject;
/**
*/
2009-05-09 17:32:29 +02:00
class PlacementIndex
{
class Table;
scoped_ptr<Table> pTab_;
public:
typedef Placement<MObject> PlacementMO;
2009-06-02 03:31:52 +02:00
typedef PlacementRef<MObject> PRef;
typedef PlacementMO::ID ID;
PlacementMO& find (ID) const;
template<class MO>
2009-06-02 03:31:52 +02:00
Placement<MO>& find (PlacementMO::Id<MO>) const;
template<class MO>
Placement<MO>& find (PlacementRef<MO>) const;
PlacementMO& getScope (PlacementMO&) const;
PlacementMO& getScope (ID) const;
vector<PRef> getReferrers (ID) const;
/** retrieve the logical root scope */
PlacementMO& getRoot() const;
/** diagnostic: number of indexed entries */
size_t size() const;
bool contains (PlacementMO const&) const;
bool contains (ID const&) const;
/* == mutating operations == */
ID insert (PlacementMO& newObj, PlacementMO& targetScope);
bool remove (PlacementMO&);
bool remove (ID);
};
////////////////TODO currently just fleshing out the API; probably have to split off an impl.class; but for now a PImpl is sufficient...
/** preliminary helper for creating a placement index (instance).
* @todo integrate this into the session and provide an extra factory for tests
*/
shared_ptr<PlacementIndex>
createPlacementIndex() ;
} // namespace mobject
#endif