* src/evtgba/Makefile.am, src/evtgba/evtgba.cc, src/evtgba/evtgba.hh, src/evtgba/evtgbaiter.hh, src/evtgba/explicit.cc, src/evtgba/explicit.hh, src/evtgba/product.cc, src/evtgba/product.hh, src/evtgba/symbol.cc, src/evtgba/symbol.hh, src/evtgbaalgos/Makefile.am, src/evtgbaalgos/dotty.cc, src/evtgbaalgos/dotty.hh, src/evtgbaalgos/reachiter.cc, src/evtgbaalgos/reachiter.hh, src/evtgbaalgos/save.cc, src/evtgbaalgos/save.hh, src/evtgbaparse/Makefile.am, src/evtgbaparse/evtgbaparse.yy, src/evtgbaparse/evtgbascan.ll, src/evtgbaparse/fmterror.cc, src/evtgbaparse/parsedecl.hh, src/evtgbaparse/public.hh, src/evtgbatest/Makefile.am, src/evtgbatest/defs.in, src/evtgbatest/explicit.cc, src/evtgbatest/explicit.test, src/evtgbatest/product.cc, src/evtgbatest/product.test, src/evtgbatest/readsave.cc, src/evtgbatest/readsave.test: New files. * configure.ac: Create the Makefiles in these new subdirectories. * src/Makefile.am: Recurse them.
109 lines
2.3 KiB
C++
109 lines
2.3 KiB
C++
// Copyright (C) 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
|
|
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
|
// et Marie Curie.
|
|
//
|
|
// This file is part of Spot, a model checking library.
|
|
//
|
|
// Spot 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.
|
|
//
|
|
// Spot 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 Spot; see the file COPYING. If not, write to the Free
|
|
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
// 02111-1307, USA.
|
|
|
|
#include <cassert>
|
|
#include "symbol.hh"
|
|
#include <ostream>
|
|
|
|
namespace spot
|
|
{
|
|
symbol::map symbol::instances_;
|
|
|
|
symbol::symbol(const std::string* name)
|
|
: name_(name), refs_(1)
|
|
{
|
|
}
|
|
|
|
symbol::~symbol()
|
|
{
|
|
map::iterator i = instances_.find(name());
|
|
assert (i != instances_.end());
|
|
instances_.erase(i);
|
|
}
|
|
|
|
const symbol*
|
|
symbol::instance(const std::string& name)
|
|
{
|
|
map::iterator i = instances_.find(name);
|
|
if (i != instances_.end())
|
|
{
|
|
const symbol* s = i->second;
|
|
s->ref();
|
|
return s;
|
|
}
|
|
// Convoluted insertion because we want the NAME member of the
|
|
// value to point to the key.
|
|
i = instances_.insert(map::value_type(name, 0)).first;
|
|
i->second = new symbol(&i->first);
|
|
return i->second;
|
|
}
|
|
|
|
const std::string&
|
|
symbol::name() const
|
|
{
|
|
return *name_;
|
|
}
|
|
|
|
void
|
|
symbol::ref() const
|
|
{
|
|
++refs_;
|
|
}
|
|
|
|
void
|
|
symbol::unref() const
|
|
{
|
|
assert(refs_ > 0);
|
|
--refs_;
|
|
if (!refs_)
|
|
delete this;
|
|
}
|
|
|
|
int
|
|
symbol::ref_count_() const
|
|
{
|
|
return refs_;
|
|
}
|
|
|
|
unsigned
|
|
symbol::instance_count()
|
|
{
|
|
return instances_.size();
|
|
}
|
|
|
|
std::ostream&
|
|
symbol::dump_instances(std::ostream& os)
|
|
{
|
|
for (map::iterator i = instances_.begin(); i != instances_.end(); ++i)
|
|
{
|
|
os << i->second << " = " << i->second->ref_count_()
|
|
<< " * symbol(" << i->second->name() << ")" << std::endl;
|
|
}
|
|
return os;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|