/*
* Config_ValidatorMessage.cpp
*
- * Created on: 08 èþëÿ 2014 ã.
+ * Created on: 08 Jul 2014 ã.
* Author: sbh
*/
/*
* Config_ValidatorMessage.h
*
- * Created on: 08 èþëÿ 2014 ã.
+ * Created on: 08 Jul 2014 ã.
* Author: sbh
*/
//CONFIG_EXPORT static const char* UID() const;
CONFIG_EXPORT const std::string& validatorId() const;
- const std::string& featureId() const;
- const std::string& attributeId() const;
+ CONFIG_EXPORT const std::string& featureId() const;
+ CONFIG_EXPORT const std::string& attributeId() const;
CONFIG_EXPORT const std::list<std::string>& parameters() const;
CONFIG_EXPORT bool isValid() const;
ConstructionPlugin_Point.cpp
)
+SET(XML_RESOURCES
+ plugin-Construction.xml
+ point_widget.xml
+)
+
ADD_DEFINITIONS(-DCONSTRUCTIONPLUGIN_EXPORTS ${BOOST_DEFINITIONS})
-ADD_LIBRARY(ConstructionPlugin SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
+ADD_LIBRARY(ConstructionPlugin SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${XML_RESOURCES})
TARGET_LINK_LIBRARIES(ConstructionPlugin ${PROJECT_LIBRARIES} ModelAPI GeomAPI GeomAlgoAPI)
+INSTALL(TARGETS ConstructionPlugin DESTINATION plugins)
+INSTALL(FILES ${XML_RESOURCES} DESTINATION plugins)
+
INCLUDE_DIRECTORIES(
../ModelAPI
../GeomAPI
../GeomAlgoAPI
)
-SET(XML_RESOURCES
- plugin-Construction.xml
- point_widget.xml
-)
-
-INSTALL(TARGETS ConstructionPlugin DESTINATION plugins)
-INSTALL(FILES ${XML_RESOURCES} DESTINATION plugins)
ADD_UNIT_TESTS(TestPointName.py
)
<workbench id="Construction">
<group id="Basic">
<feature id="Point" title="Point" tooltip="Create a new point" icon=":icons/point.png">
- <validator id="test" parameters="x,y,z"/>
+ <!-- validator id="test" parameters="x,y,z"/ -->
<source path="point_widget.xml"/>
</feature>
<feature id="Axis" title="Axis" tooltip="Create a new axis" icon=":icons/axis.png" keysequence="" internal="true">
- <validator id="inside" parameters="a,b"/>
+ <!-- validator id="inside" parameters="a,b"/ -->
</feature>
<feature id="Plane" title="Plane" tooltip="Create a new plane" icon=":icons/plane.png" keysequence="" internal="true"/>
</group>
#include <Events_Loop.h>
#include <Events_Error.h>
#include <Config_FeatureMessage.h>
+#include <Config_ValidatorMessage.h>
#include <Config_ModuleReader.h>
#include <TDF_CopyTool.hxx>
ModelAPI_PluginManager::setPluginManager(boost::shared_ptr<ModelAPI_PluginManager>(this));
// register the configuration reading listener
Events_Loop* aLoop = Events_Loop::loop();
- static Events_ID FeatureEvent = Events_Loop::eventByName("FeatureRegisterEvent");
- aLoop->registerListener(this, FeatureEvent);
+ static const Events_ID kFeatureEvent = Events_Loop::eventByName("FeatureRegisterEvent");
+ aLoop->registerListener(this, kFeatureEvent);
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED));
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_DELETED));
+ aLoop->registerListener(this, Events_Loop::eventByName(EVENT_VALIDATOR_LOADED));
}
void Model_PluginManager::processEvent(const Events_Message* theMessage)
{
- static Events_ID FeatureEvent = Events_Loop::eventByName("FeatureRegisterEvent");
- if (theMessage->eventID() == FeatureEvent) {
+ static const Events_ID kFeatureEvent = Events_Loop::eventByName("FeatureRegisterEvent");
+ static const Events_ID kValidatorEvent = Events_Loop::eventByName(EVENT_VALIDATOR_LOADED);
+ if (theMessage->eventID() == kFeatureEvent) {
const Config_FeatureMessage* aMsg =
dynamic_cast<const Config_FeatureMessage*>(theMessage);
if (aMsg) {
}
// plugins information was started to load, so, it will be loaded
myPluginsInfoLoaded = true;
+ } else if (theMessage->eventID() == kValidatorEvent) {
+ const Config_ValidatorMessage* aMsg = dynamic_cast<const Config_ValidatorMessage*>(theMessage);
+ if (aMsg) {
+ if (aMsg->attributeId().empty()) { // feature validator
+ validators()->assignValidator(aMsg->validatorId(), aMsg->featureId());
+ } else { // attribute validator
+ validators()->assignValidator(aMsg->validatorId(), aMsg->featureId(),
+ aMsg->attributeId(), aMsg->parameters());
+ }
+ }
} else { // create/update/delete
if (myCheckTransactions && !rootDocument()->isOperation())
Events_Error::send("Modification of data structure outside of the transaction");
isError = true;
}
if (myFeatures.find(theFeatureID) != myFeatures.end()) {
- Events_Error::send(
- string("Validator for feature ") + theFeatureID + " is already registered");
+ // TODO: it is called many times now because of not-optimized XML reader
+ //Events_Error::send(
+ // string("Validator for feature ") + theFeatureID + " is already registered");
isError = true;
}
if (!isError)
pair<ModelAPI_Validator*, list<string> >(aVal->second, theArguments);
}
} else {
- Events_Error::send(
- string("Validator ") + theID + " for feature " + theFeatureID +
- "attribute " + theAttrID + " is already registered");
+ // TODO: it is called many times now because of not-optimized XML reader
+ //Events_Error::send(
+ // string("Validator ") + theID + " for feature " + theFeatureID +
+ // "attribute " + theAttrID + " is already registered");
isError = true;
}
}