OpenCog Framework  Branch: master, revision 6f0b7fc776b08468cf1b74aa9db028f387b4f0c0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
opencog::ClassServer Class Reference

#include <ClassServer.h>

Public Member Functions

Type addType (const Type parent, const std::string &name)
 
TypeSignaladdTypeSignal ()
 
template<typename OutputIterator >
unsigned long getChildren (Type type, OutputIterator result)
 
template<typename OutputIterator >
unsigned long getChildrenRecursive (Type type, OutputIterator result)
 
template<typename Function >
void foreachRecursive (Function func, Type type)
 
Type getNumberOfClasses ()
 
bool isA (Type sub, Type super)
 
bool isA_non_recursive (Type sub, Type super)
 
bool isValid (Type t)
 
bool isLink (Type t)
 
bool isNode (Type t)
 
bool isDefined (const std::string &typeName)
 
Type getType (const std::string &typeName)
 
const std::string & getTypeName (Type type)
 

Static Public Member Functions

static ClassServercreateInstance (void)
 

Private Member Functions

 ClassServer ()
 
void setParentRecursively (Type parent, Type type)
 

Private Attributes

std::mutex type_mutex
 
Type nTypes
 
std::vector< std::vector< bool > > inheritanceMap
 
std::vector< std::vector< bool > > recursiveMap
 
std::unordered_map
< std::string, Type
name2CodeMap
 
std::unordered_map< Type,
const std::string * > 
code2NameMap
 
TypeSignal _addTypeSignal
 

Detailed Description

Definition at line 51 of file ClassServer.h.

Constructor & Destructor Documentation

ClassServer::ClassServer ( void  )
private

Private default constructor for this class to make it a singleton.

Definition at line 46 of file ClassServer.cc.

References nTypes.

+ Here is the caller graph for this function:

Member Function Documentation

Type ClassServer::addType ( const Type  parent,
const std::string &  name 
)

Adds a new atom type with the given name and parent type

Definition at line 60 of file ClassServer.cc.

References _addTypeSignal, code2NameMap, DPRINTF, getType(), inheritanceMap, name2CodeMap, nTypes, recursiveMap, setParentRecursively(), and type_mutex.

boost::signals2::signal< void(Type)> & ClassServer::addTypeSignal ( )

Provides ability to get type-added signals.

Warning
methods connected to this signal must not call ClassServer::addType or things will deadlock.

Definition at line 115 of file ClassServer.cc.

References _addTypeSignal.

+ Here is the caller graph for this function:

ClassServer * ClassServer::createInstance ( void  )
static

Returns a new ClassServer instance

Definition at line 55 of file ClassServer.cc.

References ClassServer().

template<typename Function >
void opencog::ClassServer::foreachRecursive ( Function  func,
Type  type 
)
inline

Definition at line 122 of file ClassServer.h.

References nTypes, and recursiveMap.

+ Here is the caller graph for this function:

template<typename OutputIterator >
unsigned long opencog::ClassServer::getChildren ( Type  type,
OutputIterator  result 
)
inline

Stores the children types on the OutputIterator 'result'. Returns the number of children types.

Definition at line 96 of file ClassServer.h.

References inheritanceMap, and nTypes.

+ Here is the caller graph for this function:

template<typename OutputIterator >
unsigned long opencog::ClassServer::getChildrenRecursive ( Type  type,
OutputIterator  result 
)
inline

Definition at line 109 of file ClassServer.h.

References nTypes, and recursiveMap.

+ Here is the caller graph for this function:

Type ClassServer::getNumberOfClasses ( )

Returns the total number of classes in the system.

Returns
The total number of classes in the system.

Definition at line 120 of file ClassServer.cc.

References nTypes.

+ Here is the caller graph for this function:

Type ClassServer::getType ( const std::string &  typeName)

Returns the type of a given class.

Parameters
typeNameClass type name.
Returns
The type of a givenn class.

Definition at line 138 of file ClassServer.cc.

References name2CodeMap, and type_mutex.

+ Here is the caller graph for this function:

const std::string & ClassServer::getTypeName ( Type  type)

Returns the string representation of a given atom type.

Parameters
typeAtom type code.
Returns
The string representation of a givenn class.

Definition at line 148 of file ClassServer.cc.

References code2NameMap, and type_mutex.

+ Here is the caller graph for this function:

bool opencog::ClassServer::isA ( Type  sub,
Type  super 
)
inline

Returns whether a given class is assignable from another. This is the single-most commonly called method in this class.

Parameters
superSuper class.
subSubclass.
Returns
Whether a given class is assignable from another.

Definition at line 144 of file ClassServer.h.

References nTypes, recursiveMap, and type_mutex.

+ Here is the caller graph for this function:

bool ClassServer::isA_non_recursive ( Type  sub,
Type  super 
)

Definition at line 125 of file ClassServer.cc.

References inheritanceMap, nTypes, and type_mutex.

bool ClassServer::isDefined ( const std::string &  typeName)

Returns whether a class with name 'typeName' is defined.

Definition at line 132 of file ClassServer.cc.

References name2CodeMap, and type_mutex.

bool opencog::ClassServer::isLink ( Type  t)
inline

Returns true if given class is a Link.

Parameters
tclass.
Returns
Whether a given class is Link.

Definition at line 174 of file ClassServer.h.

References isA().

bool opencog::ClassServer::isNode ( Type  t)
inline

Returns true if given class is a Node.

Parameters
tclass.
Returns
Whether a given class is Node.

Definition at line 182 of file ClassServer.h.

References isA().

+ Here is the caller graph for this function:

bool opencog::ClassServer::isValid ( Type  t)
inline

Returns true if given class is a valid atom type.

Parameters
tclass.
Returns
Whether a given class is valid.

Definition at line 166 of file ClassServer.h.

References isA().

void ClassServer::setParentRecursively ( Type  parent,
Type  type 
)
private

Definition at line 105 of file ClassServer.cc.

References nTypes, and recursiveMap.

+ Here is the caller graph for this function:

Member Data Documentation

TypeSignal opencog::ClassServer::_addTypeSignal
private

Definition at line 74 of file ClassServer.h.

std::unordered_map<Type, const std::string*> opencog::ClassServer::code2NameMap
private

Definition at line 73 of file ClassServer.h.

std::vector< std::vector<bool> > opencog::ClassServer::inheritanceMap
private

Definition at line 70 of file ClassServer.h.

std::unordered_map<std::string, Type> opencog::ClassServer::name2CodeMap
private

Definition at line 72 of file ClassServer.h.

Type opencog::ClassServer::nTypes
private

Definition at line 68 of file ClassServer.h.

std::vector< std::vector<bool> > opencog::ClassServer::recursiveMap
private

Definition at line 71 of file ClassServer.h.

std::mutex opencog::ClassServer::type_mutex
mutableprivate

Definition at line 66 of file ClassServer.h.


The documentation for this class was generated from the following files: